我叫 Luca,目前正在从事 iOS 持续集成工作,以使用 shell 脚本在 xcode 中构建用于分发的应用程序(Ad Hoc 和 App Store)。
到目前为止,我使用 IPA 文件取得了良好的效果。我的问题是在 App Store 中分发。要从脚本构建 .app(传递一些参数),我这样做:
xcodebuild -scheme myScheme -configuration myConfiguration PRODUCT_NAME=myProductName TARGETED_DEVICE_FAMILY=myTargetedDeviceFamily .... etc
由于使用 XCode 4.2,应用程序提交是使用 XCode Organizer 窗口完成的,我还必须能够存档我的可执行文件。
因此,我将前面的命令行修改如下:
xcodebuild -scheme myScheme -configuration myConfiguration PRODUCT_NAME=myProductName TARGETED_DEVICE_FAMILY=myTargetedDeviceFamily .... etc **archive**
不幸的是,在我这样做之后,似乎“archive”参数强制 xcodebuild 忽略其他命令行(Product_NAME、TARGETED_DEVICE_FAMILY,...),并且我的输出是使用 XCode 预定义构建的构建设置。
我希望能够使用 xcodebuild 传递参数并使其有效,但“存档”操作似乎阻止了这一点。
我快疯了,请帮忙:)
谢谢
My name is Luca and I am currently working on iOS continuous integration to build apps in xcode for distribution (Ad Hoc and App Store) using shell-scripting.
So far I achieved good results with IPA files. My problem comes for distribution in App Store. To build a .app from script (passing some arguments) I do:
xcodebuild -scheme myScheme -configuration myConfiguration PRODUCT_NAME=myProductName TARGETED_DEVICE_FAMILY=myTargetedDeviceFamily .... etc
Since with XCode 4.2, apps submission is done using the XCode Organizer Window I must be able also to archive my executable.
Therefore I modify the previous command line as follow:
xcodebuild -scheme myScheme -configuration myConfiguration PRODUCT_NAME=myProductName TARGETED_DEVICE_FAMILY=myTargetedDeviceFamily .... etc **archive**
Unfortunately after I do so, it seems that the 'archive' argument force xcodebuild to ignore the other ones (PRODUCT_NAME, TARGETED_DEVICE_FAMILY, ....) and my output is built using the XCode predefined build settings.
I want to be able to pass the arguments with xcodebuild and be effective, but the 'archive' action seems to prevent this.
I am going nuts, please help :)
Thanks
发布评论
评论(3)
xcodebuild 的归档操作似乎在 Xcode 4.2 中存在错误。通常,可以将项目配置的覆盖指定为命令行参数或通过
-xcconfig
参数。尽管构建操作尊重它们,归档却没有。 (大概这是因为存档是一个元操作,它在内部调用构建,但不会将选项传递给内部调用。)有一个 OpenRadar bug 描述了此问题,因此大概已向 Apple 报告。
最后,请注意,如果您要使用脚本中的归档操作,则不能依赖 xcodebuild 的退出代码。归档操作始终生成退出代码 0(按照惯例,成功)。要检测构建失败,您需要抓取输出。
The archive action for xcodebuild seems to have a bug in Xcode 4.2. Normally overrides for the project configuration can be specified as either command-line parameters or via the
-xcconfig
parameter.Although the build action honors them, archive does not. (Presumably this is because archive is a meta-action that invokes build internally, but doesn't pass-through the options to the internal invocation.) There is an OpenRadar bug that describes this issue, so presumably it's been reported to Apple.
Finally, note that if you're going to use the archive action from a script then you can't rely on the exit code from xcodebuild. The archive action always yields an exit code of 0 (success, by convention). To detect build failure you need to scrape the output.
我遇到了同样的问题。我当前的解决方法基本上是删除其他配置,因此存档被迫使用您想要的配置。这并不是一个可以通过命令行完成的解决方案,希望苹果能够解决这个明显的问题。
I've ran into this same issue. My current work-around is basically to delete the other configurations so archive is forced to use the one you want. Not really a solution that can be done via command-line, hopefully Apple will fix this glaring issue.
这对于原始海报来说可能为时已晚,但可能对其他人有帮助。对于我的构建过程,我使用 xcodebuild 首先清理,然后构建,然后使用 xcrun 创建存档:
使用此命令,我可以为应用程序商店创建存档,甚至可以将临时构建上传到 TestFlight,例如这:
这从 Xcode 6.1 开始工作
this may be too late for the original poster, but may help others. for my build process, i use xcodebuild to with first clean and then build, then i use xcrun to create the archive:
with this command, i can create an archive for the app store, or even upload an ad-hoc build to TestFlight like this:
this works as of xcode 6.1