美文网首页
iOS命令行自动打包(archive)

iOS命令行自动打包(archive)

作者: 等不来的期待 | 来源:发表于2017-01-10 10:37 被阅读132次

    前言:

        iOS开发工程师在测试修复bug的过程中,一般会存在频繁打包的情况,如果一步步在xcode中点击archive,下一步,下一步。。。这样太浪费我们的时间了。下面我们来介绍在命令行使用xcodebuild命令进行自动archive打包并且导出ipa文件。

    准备工作:

    打开你的项目工程配置你的证书和描述文件:

    1

    clean一下你的工程:

    进入到你的工程目录下面:

    cd /Dandy/dandy_workSpace/TestAutoPacking/

    使用以下命令clean工程:

    xcodebuild clean -project TestAutoPacking.xcodeproj -scheme TestAutoPacking -configuration Release

    如果你的工程pod了第三方库,那么你的工程目录下会有".xcworkspace"文件,你将使用这个文件来打开你的项目工程,我们需要替换下我们的命令:

    xcodebuild clean -workspace TestAutoPacking.xcworkspace -scheme TestAutoPacking -configuration Release

    上面的命令中:

    -project TestAutoPacking.xcodeproj:编译项目名称

    -workspace TestAutoPacking.xcworkspace:编译工作空间名称

    -scheme TestAutoPacking:scheme名称(一般会与你的项目名称相同)

    -configuration Release:(Debug/Release)

    -clean成功会是这样:

    2

    -archive导出.xcarchive文件:

    使用下面的命令archive导出.xcarchive文件:

    xcodebuild archive -project TestAutoPacking.xcodeproj -scheme TestAutoPacking -archivePath /dandy/xmeAutoArchive/TestAutoPacking.xcarchive

    或者:

    xcodebuild archive -workspace TestAutoPacking.xcworkspace -scheme TestAutoPacking -archivePath /dandy/xmeAutoArchive/TestAutoPacking.xcarchive

    上面的命令中:

    -project TestAutoPacking.xcodeproj:同clean步骤中一样

    -workspace TestAutoPacking.xcworkspace:同clean步骤中一样

    -scheme TestAutoPacking:同clean步骤中一样

    -archivePath /dandy/xmeAutoArchive/TestAutoPacking.xcarchive:导出.xcarchive文件的目录以及文件名称

    -archive成功会是这样:

    3

    同样会在/dandy/xmeAutoArchive目录下面生成一个TestAutoPacking.xcarchive文件:

    4

    -导出ipa包:

    使用下面命令将.xcarchive文件导出为ipa包:

    xcodebuild -exportArchive -archivePath /dandy/xmeAutoArchive/TestAutoPacking.xcarchive -exportPath /dandy/xmeAutoArchive/TestAutoPacking -exportFormat ipa -exportProvisioningProfile "developmentProfile"

    上面的命令中:

    -archivePath /dandy/xmeAutoArchive/TestAutoPacking.xcarchive:刚刚导出的.xcarchive文件的目录

    -exportPath /dandy/xmeAutoArchive/TestAutoPacking:将要导出的ipa文件的目录以及文件名

    -exportFormat ipa:导出为ipa文件

    -exportProvisioningProfile "developmentProfile":你配置的profile文件的名称:

    5

    -导出ipa成功会是这样:

    6

    -同样会在/dandy/xmeAutoArchive目录下面生成一个TestAutoPacking.ipa文件:

    7

    这样我们的ipa包就导出成功了。

    上传ipa包:

    至于导出ipa包后,怎么安装到手机上,方式就很多了,托管平台也很多:蒲公英,fir.im。就看您自己的选择啦~

    希望对您有帮助,谢谢支持~欢迎关注,我会在空余时间更新技术文章~

    相关文章

      网友评论

          本文标题:iOS命令行自动打包(archive)

          本文链接:https://www.haomeiwen.com/subject/avjkbttx.html