配置 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