当前位置:   article > 正文

IOS 打包、安装、重签名 .app & .ipa_code_sign_identity[sdk=iphoneos*

code_sign_identity[sdk=iphoneos*

打包与签名方法

  • Xcode 工具可以直接打包,不累赘;
  • 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"
  • 1
  • 2

证书与描述文件放在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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

常见error:

.app/ResourceRules.plist: cannot read resources

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

安装 .ipa||.app 方法

  • Xcode 、iTunes、助手等工具不累赘
  • ideviceinstaller:
    $ideviceinstaller -u 076dbbea77c1 -i xx.app/ || XX.ipa
  • fruitstrap(appium包支持):
    fruitstrap install –id userid –bundle “/Users/shop.app”

.ipa 重签名方法

  1. ORIGINAL_FILE=”$1” 待签名的ipa包
  2. CERTIFICATE=”$2” 证书名称
  3. MOBILEPROVISION=”$3” 对应的描述文件
  4. BUNDLE_ID=”$4” app的BundleID, 如果你的描述文件允许你修改任意BundleID那么可以任意填写,否则就老老实实的把原BundleID写上吧
  5. PASSWD=”$5” 当前用户所对于的密码
# !/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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69

“持续集成”配置参考链接:
http://blog.devtang.com/blog/2012/02/16/apply-daily-build-in-ios-project/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/314478
推荐阅读
相关标签
  

闽ICP备14008679号