赞
踩
xcrun 命令打包:
1,清理:
/usr/bin/xcodebuild -target targetName clean
2,编译:
/usr/bin/xcodebuild -target targetName
3,第三步打包:
/usr/bin/xcrun -sdk iphoneos PackageApplication -v path/xxx.app -o ./xxx.ipa
说明:
xcodebuild负责将工程源文件编译成xxx.app
xcrun负责给xxx.app(签名并)打包成xxx.ipa
关于xcrun,直接打包的参数就是 xcrun -sdk iphoneos PackageApplication -v 源app路径 -o 输出的ipa路径,以上两个命令必需在xxx.xcodeproj所在的目录执行。
下面两个命令都可以为应用签名:
xcodebuild -target targetName CODE_SIGN_IDENTITY="iPhone Distribution:XXXXXX"
xcrun -sdk iphoneos PackageApplication -v 源app路径 -o 输出的ipa路径 --sign "iPhone Distribution:XXXXXX"
证书与描述文件放在build.xcconfig时配置运行:
xcodebuild -configuration Debug clean build -xcconfig path/build.xcconfig
CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist
CODE_SIGN_IDENTITY = iPhone Developer:xxxx
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer: xxx
PROVISIONING_PROFIEL =xxx.mobileprovision
PROVISIONING_PROFIEL[sdk=iphoneos*]=xxx.mobileprovision
SYMROOT =/Users/iosTest/xxx
OBJROOT =/Users/iosTest/xxx
Click on your project > Targets > Select your target > Build Settings >Code Signing Resource Rules Path
and add :
$(SDKROOT)/ResourceRules.plist
#sh:
echo 'CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist' >> ./build.xcconfig
# !/bin/bash
#
# Sample:
# sh resign.sh 80000.ipa "iPhone Developer: Jsz autotest (xxoo)" Dev_xxoo_iphone.mobileprovision "com.xxoo.iphone" "7766"
#
ORIGINAL_FILE="$1"
CERTIFICATE="$2"
MOBILEPROVISION="$3"
BUNDLE_ID="$4"
PASSWD="$5"
function unzip_IPA()
{
ipa="$ORIGINAL_FILE"
unzip -o "$ipa"
}
function create_EntitlementsPlist()
{
/usr/libexec/PlistBuddy -x -c "print :Entitlements " /dev/stdin <<< $(security cms -D -i ${MOBILEPROVISION}) > entitlements.plist
SN_CODE=$(/usr/libexec/PlistBuddy -c "Print :com.apple.developer.team-identifier" entitlements.plist)
/usr/libexec/PlistBuddy -c "Set :application-identifier ${SN_CODE}.${BUNDLE_ID}" entitlements.plist
}
function set_BundleID()
{
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_ID" Payload/*.app/Info.plist
}
function del_OldCodeSign()
{
rm -r Payload/*.app/_CodeSignature/
}
function copy_EmbeddedProvision()
{
cp $MOBILEPROVISION Payload/*.app/embedded.mobileprovision
}
function reSignFrameworks()
{
echo "Resigning with certificate: $CERTIFICATE" >&2
find −name"∗.app"−o−name"∗.appex"−o−name"∗.framework"−o−name"∗.dylib" > directories.txt
while IFS='' read -r line || [[ -n "$line" ]]; do
/usr/bin/codesign --continue -f -s "$CERTIFICATE" --no-strict "t_entitlements.plist" "$line"
done < directories.txt
}
function reSign()
{
codesign -f -s "$CERTIFICATE" --entitlements entitlements.plist Payload/*.app/
}
function rezip_IPA()
{
original_IPA=`basename "$ORIGINAL_FILE"`
re_IPA=`echo ${original_IPA/.ipa/-resigned.ipa}`
zip -qr "$re_IPA" Payload/
}
security unlock-keychain -p "$PASSWD" ~/Library/Keychains/login.keychain
unzip_IPA
create_EntitlementsPlist
set_BundleID
del_OldCodeSign
copy_EmbeddedProvision
reSignFrameworks
reSign
rezip_IPA
“持续集成”配置参考链接:
http://blog.devtang.com/blog/2012/02/16/apply-daily-build-in-ios-project/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。