gpt4 book ai didi

ios - 尝试将 react-native 应用程序与现有 ios 应用程序集成时出现 "_fbBatchedBridge is undefined"错误

转载 作者:行者123 更新时间:2023-12-01 17:05:54 26 4
gpt4 key购买 nike

将 react-native 集成到现有的 ios 应用程序中。
我有一个 native ios 应用程序,它从远程服务器中提取 ios 包。
我按照 react-native 站点 (https://facebook.github.io/react-native/docs/embedded-app-ios.html) 上的说明进行操作,我能够在 React 中安装 pod 依赖项并在模拟器中启动 ios 应用程序。

当我导航到加载 react-native 提供的 View 的 View 时,在该 View 中加载 react-native 应用程序的代码看起来像

NSString *urlString = @"https://<some_url_here>/main.jsbundle"; //a remotely hosted bundle.
NSURL *jsCodeLocation = [NSURL URLWithString:urlString];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName: @"react-native-app"
initialProperties: nil
launchOptions:nil];

当我直接点击 https://<some_url_here>/main.jsbundle我确实看到捆绑包被下载,所以我知道该 url 确实为捆绑包提供服务。

我看到的问题是当我尝试加载 View 时,我看到一个红色屏幕:
_fbBatchedBridge is undefined

当我在网上搜索此问题时,似乎当应用程序尝试从 dev-server 拉出捆绑包但 dev-server 未运行时会发生此问题。这不适用于我的情况,因为捆绑包是远程托管的。

关于可能出现什么问题的任何想法?

最佳答案

这可能是与 ATS(应用程序传输安全)相关的问题。尝试为您要连接的域禁用它以进行调试。

在您的 Info.plist 中:

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>www.the-domain-name.com</key>
<dict>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>

Xamarin 有一个 nice explanation用于优化 ATS 设置。

关于ios - 尝试将 react-native 应用程序与现有 ios 应用程序集成时出现 "_fbBatchedBridge is undefined"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35326032/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com