React Native实践React Native学习React Native开发

react native 使用Cocoapods

2017-12-11  本文已影响427人  giants_one

什么是CocoaPods

CocoaPods是OS X和iOS下的一个第三类库管理工具,通过CocoaPods工具我们可以为项目添加被称为“Pods”的依赖库(这些类库必须是CocoaPods本身所支持的),并且可以轻松管理其版本。

CocoaPods的好处

1、在引入第三方库时它可以自动为我们完成各种各样的配置,包括配置编译阶段、连接器选项、甚至是ARC环境下的-fno-objc-arc配置等。
2、使用CocoaPods可以很方便地查找新的第三方库,这些类库是比较“标准的”,而不是网上随便找到的,这样可以让我们找到真正好用的类库。

作者使用react native版本0.49.5,本章用 react native国际化组件集成为例。

image.png
此插件提到可以用Cocoapods来自动完成ios配置,下面是使用步骤:

步骤:

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

target 'TestDemo' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
        pod 'RNI18n', :path => '../node_modules/react-native-i18n'
  # Pods for TestDemo

  target 'TestDemo-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'TestDemoTests' do
    inherit! :search_paths
    # Pods for testing
  end

end



以上就是整个过程,后面如果在遇到能使用Cocoapods的,直接在target 'SimpleApp' doend之间加上pod 'xxx'运行 pod install --verbose --no-repo-update命令就可以了。

上一篇 下一篇

猜你喜欢

热点阅读