美文网首页ios专题
Swift项目中嵌入ReactNative

Swift项目中嵌入ReactNative

作者: 关关雎鸠1206 | 来源:发表于2016-08-10 13:31 被阅读0次

第一步:打开xcode,新建一个swift项目

第二步:在项目下新建ReactNative的文件夹,把index.io.js跟package.json拷贝进来,执行npm install,根据package.json生成node_module

第三步:在项目的下面,拷贝podfile文件,然后安装pod,对应的指令有touch Podfile,pod install,pod update

第四步:把下面的代码粘贴到controller里面,控制从swift中跳转到reactnative页面的跳转

let str = "http://192.168.0.171:8081/index.ios.bundle?platform=ios&dev=true"

let jsCodeLocation = NSURL(string: str)

let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "ReactTest", initialProperties: nil, launchOptions: nil)

self.view.addSubview(rootView)

相关文章

网友评论

    本文标题:Swift项目中嵌入ReactNative

    本文链接:https://www.haomeiwen.com/subject/yvzdsttx.html