六、更换源
这有多是由于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”便可。