我正在使用 Kotlin Multiplatform 在我的
iosMain
实现中生成 WebView:
@Composable
actual fun LoadUrl(url: String) {
val webView = remember { WKWebView() }
UIKitView(
factory = {
webView.apply {
WKWebViewConfiguration().apply {
allowsInlineMediaPlayback = true
allowsAirPlayForMediaPlayback = true
allowsPictureInPictureMediaPlayback = true
}
loadRequest(NSURLRequest(NSURL(string = url)))
}
webView
},
modifier = Modifier
)
}
不幸的是,它无法加载。 我的理解是不需要额外的权利,但错误表明不然:
2024-10-04 23:29:07.074826-0400 iosApp[7557:140326] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))" UserInfo={NSLocalizedFailureReason=((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))}>
我尝试将权利添加到我的
iosApp.entitlements
文件中,但这似乎并不能解决问题。 所有在线研究都告诉我,我什至不需要添加权利来运行它。
尝试将 NSAppTransportSecurity 添加到您的 Info.plist 中
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>