iOS app打包上线测试流程app打包测试上线

iOS利用Jenkins+Mac+gitLab+fir/蒲公英

2019-08-06  本文已影响0人  风月灯

@[TOC](iOS利用Jenkins+Mac+gitLab+fir/蒲公英 快速打包)
原文地址:https://www.jianshu.com/p/484b038712b9

一、下载安装

二、访问Jenkins

三、添加插件

四、gitLab设置

五、创建新Item任务

image.png image.png

六、Item打包设置

#要打包的项目地址,若使用了cocoapods则"test1110/test1110.xcworkspace"
ProjectPath="test1110/test1110.xcodeproj"
#项目中要打包的scheme
TargetScheme="test1110"
#生成的中转文件xcarchive存放地址
ArchivePath="test1110.xcarchive"
#打包使用的配置文件地址
ExportOptionsPlistPath="ExportOptions.plist"
#打包IPA的存放文件,这个名字随便自定义,注意别跟其他path重复
ExportPath="XCBuildIPA"

xcodebuild clean -project ${ProjectPath} \
                 -scheme ${TargetScheme} \

xcodebuild archive  -project ${ProjectPath} \
                    -sdk iphoneos \
                    -scheme ${TargetScheme} \
                    -archivePath ${ArchivePath} \
                    -configuration Release \


echo "+++++++++++++++++ exportArchive +++++++++++++++++"
xcodebuild -exportArchive -archivePath ${ArchivePath}\
                          -exportPath  ${ExportPath}\
                          -exportOptionsPlist ${ExportOptionsPlistPath}\
                          -configuration Release \

七、带参数(tag、branch)的打包

image.png

八、打包完成自动上传fir

image.png

九、钉钉机器人提醒

image.png
https://oapi.dingtalk.com/robot/send?access_token=e9。。。41

十、自定义描述界面

十一、邮件通知

十二、配置奴隶Mac机实现自动打包:参考

重要提示:
security unlock-keychain -p "login pwd" ~/Library/Keychains/login.keychain
image.png

十三、自动配置项目打包模式

十四、适配Xcode10 的BuildSystem

第三行代码 -UseModernBuildSystem=NO 的功能与方法1相同
echo "+++++++++++++++++ 清理工程 +++++++++++++++++"
xcodebuild clean -project ${ProjectPath} \
                 -scheme ${TargetScheme} \
                 -UseModernBuildSystem=NO \

总结

#要打包的项目地址
ProjectPath="OA/CRM.xcodeproj"
#项目中要打包的scheme
TargetScheme="CRM"
#生成的中转文件xcarchive存放地址
ArchivePath="CRM.xcarchive"
#打包使用的配置文件地址,这个是存放在slave机上。
ExportOptionsPlistPath="/Users/macserver/Desktop/ExportOptions.plist"
#打包IPA的存放文件
ExportPath="XCBuildIPA"
#肉鸡的登录密码
SlaveMacPWD="macserver"
#项目配置文件地址
ProjectSettingFilePath="OA/CRM.xcodeproj/project.pbxproj"

echo "+++++++++++++++++ 若项目是自动签名,则修改配置为手动Release签名 +++++++++++++++++"
sed -i "" "s#ProvisioningStyle = Automatic#ProvisioningStyle = Manual#g" ${ProjectSettingFilePath}
sed -i "" "s#CODE_SIGN_STYLE = Automatic#CODE_SIGN_STYLE = Manual#g" ${ProjectSettingFilePath}

sed -i "" "s#PROVISIONING_PROFILE = \"\"#PROVISIONING_PROFILE = \"dc28777c-0cde-4bb2-b9bf-6c6a4c55aa76\"#g" ${ProjectSettingFilePath}
sed -i "" "s#PROVISIONING_PROFILE_SPECIFIER = \"\"#PROVISIONING_PROFILE_SPECIFIER = \"Xueersi.WangXiao.CRM(Dis)\"#g" ${ProjectSettingFilePath}
sed -i "" "s#DEVELOPMENT_TEAM =.*#DEVELOPMENT_TEAM = 6BUND8EFF7;#g" ${ProjectSettingFilePath}
sed -i "" "s#DevelopmentTeam =.*#DevelopmentTeam = 6BUND8EFF7;#g" ${ProjectSettingFilePath}
#若项目bundle id不是com.Xueersi.CRM(target项目的bundle id)那么别替换了,打包失败很正常
#sed -i "" "s#PRODUCT_BUNDLE_IDENTIFIER =.*#PRODUCT_BUNDLE_IDENTIFIER = com.Xueersi.CRM;#g" ${ProjectSettingFilePath}



echo "+++++++++++++++++ 解锁slave机的钥匙串权限 +++++++++++++++++"
security unlock-keychain -p ${SlaveMacPWD} ~/Library/Keychains/login.keychain

echo "+++++++++++++++++ 清理工程 +++++++++++++++++"
xcodebuild clean -project ${ProjectPath} \
                 -scheme ${TargetScheme} \
                 -UseModernBuildSystem=NO \
                 
                 
echo "+++++++++++++++++ 开始打包 +++++++++++++++++"
xcodebuild archive  -project ${ProjectPath} \
                    -sdk iphoneos \
                    -scheme ${TargetScheme} \
                    -archivePath ${ArchivePath} \
                    -configuration Release \
                    -UseModernBuildSystem=NO \


echo "+++++++++++++++++ 导出打包 +++++++++++++++++"
xcodebuild -exportArchive -archivePath ${ArchivePath}\
                          -exportPath  ${ExportPath}\
                          -exportOptionsPlist ${ExportOptionsPlistPath}\
                          -configuration Release \

echo "+++++++++++++++++ 上传蒲公英 +++++++++++++++++"
#蒲公英账号对应的userkey与apikey,只需替换这俩参数即可切换上传地址
PGYUserKey="蒲公英账号对应的userkey(这里我手动打码)"
PGYAPIKey="蒲公英账号对应的apikey(这里也打码)"
curl -F "file=@${ExportPath}/CRM.ipa" -F "uKey=${PGYUserKey}" -F "_api_key=${PGYAPIKey}" https://qiniu-storage.pgyer.com/apiv1/app/upload                          
                           

附:Jenkins 自动打包问题

一、Command /Applications/Xcode.app/Contents/Developer/usr/bin/actool failed with exit code 255

failed content

The following build commands failed: CompileAssetCatalog /Users/macserver/Library/Developer/Xcode/DerivedData/CRM-aghqpbaaoycsdgddnnenvhgeuxjo/Build/Intermediates.noindex/ArchiveIntermediates/CRM/InstallationBuildProductsLocation/Applications/CRM.app CRM/Assets.xcassets

参考答案1:link

二、Command /usr/bin/codesign failed with exit code 1:errSecInternalComponent

failed content

/Users/macserver/Library/Developer/Xcode/DerivedData/CRM-aghqpbaaoycsdgddnnenvhgeuxjo/Build/Intermediates.noindex/ArchiveIntermediates/CRM/InstallationBuildProductsLocation/Applications/CRM.app: errSecInternalComponent

参考答案 链接

security unlock-keychain -p "login pwd" ~/Library/Keychains/login.keychain

三、自动手动冲突问题

failed content

Check dependencies Code Signing Error: CRM has conflicting provisioning settings. CRM is automatically signed for development, but a conflicting code signing identity iPhone Distribution has been manually specified. Set the code signing identity value to "iPhone Developer" in the build settings editor, or switch to manual signing in the project editor.

修复思路,文件内容替换

sed -i "" "s#被替换的旧内容#替换成的内容#g" 被替换内容的文件的Path
比如:
sed -i "" "s#ProvisioningStyle = Automatic#ProvisioningStyle = Manual#g" OA/CRM.xcodeproj/project.pbxproj
被替换的旧内容:ProvisioningStyle = Automatic
替换成的内容:ProvisioningStyle = Manual
被替换内容的文件的Path:OA/CRM.xcodeproj/project.pbxproj
AutomaticManual修改完成后

iPhoneConnect: ## Unable to mount developer disk image, (Error Domain=com.apple.dtdevicekit Code=601 "Could not locate device support files." UserInfo={DeviceType=iPhone7,1, NSLocalizedDescription=Could not locate device support files., NSLocalizedRecoverySuggestion=This iPhone 6 Plus is running iOS 12.0 (16A366), which may not be supported by this version of Xcode.}) { DeviceType = "iPhone7,1"; NSLocalizedDescription = "Could not locate device support files."; NSLocalizedRecoverySuggestion = "This iPhone 6 Plus is running iOS 12.0 (16A366), which may not be supported by this version of Xcode."; } Code Signing Error: "CRM" requires a provisioning profile with the Push Notifications feature. Select a provisioning profile for the "Release" build configuration in the project editor.

PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
需要替换为
PROVISIONING_PROFILE = "dc28777c-0cde-4bb2-b9bf-6c6a4c55aa76";
PROVISIONING_PROFILE_SPECIFIER = "Xueersi.WangXiao.CRM(Dis)";
现在跑3.14,3.15. 3.13 正常了,然后到3.12时候又报错

Code Signing Error: Signing for "CRM" requires a development team. Select a development team in the build settings editor that matches the selected profile "Xueersi.WangXiao.CRM(Dis)".

明显是没有development team
经过检查
DEVELOPMENT_TEAM = ""需要替换为DEVELOPMENT_TEAM = 6BUND8EFF7
DevelopmentTeam = 246724P5ZQ;需要替换为DevelopmentTeam = 6BUND8EFF7;
PRODUCT_BUNDLE_IDENTIFIER = com.Xueersi.CRM022;>>PRODUCT_BUNDLE_IDENTIFIER = com.Xueersi.CRM;

上一篇 下一篇

猜你喜欢

热点阅读