我跟随Reactinative文档从一个iOS应用程序加载一个Reactive原住民视图。
import React from 'react';
import { AppRegistry, View, Text } from 'react-native';
const TestView = () => {
return (
<View>
<Text>Hello World</Text>
</View>
);
};
// Module name
AppRegistry.registerComponent('TestView', () => TestView);如文档所示,我正在从iOS应用程序创建视图:
guard let jsCodeLocation = URL(string: "http://localhost:8081/index.bundle?platform=ios") else { return }
let rootView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "TestView",
initialProperties: nil,
launchOptions: nil
)
let vc = UIViewController()
vc.view = rootView
self.present(vc, animated: true, completion: nil)但是当视图控制器出现时,我什么也没看到:

React项目中的集成是正确的。当视图控制器出现时,调用index.js。但这不管用。有什么想法吗?

Xcode日志:
本机运行的应用程序TestView ({ initialProps ={ };rootTag = 51;}) 连接nw_socket_handle_socket_event C15:1套接字SO_ERROR 61:连接拒绝nw_connection_get_connected_socket C15客户端在未连接nw_connection上调用nw_connection_get_connected_socket TCP 0x600003104000失败:错误0:61不变违反:TurboModuleRegistry.getEnforcing(.):“DevSettings”无法找到。验证此名称的模块是否已在本机二进制.,js引擎: hermes中注册。 javascript :需要抛出异常的模块"node_modules/react-native/Libraries/Core/InitializeCore.js",:不变量违反:TurboModuleRegistry.getEnforcing(.):无法找到'DevSettings‘。验证此名称的模块是否已在本机二进制.,js引擎: hermes中注册。 javascript不变冲突:未能调用JavaScript模块方法RCTEventEmitter.receiveTouches()。模块尚未注册为可调用。注册可调用JavaScript模块(n = 10):Systrace、JSTimers、HeapCapture、SamplingProfiler、RCTLog、RCTDeviceEventEmitter、RCTNativeAppEventEmitter、GlobalPerformanceLogger、JSDevSupportModule、HMRClient。 错误的一个常见原因是应用程序输入文件路径不正确。这也可能发生在JS包损坏或加载React .,js engine: hermes时出现早期初始化错误时。 本机使 (父级:(null),executor:(null))无效
发布于 2022-11-24 13:12:55
我没有使用调试模式在Xcode中运行这个应用程序。
https://stackoverflow.com/questions/74393295
复制相似问题