• ios自动打包-fastlane 安装、使用、更新和卸载


    ios自动打包使用fastlane


    1、首先安装xcode

    首先检查是否已经安装 Xcode 命令行工具,fastlane 使用 xcodebuild 命令进行打包,运行 xcode-select --install 命令,根据你的情况进行不同处理。

    2、没有弹出提示,命令行提示 xcode-select: note: install requested for command line developer tools, 则需要运行下面命令,指定 Xcode 命令行工具所在的路径。

    $ xcode-select -p  // 打印 Xcode 开发目录
    /Applications/Xcode.app/Contents/Developer
    $ xcode-select --switch /Applications/Xcode.app/Contents/Developer //进行选择



    安装 fastlane:
    sudo gem install fastlane --verbose

    安装成功后查看版本:fastlane --version



    初始化:fastlane
    进入项目目录,进行初始化操作

    fastlane init

    选择4、进行自定义操作

    补充:
    1.fastlane 初始化默认会创建三个文件:Fastfile、Appfile、Deliverfile;两个文件夹:metadata、screenshots
    2.Fastfile : 核心文件,主要用于 命令行调用和处理具体的流程,lane相对于一个方法或者函数
    3.Appfile : 存储有关开发者账号相关信息
    4.Deliverfile: deliver工具的配置文件


    
    
    安装蒲公英的 fastlane 插件
    $ fastlane add_plugin pgyer

    安装g工具

    sudo gem install gym

    bundle install --path vendor/bundle

    gem install xcode-select

    security unlock-keychain -p 1234 /Users/shangying/Library/Keychains/Login.keychain

     


     


    打包前,需要开发进行xcode证书配置完成
    配置完成后,mac电脑上需要进行一次完整打包过程才可以


    脚本是初始化生成的文件,如

    /Users/shangying/ios-workspace/syhospital-p-ios/fastlane

     


    脚本配置:

    macos:fastlane SY$ vim Fastfile 

     

    default_platform(:ios)

      

    platform :ios do

     

    desc "Description of what the lane does"

     

     

    lane :p do

     

    gym(

        clean:true,

        scheme:"sy_user_ios_qa",

     

        export_method:"ad-hoc",

        #output_name: output_name,

        output_directory:"./build",

     

       )

       pgyer(api_key: "9b0d93c5............5d0", user_key: "e60b..............b2f4275df4d31")

     

    end

     

    end

     

    appfile文件里写id
    如:

    app_identifier "com.syxxxxxx.user"

     


    编写脚本进行执行如:

    macos:scripts SY$ cat ios-p-app.sh 

    #!/bin/bash

    cd /Users/shangying/ios-workspace/syhospital-p-ios

    git checkout qa

    git pull

    /usr/local/bin/fastlane p

     

    curl -F "file=@/Users/shangying/ios-workspace/syhospital-d-ios/build/sy_doctor_ios_qa.ipa"

    -F "uKey=e60baa4e2c80**********1"

    -F "_api_key=9b0d9****************"

    https://www.pgyer.com/apiv1/app/upload




    说明:

    jenkins执行shell脚本需要注意,环境变量需要带上

    #!/bin/bash
    export LANG=zh_CN.UTF-8
    source ~/.bash_profile
    export PATH=$PATH:/Library/Ruby/Gems/2.3.0/gems/xcpretty-0.3.0/bin

    sh /Users/shangying/scripts/ios-d-app.sh*


    异常:

    如果打包出现异常,提示权限不正确解决方案:

    添加命令 security unlock-keychain -p password /Users/username/Library/Keychains/Login.keychain
    https://www.jianshu.com/p/b03e59560d31


    lane的名称一定不能有特殊符号如-等,需要为str字符串类型(巨坑)



    参考文档:

    http://www.cocoachina.com/ios/20180516/23396.html
    https://www.jianshu.com/p/9d53836a3b64
    http://www.cocoachina.com/ios/20150728/12733.html
  • 相关阅读:
    pm2 配置
    添加项目到远程服务器(git)
    psql 命令行使用
    SQL
    iOS AFNetworking 打印从服务器返回的错误提示信息
    iOS 获取网络图片的大小
    iOS 10 常见配置的问题
    LGLTagsView
    xcode8 关闭控制台打印不用信息
    LGLProgressHUD
  • 原文地址:https://www.cnblogs.com/qiangyuzhou/p/10728874.html
Copyright © 2020-2023  润新知