第一步:将写好的ios的swift的项目拷贝到对应的ios文件的下面
第二步:修改Podfile文件,在文件的后面添加以下代码:
pod 'React', :path => ‘../node_modules/react-native', :subspecs => [
'RCTText',
'RCTImage',
'RCTWebSocket',
'RCTPushNotification',
'RCTActionSheet',
'ART',
'RCTCameraRoll'
]
如果Podfile文件是最新的,需要添加target,在文件的最上面,代码如下:
target :DDU do
第三步:修改对应的AppDelegate.swift文件,代码如下:
let moduleName:String = "AwesomeProject"
let jsCodeLocation: NSURL
jsCodeLocation = NSURL(string: "http://localhost:8081/index.ios.bundle?platform=ios&dev=true")!
let rootView: RCTRootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: moduleName, initialProperties: nil, launchOptions: launchOptions)
rootView.backgroundColor = UIColor.whiteColor()
let rootViewController = UIViewController()
rootViewController.view = rootView
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.rootViewController = rootViewController
window?.makeKeyAndVisible()