Ios – Xcode building application to ipa from command line

buildingcontinuous integrationiosxcode

I'm unable to build ipa signed file from command line. First a few words about my environment:

1. Application
I've prepared a simple application for iPad from template "Master-Detail Application". Changed nothing in code, changed nothing in settings. Just plain new project.

2. Build script
Here is my build "script"

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

Application is builded, and then I'm trying to make an ipa file from the build. But I've got this:

** 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 done
Here 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).

5. What I'm trying to achive
I'm trying to generate an ipa file signed with developer certificate so I can upload ipa file via iTunes to test it on device.

6. Response to answers from below

  • I've changed the build command line to:

    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.

Best Answer

You're selecting the iPhone Simulator SDK in your build script. Switch it to the real SDK.

Related Topic