在RN开发中,ios会使用pod 安装第三方库
- 通过
pod init
自成 Podfile文件 - 打开文件加入相关内容如下
platform :ios, '8.0'
# The target name is most likely the name of your project.
target 'lgzq' do
# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
'RCTNetwork',
'RCTWebSocket', # needed for debugging
# Add any other subspecs you want to use in your project
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
# Third party deps podspec link
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'GLog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
pod 'react-native-amap-geolocation', path: '../node_modules/react-native-amap-geolocation/lib/ios'
end
- 执行
pod install
,这个过程会等待比较长的时间 - 安装后的工程不在使用
.xcodeproj
打开,而是.xcworkspace
,打开 - build后会在
../node_modules/react-native/
生成一个third-party
- 注意如果报
third-party
相关文件没有找到,这时清理工程,同时也要把third-party
删除。否则一样会报错。