Xcode 从命令行构建应用程序到 ipa
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8532750/
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
Xcode building application to ipa from command line
提问by Ertai
I'm unable to build ipa signed file from command line. First a few words about my environment:
我无法从命令行构建 ipa 签名文件。首先是关于我的环境的几句话:
1. ApplicationI've prepared a simple application for iPad from template "Master-Detail Application". Changed nothing in code, changed nothing in settings. Just plain new project.
1. 应用程序我已经从模板“主从应用程序”为 iPad 准备了一个简单的应用程序。代码中没有任何更改,设置中没有任何更改。只是普通的新项目。
2. Build scriptHere is my build "script"
2. 构建脚本这是我的构建“脚本”
cd /Users/admin/Desktop/signtest/signtest/
xcodebuild -target signtest -configuration Debug -sdk iphonesimulator4.3 clean build
/usr/bin/xcrun -sdk iphoneos PackageApplication -v /Users/admin/Desktop/signtest/signtest/build/Debug-iphonesimulator/signtest.app -o /Users/admin/Desktop/binaries/signtest.ipa --sign "iPhone Developer: Marcin Zyga (CLJR93MXJ6)" --embed "/Users/admin/Library/MobileDevice/Provisioning\ Profiles/94D99766-0268-4E0E-B8D1-053063BB2DA1.mobileprovision"
3. Problem
3. 问题
Application is builded, and then I'm trying to make an ipa file from the build. But I've got this:
应用程序已构建,然后我试图从构建中制作一个 ipa 文件。但我有这个:
** BUILD SUCCEEDED **
Packaging application: '/Users/admin/Desktop/signtest/signtest/build/Debug-iphonesimulator/signtest.app'
Arguments: embed=/Users/admin/Library/MobileDevice/Provisioning\ Profiles/94D99766-0268-4E0E-B8D1-053063BB2DA1.mobileprovision verbose=1 output=/Users/admin/Desktop/binaries/signtest.ipa sign=iPhone Developer: Marcin Zyga (CLJR93MXJ6)
Environment variables:
HOME = /Users/admin
SUDO_GID = 20
DISPLAY = /tmp/launch-vj2zx7/org.x:0
VERSIONER_PERL_PREFER_32_BIT = no
MAIL = /var/mail/root
SSH_AUTH_SOCK = /tmp/launch-YPyQMl/Listeners
PWD = /Users/admin/Desktop/signtest/signtest
LANG = pl_PL.UTF-8
USER = root
LOGNAME = root
__CF_USER_TEXT_ENCODING = 0x0:29:42
USERNAME = root
SHLVL = 1
OLDPWD = /SMT/ci_shell_scripts
_ = /usr/bin/xcrun
PATH = /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
LSCOLORS = GxFxCxDxBxegedabagaced
SUDO_USER = admin
SHELL = /bin/bash
TERM = xterm-256color
SUDO_COMMAND = ./sign_test_ipa.sh
VERSIONER_PERL_VERSION = 5.12
SUDO_UID = 502
Output directory: '/Users/admin/Desktop/binaries/signtest.ipa'
Temporary Directory: '/tmp/eiJTk08At3' (will NOT be deleted on exit when verbose set)
+ /bin/cp -Rp /Users/admin/Desktop/signtest/signtest/build/Debug-iphonesimulator/signtest.app /tmp/eiJTk08At3/Payload
Program /bin/cp returned 0 : []
### Checking original app
+ /usr/bin/codesign --verify -vvvv /Users/admin/Desktop/signtest/signtest/build/Debug-iphonesimulator/signtest.app
Program /usr/bin/codesign returned 1 : [/Users/admin/Desktop/signtest/signtest/build/Debug-iphonesimulator/signtest.app: object file format unrecognized, invalid, or unsuitable
]
error: Codesign check fails : /Users/admin/Desktop/signtest/signtest/build/Debug-iphonesimulator/signtest.app: object file format unrecognized, invalid, or unsuitable
The important part is here:
重要的部分在这里:
Program /usr/bin/codesign returned 1 : [/Users/admin/Desktop/signtest/signtest/build/Debug-iphonesimulator/signtest.app: object file format unrecognized, invalid, or unsuitable
]
error: Codesign check fails : /Users/admin/Desktop/signtest/signtest/build/Debug-iphonesimulator/signtest.app: object file format unrecognized, invalid, or unsuitable
I'm unable to find solution.
我无法找到解决方案。
4. What I've already doneHere is a list of what I've already tried to do. However if you are sure that things that I've already tried is solution for my problem please write step by step how to do this (maybe I've done something wrong earlier).
4. 我已经做过的事情以下是我已经尝试过的事情的列表。但是,如果您确定我已经尝试过的事情可以解决我的问题,请逐步写下如何执行此操作(也许我之前做错了什么)。
- That codesign returned 1 (object ifile format invalid or unsuitable) problem again- added propsed line of code, no effect at all
- Xcode - Sharing app - PackageApplication failed with exit code 1- setted in build settings Code Signing Resource Rules Path to $(SDKROOT)/ResourceRules.plist
iPhone Codesign object file format invalid or unsuitable- invoke commands
sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin
- 该协同设计再次返回 1(对象 ifile 格式无效或不合适)问题- 添加了推荐的代码行,根本没有效果
- Xcode - 共享应用程序 - PackageApplication 失败,退出代码为 1- 在构建设置代码签名资源规则路径到 $(SDKROOT)/ResourceRules.plist 中设置
iPhone Codesign 对象文件格式无效或不合适- 调用命令
sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin
5. What I'm trying to achiveI'm trying to generate an ipa file signed with developer certificate so I can upload ipa file via iTunes to test it on device.
5. 我想要达到的目标我正在尝试生成一个使用开发者证书签名的 ipa 文件,以便我可以通过 iTunes 上传 ipa 文件以在设备上对其进行测试。
6. Response to answers from below
6. 对以下回答的回应
I've changed the build command line to:
xcodebuild -target signtest -configuration Debug -sdk iphoneos clean build
我已将构建命令行更改为:
xcodebuild -target signtest -configuration Debug -sdk iphoneos clean build
But now I'm getting:
但现在我得到:
=== BUILD NATIVE TARGET signtest OF PROJECT signtest WITH CONFIGURATION Debug ===
Check dependencies
[BEROR]Code Sign error: Provisioning profile '94D99766-0268-4E0E-B8D1-053063BB2DA1' can't be found
** BUILD FAILED **
I've manually setted provisioning profiles in xcode for this project. I've double checked and they are there. What I'm a doing wrong here? Moreover when I'm building with attached device it all goes fine and application start on my iPad.
我已经在 xcode 中为这个项目手动设置了配置文件。我已经仔细检查过,他们在那里。我在这里做错了什么?此外,当我使用附加设备进行构建时,一切正常,应用程序在我的 iPad 上启动。
采纳答案by Jim
You're selecting the iPhone Simulator SDK in your build script. Switch it to the real SDK.
您正在构建脚本中选择 iPhone Simulator SDK。切换到真正的SDK。