iOS打包常用腳本

解鎖Mac OS

password = "12345"

userName = "jimmy"

/usr/bin/security unlock-keychain -p $password ?/Users/$userName/Library/Keychains/login.keychain


設(shè)置包名版本號

cd ${WORKSPACE}

buildPlist=${WORKSPACE}/Info.plist

bundleId="com.bundleid"

CFBundleVersion=0.0.0

/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" $buildPlist

/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $bundleId" $buildPlist


指定project clean

xcodebuild clean \

-project Unity-iPhone.xcodeproj \

-scheme Unity-iPhone \

-configuration Release


打Archive包

#指定證書,bundle id打包

xcodebuild -archivePath $location \

-project Unity-iPhone.xcodeproj \

-configuration Release \

-scheme Unity-iPhone \

archive \

-sdk iphoneos \

-arch arm64??\

PROVISIONING_PROFILE_SPECIFIER="your_provisiont_profile" \

PRODUCT_BUNDLE_IDENTIFIER="your.bundle.id" \

DEVELOPMENT_TEAM="AXXXXXX4"


No matching provisioning profiles found

明明證書在xcode上配置成功,xcodebuild的時候卻顯示無法找到證書:

error: No profile for team 'asdfasdfasdf' matching 'dev_com_sdf.mobileprovision' found: Xcode couldn't find any provisioning profiles matching 'asdfasdfasdf/dev_com_sdf.mobileprovision'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the Signing & Capabilities tab of the target editor. (in target 'ttt' from project 'ttt')

** ARCHIVE FAILED **

我的打包命令:

xcodebuild archive -project /Users/kingsoft/Desktop/ttt/ttt.xcodeproj \

-scheme ttt \

-configuration Debug \

-archivePath .\

CODE_SIGN_IDENTITY="iPhone Developer: xxx (xxx)" \

PROVISIONING_PROFILE_SPECIFIER=dev_com_sdf.mobileprovision. \

DEVELOPMENT_TEAM="asdfasdfasdf" \

PRODUCT_BUNDLE_IDENTIFIER="com.asdf.asdf"

解決方案是:

CODE_SIGN_IDENTITY不能放到自定義參數(shù)的第一位。

xcodebuild archive -project /Users/kingsoft/Desktop/ttt/ttt.xcodeproj \

-scheme ttt \

-configuration Debug \

-archivePath .\

PROVISIONING_PROFILE_SPECIFIER=dev_com_sdf.mobileprovision. \

DEVELOPMENT_TEAM="asdfasdfasdf" \

CODE_SIGN_IDENTITY="iPhone Developer: xxx (xxx)" \

PRODUCT_BUNDLE_IDENTIFIER="com.asdf.asdf"



UnityFramework 因為CodeSigned引起的問題:


因為在Unity 2019.3.x往后,Unity修改了打包策略,會在xcode導(dǎo)出的工程里面多出一個UnityFramework target,而且是auto signed,這樣就會導(dǎo)致兩個問題:

1.無法導(dǎo)出iPa

2.簽名后的iPa有可能企業(yè)證書無法安裝

解決方式,cd到Unity-iPhone.xcodeproj下

sed -i '' 's/CODE_SIGN_STYLE = Automatic;/ CODE_SIGN_STYLE = Manual;/' project.pbxproj

手動吧unityframework設(shè)為手動簽名

打出ipa

xcodebuild -exportArchive \

-archivePath $your_archive_path \

-exportPath ./ \

-exportOptionsPlist $your_export_plsit.plist PROVISIONING_PROFILE=$your_profile

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容