fastlane 使用中遇到的问题


使用fastlane 实现快速持续的更新、在安装过程中 出现的一系列问题:

1.安装fastlane :sudo gem install fastlane

-错误:ERROR: Failed to build gem native extension.

#不要添加多个gem 源

#开始以为是gem 源的问题
#查看gem源
gem sources
# 删除默认的gem源 
gem sources --remove https://rubygems.org/
# 增加taobao作为gem源 
gem sources -a https://ruby.taobao.org/
# 查看当前的gem源
gem sources
*** CURRENT SOURCES ***

http://ruby.taobao.org
# 请确保只有 ruby.taobao.org

# 清空源缓存
gem sources -c
# 更新源缓存
gem sources -u

错误仍然存在;

然后查到是ruby版本的问题

2.更新ruby版本,安装rvm

http://blog.csdn.net/lissdy/article/details/9191351,

http://stackoverflow.com/questions/3696564/how-to-update-ruby-to-1-9-x-on-mac

 curl -L get.rvm.io | bash -s stable 

测试是否安装正常 rvm -v 

列出已知ruby版本:rvm list known 

安装一个ruby版本:rvm install 2.0.0

使用一个ruby版本:rvm use 2.0.0

设置默认版本: rvm use 2.0.0 --default

查询:rvm list

卸载:rvm remove 2.0.0

3.rvm install ruby-2.1.4,报下面的错误

?  ~ git:(master) ? rvm install ruby-2.1.4
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/10.11/x86_64/ruby-2.1.4.tar.bz2
Checking requirements for osx.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mach (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/Library/Homebrew/extend/pathname.rb:2:in `'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/Library/Homebrew/global.rb:3:in `'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/Library/brew.rb:16:in `
' ERROR: '/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it! Requirements installation failed with status: 1.

然后这样处理:

$ brew install openssl  # if you want to install all dependencies run 'rvm requirements'
$ rmv reinstall|install ruby-2.1.4

这里参考了http://stackoverflow.com/questions/18863211/homebrew-permissions-mess

最后就顺利安装fastlane了。

4.在fastlane init初始化时出现 

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

参考这里https://github.com/fastlane/fastlane/blob/master/docs/FAQs.md#im-getting-an-ssl-error 

5.这里需要安装 brew .

安装命令如下:
curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1

这里需要FQ。(不然会有如下错 curl: (56) Recv failure: Connection reset by peer)

然后

6.? ~ git:(master) ? brew update && brew upgrade openssl
Error: /usr/local must be writable!

解决:sudo chown -R 'goyoo' /usr/local

然后就可以brew update && brew upgrade openssl

7.Error: openssl not installed

brew install openssl 

?  /  brew install openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2g.el_capitan.bottl
######################################################################## 100.0%
==> Pouring openssl-1.0.2g.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
??  /usr/local/Cellar/openssl/1.0.2g: 466 files, 11.9M

查看openssl版本:

openssl
version

OpenSSL 0.9.8zg 14 July 2015 //不是最新的。

?  ~ git:(master) ? whereis openssl
/usr/bin/openssl
?  ~ git:(master) ? 
?  ~ git:(master) ? 
?  ~ git:(master) ? 
?  ~ git:(master) ? mv /usr/bin/openssl /usr/bin/openssl_OLD
mv: rename /usr/bin/openssl to /usr/bin/openssl_OLD: Operation not permitted
?  ~ git:(master) ? openssl versino
openssl:Error: 'versino' is an invalid command.

Standard commands
asn1parse         ca                ciphers           cms               
crl               crl2pkcs7         dgst              dh                
dhparam           dsa               dsaparam          ec                
ecparam           enc               engine            errstr            
gendh             gendsa            genpkey           genrsa            
nseq              ocsp              passwd            pkcs12            
pkcs7             pkcs8             pkey              pkeyparam         
pkeyutl           prime             rand              req               
rsa               rsautl            s_client          s_server          
s_time            sess_id           smime             speed             
spkac             srp               ts                verify            
version           x509              

Message Digest commands (see the `dgst' command for more details)
md4               md5               mdc2              rmd160            
sha               sha1              

Cipher commands (see the `enc' command for more details)
aes-128-cbc       aes-128-ecb       aes-192-cbc       aes-192-ecb       
aes-256-cbc       aes-256-ecb       base64            bf                
bf-cbc            bf-cfb            bf-ecb            bf-ofb            
camellia-128-cbc  camellia-128-ecb  camellia-192-cbc  camellia-192-ecb  
camellia-256-cbc  camellia-256-ecb  cast              cast-cbc          
cast5-cbc         cast5-cfb         cast5-ecb         cast5-ofb         
des               des-cbc           des-cfb           des-ecb           
des-ede           des-ede-cbc       des-ede-cfb       des-ede-ofb       
des-ede3          des-ede3-cbc      des-ede3-cfb      des-ede3-ofb      
des-ofb           des3              desx              idea              
idea-cbc          idea-cfb          idea-ecb          idea-ofb          
rc2               rc2-40-cbc        rc2-64-cbc        rc2-cbc           
rc2-cfb           rc2-ecb           rc2-ofb           rc4               
rc4-40            seed              seed-cbc          seed-cfb          
seed-ecb          seed-ofb          zlib              

?  ~ git:(master) ? 

~ git:(master) ?openssl version 

OpenSSL 1.0.2g  1 Mar 2016

~ git:(master) ? 

参考:http://stackoverflow.com/questions/15185661/openssl-version-macosx-homebrew

http://apple.stackexchange.com/questions/126830/how-to-upgrade-openssl-in-os-x

https://segmentfault.com/a/1190000004395173

然而 fastlane init 的错误并没有解决。

后续、

最后换了一台电脑 轻松fastlane init 和ruby版本 openssl 都没什么关系

然后我就还原系统(10.11.3 )。。。也就可以了。

fastlane简单记录一些细节:

  • deliver:用于上传app,应用截屏和原数据到 App Store

  • snapshot:可以自动化iOS应用在每个设备上的本地化截屏过程

  • frameit:用于在应用截屏外添加设备的边框

  • PEM:可以自动化生成和更新应用推送通知描述文件

  • sigh:可以生成并下载开发者的应用商店配置文件(支持resign)

  • product:可以使用命令行在iTunes Connect中创建iOS应用以及Developer Portal

  • cert:可以自动创建并维护iOS的签名证书

  • codes:使用命令行来生成应用的优惠码

  • gym 编译app 打包

当前路径:/Users/yfan/Desktop/AutoOnlineTest

下图是 fastlane init 产生的目录

 -->gym

    执行gym :直接就在当前目录下生成project.ipa文件和project.app.dsym.zip文件

 -->snapshot

  1.github文档 https://github.com/fastlane/fastlane/tree/master/snapshot

  2.详细的英文文档:https://tisunov.github.io/2015/11/06/automating-app-store-screenshots-generation-with-fastlane-snapshot-and-sketch.html

  3.我的一些记录:

    snapshot是利用Xcode7 的 UI Tests的录制来截屏,更多 使用命令行工具运行Xcode7 UI Tests

    使用过程:①snapshot init初始化 ②将生产的snapshotHelper.swift添加到Project_UI_Tests 目录下③修改sanpfile配置文件包括路径,语言型号等④

//ui test 写这些
override func setUp() {
        super.setUp()
        continueAfterFailure = false
        
        let app = XCUIApplication()
        
        app.launchEnvironment = ["UITest":"1"];
        setupSnapshot(app)//setLanguage(app)弃用        
        app.launch()
      
    }
在需要截屏的地方是用 snapshot("string") 方法进行截屏。
//这个方法里的内容是点击红点,录制过程中自动生成的
func testExample() {
        
        let app = XCUIApplication()
        let masterNavigationBar = app.navigationBars["Master"]
        masterNavigationBar.buttons["Add"].tap()
        snapshot("1Store")
        masterNavigationBar.buttons["Edit"].tap()
        snapshot("2Store")
        masterNavigationBar.buttons["Done"].tap()
        
        snapshot("3Store")
        
    }

    ⑤运行snapshot 就开始截图了,截完图后就生成 screenshots.html和screenshots文件夹中图了。

-->deliver:

  1.运行 deliver 直接从本地上传app元数据(Run deliver to upload the app metadata from your local machine)

  2. 关于路径:ipa 放在当前目录下 就可以用deliver 传ipa

  3.deliver --ipa "AutoOnlineTest.ipa" --submit_for_review  (上传ipa并提交审核)

      4.screenshots 截图路径的位置:如图

  

deliver 执行完后,如图,点y就上传 api 和图片 等信息了。

 

Fastfile :

desc "Deploy a new version to the App Store"
  lane :appstore do
    # match(type: "appstore")
    # snapshot
    # frameit
    # gym # Build your app - more options available
    deliver(force: true,
    app_icon: "./fastlane/AppIcon.png"# 这个是iTunes connection 里的icon 
    )
    # sh "your_script.sh"//可以加一些脚本,填写补充信息
  end

snapfile:

devices([
"iPhone 6",
"iPhone 6 Plus",
"iPhone 5",
"iPhone 4s",
])

languages([
"en-US"#选择哪个语言
])

output_directory "./screenshots"#输出路径