iOS 下 Podfile 使用方法


配置 Podlist

Pod 是 iOS 下包管理工具,类似于 JavaScript 里的 npm 或 yarn

创建 Podfile

创建 Podfile 有两种方式:

  • 打开 Terminal,在 iOS 项目的根目录,执行 touch Podfile
    或者
  • 打开 Terminal,在 iOS 项目的根目录,执行 pod init

配置 Podfile

一个简单的 Podfile

target 'MyApp'
pod 'AFNetworking', '~>3.0.4' # AFNetworking 版本必须 >=3.0.4 并且 <3.1.0

一个复杂的 Podfile

platform :ios, '9.0' # 指定平台与版本 inhibit_all_warnings! # 全局禁止显示警告 target 'MyApp' do # Pods for MyApp pod 'Fabric', '~>1.6.0' # Fabric 版本必须 >=1.6.0 并且 <1.7.0 pod 'ObjectiveSugar', '>=1.0.0' # ObjectiveSugar 版本必须 >=1.0.0 pod 'AFNetworking','<=4.0' # AFNetworking 版本必须<=4.0 # Pods for testing target 'MyAppTests' do # MyAppTests 目录下的引用 inherit! :search_paths end # Pods for testing target 'MyAppUITests' do # MyAppUITests 目录下的引用 inherit! :search_paths end end

安装依赖包

注:要先关闭 xcode, 不然不能正常生成 Podfile.lock 和 xxx.xcworkspace 文件

打开 Terminal,在 iOS 项目的根目录,执行 pod install

参考文档

欢迎您帮忙纠错, 一起帮助更多的人。 一起来学习交流React, QQ群:413381701

首发于:https://github.com/Kennytian/learning-react-native


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM