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