React Native

react-native third-party

2018-05-24  本文已影响0人  5ae3c8c40b0e

在RN开发中,ios会使用pod 安装第三方库

  1. 通过 pod init 自成 Podfile文件
  2. 打开文件加入相关内容如下
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

  1. 执行 pod install ,这个过程会等待比较长的时间
  2. 安装后的工程不在使用.xcodeproj打开,而是.xcworkspace,打开
  3. build后会在../node_modules/react-native/生成一个third-party
  4. 注意如果报third-party相关文件没有找到,这时清理工程,同时也要把third-party删除。否则一样会报错。
上一篇 下一篇

猜你喜欢

热点阅读