mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-24 20:39:31 -04:00
Merge pull request #740 from kiwix/feature/215-make-webview-inspectable
Make webView inspectable / debuggable
This commit is contained in:
commit
2465f27e10
26
Model/Utilities/Bundle+Extension.swift
Normal file
26
Model/Utilities/Bundle+Extension.swift
Normal file
@ -0,0 +1,26 @@
|
||||
// This file is part of Kiwix for iOS & macOS.
|
||||
//
|
||||
// Kiwix is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// Kiwix is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kiwix; If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Bundle {
|
||||
var isProduction: Bool {
|
||||
#if DEBUG
|
||||
false
|
||||
#else
|
||||
appStoreReceiptURL?.path.contains("sandboxReceipt") == true
|
||||
#endif
|
||||
}
|
||||
}
|
@ -96,6 +96,9 @@ final class BrowserViewModel: NSObject, ObservableObject,
|
||||
init(tabID: NSManagedObjectID? = nil) {
|
||||
self.tabID = tabID
|
||||
webView = WKWebView(frame: .zero, configuration: WebViewConfiguration())
|
||||
if !Bundle.main.isProduction, #available(iOS 16.4, macOS 13.3, *) {
|
||||
webView.isInspectable = true
|
||||
}
|
||||
// Bookmark fetching:
|
||||
bookmarkFetchedResultsController = NSFetchedResultsController(
|
||||
fetchRequest: Bookmark.fetchRequest(), // initially empty
|
||||
@ -402,6 +405,9 @@ final class BrowserViewModel: NSObject, ObservableObject,
|
||||
let configuration = UIContextMenuConfiguration(
|
||||
previewProvider: {
|
||||
let webView = WKWebView(frame: .zero, configuration: WebViewConfiguration())
|
||||
if !Bundle.main.isProduction, #available(iOS 16.4, *) {
|
||||
webView.isInspectable = true
|
||||
}
|
||||
webView.load(URLRequest(url: url))
|
||||
return WebViewController(webView: webView)
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user