六、更換源
這有多是由於Ruby的默認源使用的是cocoapods.org,國內訪問這個網址有時候會有問題,網上的一種解決方案是將遠替換成淘寶的,替換方式以下:
要想驗證是否替換成功了,能夠執行:
$ gem sources -l
正常的輸出結果:
到這裏就已經把Ruby環境成功的安裝到了Mac OS X上。
2、fastlane安裝
一、確保你的Xcode命令行工具的最新版本安裝:
命令:xcode-select --install
若是已經安裝會有提示已經安裝:
二、安裝fastlane
https://docs.fastlane.tools
官方提供了三種安裝方式:
第一種:經過Homebrew,若是fastlane與jenkins結合使用可使用brew安裝,先安裝homebrew,在安裝fastlane,然安裝jenkins,fastlane與jenkins結合使用。
第二種:下載fastlane包,運行包裏面install進行安裝,執行install的時候會被阻止,須要在安全性與隱私設置,還有一個問題下載的包可能不是最新版,在使用的時候提示要更新,這裏更新沒有成功,因此不建議使用。
第三種:本文使用的方法,安裝ruby以後,在命令行輸入:
sudo gem install fastlane -NV
便可安裝,安裝完成後執行:
fastlane -v
可查詢當前安裝版本:
3、項目使用fastlane
一、在終端打開你的iOS項目文件.xcodeproj所在的文件夾
cd xxx
執行fastlane初始化,命令:
fastlane init
會出現一下提示:想要作什麼?由於要打包企業級項目因此這裏選擇4, 若是選擇3,須要輸入Apple ID等相關信息,若是ID是企業級帳號會提示init 失敗。
選擇4以後,會提示回車繼續,完成以後項目文件夾中會多出一個fastlane文件夾,文件中包含Appfile,Fastfile兩個文件
分別對兩個文件的內容設置:
Appfile:主要是app_identifier和apple_id
Fastfile:
都配置完成以後,在終端輸入
fastlane ios enterprise
執行開始打包,這裏ios enterprise 是lane的Name,若是執行錯誤,會有提示.
若是執行後提示gym命令相關的錯誤
fastlane gym produces error: method `to_plist' not defined in Array #11503
能夠參考:
https://github.com/fastlane/fastlane/issues/11503
方法終端命令:
一、rvm @global do uninstall fastlane
二、gem install fastlane
三、rvm @global do gem install fastlane
四、rvm @global do fastlane action gym
五、rvm @global do gem uninstall fastlane
rvm all do gem uninstall fastlane
gem uninstall fastlane
六、gem install fastlane
以後在打包的時候就能夠了,不知道原理:
4、遇到的錯誤
fastlane init
報錯 Unable to locate Xcode. Please make sure to have Xcode installed on your machine
可能在Xcode中沒有設置「Command Line Tools」:打開Xcode偏好設置,選擇"Location"選項卡,選擇相應的「Command Line Tools」便可。