iPhone Codesign object file format invalid or unsuitable

依然范特西╮ 提交于 2019-12-17 04:21:29

问题


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
Connad /usr/bin/codesign failed with exit code 1

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


回答1:


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



回答2:


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

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



回答3:


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




回答4:


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.




回答5:


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.




回答6:


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!




回答7:


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!




回答8:


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



回答9:


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




回答10:


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"




回答11:


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/




回答12:


  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.




回答13:


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.




回答14:


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.




回答15:


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




回答16:


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)




回答17:


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.



来源:https://stackoverflow.com/questions/4842717/iphone-codesign-object-file-format-invalid-or-unsuitable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!