开发者

iPhone Codesign object file format invalid or unsuitable

开发者 https://www.devze.com 2023-02-07 06:44 出处:网络
I accidentally deleted my target in xcode. so i created a new one with the exact same name. in the target settings i again selected the proper codesigning identity

I accidentally deleted my target in xcode.

so i created a new one with the exact same name. in the target settings i again selected the proper codesigning identity

but now i can't compile for the device anymore. as soon as i want to build, i get:

CodeSign build/Release-iphoneos/myApp.app
....somestuff....
/Volumes/XCodeProj/myApp/build/Release-iphoneos/myApp.app: object file format invalid or unsuitable
C开发者_StackOverflow中文版onnad /usr/bin/codesign failed with exit code 1

I already tried to clean targets. what could cause this problem and how to solve it?


May also be an issue with your install. Symlinking to the latest codesign_allocate cleared up the issue in my case:

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


In Mountain Lion, you can try to run this before codesign:

export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"


Make sure the 'Executable Name' (CFBundleExecutable) entry in your target's info.plist matches the 'Product Name' specified in your target settings.


I had this issue when I was trying to codesign from the terminal. I had just installed Xcode 4.4 after uninstalling Xcode 3.0. Took a look at the Downloads in Xcode preferences and noticed that the Command Line Tools had not been installed. My issue was fixed after I installed this. I'm guessing the problem is more complex given the solutions here, but this might be something that future users want to check before they have to start diving deeper.


For me, this was occurring after upgrading to XCode 4.5.

The solution was simply to go to Preferences / Downloads and install the latest Command Line Tools.


I had the same problem and tried all sorts of build settings GCC4.0, search paths etc etc. It turned out to be nothing to do with the build settings in my case the problem was I put a dot in the target name i.e. I was targeting v3.0 SDK so I called the target Granade3.0.

I started a brand new project named "Grenade3zero", imported the sources from the original, fixed the appdelegate name to match the project name etc. build and go and it loaded first time onto the device and the simulator was also fine when I checked it. Looks like some characters are illegal in target names!


Thought I'd add my solution to this problem too... I've been struggling for a couple of weeks with this problem... having checked ALL the solutions above and changing more.

My solution was in the target build settings.

I had put in two options, armv6 and armv7. I changed this back to one single entry of normal and it built!

iPhone Codesign object file format invalid or unsuitable


emcmanus answer worked for me but since Xcode 4.3 is now installed in the Applications folder and I removed the old /Developer folder, I had to change the path to codesign_allocate:

sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin


I tried all the above to no avail. What worked for me was to add the following to my build script:

export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"

I came across this post while researching my problem: http://mobiledevelopertips.com/mac-osx/code-signing-error-object-file-format-unrecognized-invalid-or-unsuitable.html


For Mountain Lion before starting signing process Please run below command as first command.

For Xcode 4.x: export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"

For XCode 5: export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate"


Faced a similar issue in Jenkins running on Mountain Lion and Xcode 5.x.x without any command line utilities. since the command line utilities are now bundled with Xcode 5.1.x

the following worked

sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate /usr/bin/


  1. Go to 'Build Settings'
  2. Go to 'Build Options' tab
  3. Inside of the build options tab go find 'Debug Information Format' and change it's value from 'DWARF' to 'DWARF with dSYM File'. Should be in the dropdown.

It should work for you guys.


If your app has special characters in the Product Name in the target build settings, remove them.

For example, rename "Mat's app" to "Mats app" and it will build. You can of course have special characters in the display name.


I also had the same problem, and the cause was that my app target was linked to a static library and didn't provide its own source files (all sources were in the library and the app target only provided resources). Once I moved out one of the sources from the library to the app target, it fixed the code sign error.


I think that it was cause by one of Xcode DP(developer preview). It could change default Xcode.app Path to Xcode DP.

So, U can check Xcode path by xcode-select --print-path

If U got some wrong directory then U could change path by xcode-select --switch

check this thread. change xcrun developer path


It is better to use xcrun to locate the correct version of codesign_allocate as it can be different depending on whether it is an OS X binary or iOS.

This also allows Apple to change the location of various tools without breaking your script.

Use something like:

export CODESIGN_ALLOCATE=$(xcrun --sdk iphoneos --find codesign_allocate)


I would get the error when trying to sign my OS/X (not iOS) application with a digital certificate my company purchased from a root Certification Authority different from Apple. The problem would occur whenever I downloaded the certificate via Safari. Downloading the certificate using Firefox helped me get rid of the error.

0

精彩评论

暂无评论...
验证码 换一张
取 消