Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import androidx.compose.ui.viewinterop.UIKitView
import com.multiplatform.webview.jsbridge.WebViewJsBridge
import com.multiplatform.webview.util.toUIColor
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.cValue
import kotlinx.cinterop.readValue
import platform.CoreGraphics.CGRectZero
import platform.Foundation.NSOperatingSystemVersion
import platform.Foundation.NSProcessInfo
import platform.Foundation.setValue
import platform.WebKit.WKAudiovisualMediaTypeAll
import platform.WebKit.WKAudiovisualMediaTypeNone
Expand Down Expand Up @@ -149,7 +152,22 @@ fun IOSWebView(
}
}

this.setInspectable(state.webSettings.iOSWebSettings.isInspectable)
/**
* Sets the inspectable property of the WKWebView.
* This is only done if the operating system version is iOS 16.4 or later
* to prevent crashes on lower versions where the `setInspectable` method is not available.
* Enabling this allows Safari Web Inspector to debug the content of the WebView.
* The value is determined by `state.webSettings.iOSWebSettings.isInspectable`.
*/
val minSetInspectableVersion =
cValue<NSOperatingSystemVersion> {
majorVersion = 16
minorVersion = 4
patchVersion = 0
}
if (NSProcessInfo.processInfo.isOperatingSystemAtLeastVersion(minSetInspectableVersion)) {
this.setInspectable(state.webSettings.iOSWebSettings.isInspectable)
}
}.also {
val iosWebView = IOSWebView(it, scope, webViewJsBridge)
state.webView = iosWebView
Expand Down