xcode 无法为 Cordova iOS App 生成发布版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19814092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't generate release build for Cordova iOS App
提问by Aarush
I am using Phonegap CLI 3.1and XCode5. I want to generate the release build for iPhone Application through command line, I have valid distribution certificateand mobile provisioning profile. I want to generate the release build totally through command and don't want to use XCode GUI or Phonegap Build. I have tried too much with xcodebuild, xcrun and even corodva build command but none of them provide me the release build file (either in .app format or .ipa).
我正在使用Phonegap CLI 3.1和XCode5。我想通过命令行为 iPhone 应用程序生成发布版本,我有有效的分发证书和移动配置文件。我想完全通过命令生成发布版本,不想使用 XCode GUI 或 Phonegap Build。我对 xcodebuild、xcrun 甚至 corodva 构建命令尝试了太多,但它们都没有为我提供发布构建文件(.app 格式或 .ipa)。
Method 1 (Use xcodebuild)
方法一(使用xcodebuild)
a) xcodebuild -project MyApp.xcodeproj -alltargets -sdk iphoneos7.0 PROVISIONING_PROFILE="PROFILE_UUID.mobileprovision" -configuration Release
** BUILD FAILED **
The following build commands failed:
** 构建失败 **
以下构建命令失败:
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7 Objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/MainViewController.o MyApp/Classes/MainViewController.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/MainViewController.o MyApp/Classes/MainViewController.m normal armv7 Objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7s/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7s objective-c com.apple.compilers.llvm.clang.1_0.compiler
(3 failures)
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7s/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7s Objective-c com.apple.compilers.llvm.clang.1_0.compiler
( 3次失败)
Method 2 (Use corodova build and xcrun to sign the app)方法二(使用corodova build和xcrun对app进行签名)
a) cordova build ios -release
Compiling app on platform "ios" via command "/Users/Macuser/Desktop/MyApp/platforms/ios/cordova/build" --release Platform "ios" compiled successfully.
通过命令“/Users/Macuser/Desktop/MyApp/platforms/ios/cordova/build”在平台“ios”上编译应用程序——发布平台“ios”编译成功。
b) xcrun -sdk iphoneos PackageApplication -v "build/Release-iphoneos/MyApp.app" -o "build/Release-iphoneos/MyApp.ipa" --sign "iPhone Distribution: NAME (ID)" --embed "PROFILE_UUID.mobileprovision"
error: Failed to read entitlements from '/tmp/iyibGn3aUv/Payload/MyApp.app
error: Failed to read entitlements from '/tmp/iyibGn3aUv/Payload/MyApp.app
采纳答案by coolphon
The problem is that you do not have proper schemes. When phonegap project is generated it does not contain any schemes and thus linking to the phonegap files is incorrect.
问题是你没有合适的方案。生成 phonegap 项目时,它不包含任何方案,因此链接到 phonegap 文件是不正确的。
Go to the phonegap generated project in console and put 'xcodebuild -list' in the output you will get that there is no schemes in the project.
转到控制台中 phonegap 生成的项目,并在输出中放入“ xcodebuild -list”,您会发现项目中没有方案。
Open generated by phonegap project in the xcode - this will generate schemes.
在 xcode 中打开由 phonegap 项目生成的 - 这将生成方案。
Now you can build this using xcodebuild(Remember to fill up the proper scheme name):
现在您可以使用 xcodebuild 构建它(记住填写正确的方案名称):
xcodebuild -scheme YOURSCHEMENAME-project MyApp.xcodeproj -alltargets -sdk iphoneos7.0 PROVISIONING_PROFILE="PROFILE_UUID.mobileprovision" -configuration Release
xcodebuild -scheme YOURSCHEMENAME -projectMyApp.xcodeproj -alltargets -sdk iphoneos7.0 PROVISIONING_PROFILE="PROFILE_UUID.mobileprovision" -configuration Release
For continous integration this is bad solution because you have to launch the xcode GUI to generate the schemes but I did not found any other solution for this problem. If someone know how to generate scheme using command line it would be nice of him to write it down.
对于持续集成,这是一个糟糕的解决方案,因为您必须启动 xcode GUI 来生成方案,但我没有找到针对此问题的任何其他解决方案。如果有人知道如何使用命令行生成方案,那么他最好把它写下来。
回答by Paul
First, you need to create your app in iTunes Connect (This is in the member center of your iOS developer account). If you've already created your profiles and certificates, then you can select the correct one in iTunes Connect. Here is where you name your app, set a price, write a description, and upload screen shots and a large icon. Make sure you fill in all information and upload all images for your app. You will know when you are done the status of your app changes to 'Waiting for Upload".
首先,您需要在 iTunes Connect(这是在您的 iOS 开发者帐户的会员中心)中创建您的应用程序。如果您已经创建了您的配置文件和证书,那么您可以在 iTunes Connect 中选择正确的。您可以在此处为应用命名、设置价格、撰写描述以及上传屏幕截图和大图标。确保为您的应用填写所有信息并上传所有图片。完成后,您将知道应用程序的状态更改为“等待上传”。
After you've created your app successfully in iTunes Connect, to generate an .IPA file for distribution (either for the AppStore or Ad-Hoc) in Xcode you need to select your Project in the file tree (at the top of the tree). Then make sure your 'Targets' is selected to the right.
在 iTunes Connect 中成功创建应用程序后,要在 Xcode 中生成用于分发的 .IPA 文件(用于 AppStore 或 Ad-Hoc),您需要在文件树(在树的顶部)中选择您的项目. 然后确保在右侧选择了“目标”。
Choose 'Build Settings". Then go to the section where is says Code Signing. For 'Release', make sure that the correct iPhone Distribution identity or profile is selected.
选择“构建设置”。然后转到代码签名部分。对于“发布”,请确保选择了正确的 iPhone 分发标识或配置文件。
Below 'Release' it should say 'Any iOS SDK'. Make sure that it says 'IOS Distribution' next to it.
在“发布”下方,它应该显示“任何 iOS SDK”。确保它旁边显示“IOS 分发版”。
If you have the correct certificates and profiles in the keychain, you can now in the menu at the top choose Product > Archive.
如果您在钥匙串中有正确的证书和配置文件,您现在可以在顶部的菜单中选择产品 > 存档。
If it doesn't build, then press the run button to build your project. Xcode should say that it is archiving.
如果它没有构建,则按运行按钮构建您的项目。Xcode 应该说它正在归档。
After it archive's successfully, go to the Organizer. In the menu at the top choose Window > Organizer. Now click Archives.
存档成功后,进入管理器。在顶部的菜单中选择窗口 > 管理器。现在单击存档。
If your project successfully archived you will see it here. First you need to Validate your project with iTunes Connect. You will need to enter your iOS Developer login info. Xcode 5 does a pretty good job of detecting the correct profiles so you should see it in there.
如果您的项目成功存档,您将在此处看到它。首先,您需要使用 iTunes Connect 验证您的项目。您需要输入您的 iOS 开发人员登录信息。Xcode 5 在检测正确的配置文件方面做得很好,所以你应该在那里看到它。
If your app validates then you can then distribute either to the App Store or as an Ad-Hoc distribution. Depending on which profile you have.
如果您的应用程序通过验证,那么您可以将其分发到 App Store 或作为 Ad-Hoc 分发。取决于您拥有的个人资料。
This is the process for distributing apps either Native or Phonegap. It doesn't matter, I've built both.
这是分发 Native 或 Phonegap 应用程序的过程。没关系,我都建了。
I would suggest doing it this way, in case your app doesn't validate. Xcode will then tell you what you need to do to fix. Then once you fix everything. Create a new archive and try until it validates.
我建议这样做,以防您的应用程序未验证。然后 Xcode 会告诉您需要做什么来修复。然后一旦你解决了所有问题。创建一个新的存档并尝试直到它通过验证。