使用Xcode7的命令行打出ios9的ipa

作者:Wupei  |  发表时间:  |  所属分类:未分类

在ios9发布以后,上线的游戏项目不知道什么原因闪退,但是使用xcode7安装ios9真机设备一切正常,只有重新打包,遇见很多坑。

现记录打包过程如下:

  1. OS X Yosemite 10.10.5
  2. Xcode 7.0(7A220)

一. 项目配置修改:

1. Target -> General -> 勾选 Requires full screen

0A1955F9-138A-4BDD-BB7B-FE1282B48BE4

不勾选的话会出现,项目提交审核会出现 ITMS-90474 和 ITMS-90475的错误提示

 

2. Target -> Build Settings -> 设置 Enable Bitcode 为 No

否则会出现编译错误

clang: error: -fembed-bitcode is not supported on versions of iOS prior to 6.0

 

3. 找到准备签名的证书名称,类似:iPhone Distribution: XXXXXX (xxxxx)

由于现在的游戏开发商会找代理商来代理发行游戏,所以自己一般没有appstore帐号密码,代理商会给一套打包用的私钥和证书出来,全部双击导入系统和xcode中后,在 Target -> Build Settings -> Code Signing Identity 中会出现类似 iPhone Distribution 的字样,那个就是你所需要的证书名称

自从 Xcode6 之后,我就没办法只用证书打出ipa了,只有appstore帐号密码才行,所以需要用命令行来打包(当然也有一种方式是用Xcode6 Archive出来以后,再用Xcode5 Organizer 打出ipa,随着Xcode7的发布,这种办法也就很麻烦了)

 

4. 修改 /Applications/Xcode 7.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication 文件

替换以下代码:(不想替换的到这里下载吧:PackageApplication.txt

my @codesign_args = (“/usr/bin/codesign”, “–force”, “–preserve-metadata=identifier,entitlements,resource-rules”,
“–sign”, $opt{sign},
“–resource-rules=$destApp/ResourceRules.plist”);

为:

my @codesign_args;
if (-e ‘$destApp/ResourceRules.plist’) { # If ResourceRules.plist exists, include it in codesign arguments, for backwards compatability
@codesign_args = (“/usr/bin/codesign”, “–force”, “–preserve-metadata=identifier,entitlements,resource-rules”,
“–sign”, $opt{sign},
“–resource-rules=$destApp/ResourceRules.plist”);
} else { # If ResourceRules.plist isn’t found, don’t include it in the codesign arguments
@codesign_args = (“/usr/bin/codesign”, “–force”, “–preserve-metadata=identifier,entitlements”,
“–sign”, $opt{sign});
}

否则打包过程中会出现

Warning: –resource-rules has been deprecated in Mac OS X >= 10.10!
error: /usr/bin/codesign –force –preserve-metadata=identifier,entitlements,resource-rules –sign foo —resource-rules=/path/to/foo/bar.app failed with error 1

的错误

 

二. 现在把所有事项准备完毕,开始打包:

是用命令行打开 Xcode 项目 xx.xcodeproj 所在目录

假设你的:

  1. Target名称是 “myTarget”
  2. Distribution证书是 “iPhone Distribution: XXXX (xxxx)”

依次执行以下命令:

xcodebuild -target “myTarget” clean

xcodebuild -target “myTarget” CODE_SIGN_IDENTITY=”iPhone Distribution: XXXX (xxxx)”

xcrun -sdk iphoneos PackageApplication -v “build/Release-iphoneos/myTarget.app” -o “你的路径/myTarget.ipa” –sign “iPhone Distribution: XXXX (xxxx)”

 

如果编译正常,最终 “你的路径/myTarget.ipa”  就是所打出的ipa

 

参考文章:

  1. IOS行货自动打包 http://www.cnblogs.com/yesun/archive/2013/08/16/3261839.html
  2. Fixing your iOS build scripts  http://www.jayway.com/2015/05/21/fixing-your-ios-build-scripts/

 

 

标签:, , ,

Trackback from your site.

请在这里留言: