react native 0.55.4集成到本地的坑
2018-06-14 本文已影响0人
俊逸的狮子
coapods的方式
1.pods需要先更新一下 pod update
- 错误:React Native iOS: Could not build module 'yoga': 'algorithm' file not found
需要在node_modules/react-native/ReactCommon/yoga/yoga.podspec 最后一行添加
spec.public_header_files = 'yoga/Yoga.h', 'yoga/YGEnums.h', 'yoga/YGMacros.h'
参考:https://stackoverflow.com/questions/48705250/react-native-ios-could-not-build-module-yoga-algorithm-file-not-found
3.错误:Native module cannot be null
需要添加更多的库,本人试过之后成功的podfile:
source 'https://github.com/CocoaPods/Specs.git'
react_native_path = '../node_modules/react-native'
platform :ios, '8.0'
target 'XXX' do
# ---------react-----------
pod 'React', :path => react_native_path, :subspecs => [
'Core',
'CxxBridge',
'DevSupport', # 如果RN版本 >= 0.43,则需要加入此行才能开启开发者菜单
'RCTText',
'RCTImage',
'RCTNetwork',
'RCTWebSocket', # 这个模块是用于调试功能的
# 在这里继续添加你所需要的模块
'RCTAnimation',
'RCTBlob',
'RCTActionSheet',
'RCTGeolocation',
'RCTSettings',
'RCTVibration',
'RCTActionSheet',
'RCTPushNotification',
'RCTLinkingIOS',
'ART',
]
# 如果你的RN版本 >= 0.42.0,则加入下面这行
pod 'yoga', :path => react_native_path + '/ReactCommon/yoga'
# Third party deps
pod 'DoubleConversion', :podspec => react_native_path + '/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => react_native_path + '/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => react_native_path + '/third-party-podspecs/Folly.podspec'
# ---------react-----------
end
- .a文件要添加到build phases里面
手动拖工程的方式
会找不到头文件
除了要添加header search paths
$(SRCROOT)/../node_modules/react-native/React 注意后边选recursive(递归查找头文件)
还要在edit schemes中设置
image.png
注意react放在前面