react-native-Cocoapods-Swift-Project

Posted youhui

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了react-native-Cocoapods-Swift-Project相关的知识,希望对你有一定的参考价值。

https://blog.csdn.net/u011690583/article/details/51700662

 

1、创建一个xcode工程,single View就行,项目语言选择swift,oc的直接生成就行不用这么麻烦。
2、把跟目录上创建 node的package.json,执行命令

npm init
npm install react-native --save-dev
npm install react --save-dev
 
3、创建podfile文件,然后执行pod install ,必须第二步完成。代码如下:
 

# Uncomment the next line to define a global platform for your project
# platform :ios, ‘9.0‘

target ‘demo1‘ do
  # Comment the next line if you‘re not using Swift and don‘t want to use dynamic frameworks
  use_frameworks!

   pod ‘React‘, :path => ‘./node_modules/react-native‘, :subspecs => [
    ‘Core‘,
    ‘RCTText‘,
    ‘RCTNetwork‘,
    ‘RCTWebSocket‘
  ]
  # 如果你的RN版本 >= 0.42.0,请加入下面这行
  pod "yoga", :path => "./node_modules/react-native/ReactCommon/yoga"


end

 

 

以上是关于react-native-Cocoapods-Swift-Project的主要内容,如果未能解决你的问题,请参考以下文章