You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS 17.5 Beta中WKWebView无法加载问题 | Xcode 15.4 Beta

WKWebView在Xcode 15.4 Beta 1、iOS 17.5模拟器及Xcode Cloud中无法渲染内容

我的代码多年来运行无异常,但更新至Xcode 15.4(Beta 1)后,WKWebView无法渲染内容。此前Xcode 15发布后Xcode Cloud就出现了该问题,因此我升级了Xcode版本,目前已将测试URL临时替换为google.com。

以下是项目中用于加载URL的代码:

import WebKit
import SwiftUI

struct LoginView: View {

var body: some View {
    NavigationView {
        VStack {
            WebView(urlString: "https://google.com")
                .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
        }
        .navigationTitle("Web View")
    }
}

#Preview {
    LoginView()
}

struct WebView: UIViewRepresentable {

let urlString: String

func makeUIView(context: Context) -> WKWebView {
    let webView = WKWebView()
    webView.navigationDelegate = context.coordinator
    return webView
}

func updateUIView(_ uiView: WKWebView, context: Context) {
    if let url = URL(string: urlString) {
        let request = URLRequest(url: url)
        uiView.load(request)
    }
}
}

该代码在iOS 17.4模拟器及真机上可正常加载,但在iOS 17.5模拟器中完全无法加载。此外,Xcode Cloud使用iPhone 15 Pro Max iOS 17.4模拟器进行UITests时,也存在WebView渲染问题,相关截图如下:

  • iPhone 15 Pro Max iOS 17.5(模拟器):iPhone 15 Pro Max iOS 17.5
  • iPhone 15 Pro Max iOS 17.4(模拟器):iPhone 15 Pro Max iOS 17.4
  • Xcode Cloud UITests:Xcode Cloud UITests

内容的提问来源于stack exchange,提问作者M. Mansuelli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 12:15:20