iPhone Codesign对象文件格式无效或不适合。

时间:2022-05-22 08:29:52

I accidentally deleted my target in xcode.

我不小心在xcode中删除了我的目标。

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

所以我创建了一个新的名字。在目标设置中,我再次选择了正确的codesign标识。

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?

我已经尝试过清除目标。什么会导致这个问题以及如何解决它?

17 个解决方案

#1


78  

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

也可能是您安装的问题。与最新的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

#2


52  

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

在Mountain Lion,你可以尝试在codesign之前运行这个:

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

#3


42  

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

确保你的目标信息中的“可执行名称”(CFBundleExecutable)条目。plist匹配在目标设置中指定的“产品名称”。

#4


10  

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.

当我试图从终端进行设计时,我遇到了这个问题。在卸载Xcode 3.0之后,我刚刚安装了Xcode 4.4。查看了Xcode首选项中的下载,并注意到没有安装命令行工具。安装好后,我的问题就解决了。我猜想,考虑到这里的解决方案,问题会更加复杂,但这可能是将来的用户想要检查的东西,在他们开始深入挖掘之前。

#5


7  

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

对我来说,这是在升级到XCode 4.5之后发生的。

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

解决方案就是选择/下载并安装最新的命令行工具。

#6


4  

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.

我有同样的问题,尝试各种各样的构建设置GCC4.0,搜索路径等等。它是与构建设置在我的情况下,问题是我把一个点即在目标的名字。我是针对v3.0 SDK 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!

我开始一个全新的项目命名为“Grenade3zero”,从最初的进口来源,固定在appdelegate名称与项目名称等构建,它第一次加载到设备和模拟器也很好当我检查它。看起来像一些字符目标名称是非法的!

#7


4  

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!

我有两种选择,armv6和armv7。我把它改回到正常的一个入口,它就建好了!

iPhone Codesign对象文件格式无效或不适合。

#8


3  

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:

emcmanus的回答对我来说很有用,但由于Xcode 4.3现在已经安装在应用程序文件夹中,我删除了旧的/Developer文件夹,所以我必须更改codesign_的路径:

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


2  

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"

出口CODESIGN_ALLOCATE = " /应用程序/ xcode /内容/开发/ 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

我在研究我的问题时偶然发现了这篇文章:http://mobiledevelopertips.com/mac-osx/code-signing-error-object-file-format- un- invalid-or-unsuitable.html。

#10


2  

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"

Xcode 4。x:出口CODESIGN_ALLOCATE = " /应用程序/ xcode /内容/开发/ usr / bin / CODESIGN_ALLOCATE”

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

对于XCode 5:导出codesign_= "/ application / XCode .app/Contents/Developer/ toolchain/ XcodeDefault.xctoolchain/usr/bin/ codesign_"

#11


1  

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

在詹金斯在Mountain Lion和Xcode 5.x上运行类似的问题。x没有任何命令行实用程序。因为命令行实用程序现在与Xcode 5.1.x绑定在一起。

the following worked

下面的工作

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

sudo ln - s /应用程序/ xcode /内容/开发/工具链/ XcodeDefault。xctoolchain / usr / bin / codesign_allocate /usr/bin/

#12


1  

  1. Go to 'Build Settings'
  2. 去“建立设置”
  3. Go to 'Build Options' tab
  4. 转到“构建选项”选项卡。
  5. 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.
  6. 在build options选项卡内找到“调试信息格式”,并将其值从“DWARF”改为“DWARF with dSYM文件”。应该在下拉菜单。

It should work for you guys.

它应该对你们有用。

#13


0  

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.

例如,将“Mat应用程序”重命名为“Mats应用程序”,它将构建。您当然可以在显示名称中有特殊字符。

#14


0  

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


0  

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

我认为它是由Xcode DP(开发者预览版)引起的。它可以更改默认的Xcode。应用程序路径到Xcode DP。

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

因此,可以通过Xcode -select—printpath来检查Xcode路径。

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

如果你有一个错误的目录,那么U可以通过xcode-select -switch改变路径。

check this thread. change xcrun developer path

检查这个线程。改变xcrun开发路径

#16


0  

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.

最好使用xcrun来定位codesign_的正确版本,因为它可能不同,取决于它是OS X二进制还是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)

导出codesign_deploy =$(xcrun -sdk iphoneos——找到codesign_deploy)

#17


0  

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.

当我试图在我的OS/X(非iOS)应用程序上签名时,我将会得到这个错误,我的公司从一个不同于苹果的根认证机构购买了一个数字证书。当我通过Safari下载证书时,问题就会出现。使用Firefox下载证书帮助我摆脱了错误。

#1


78  

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

也可能是您安装的问题。与最新的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

#2


52  

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

在Mountain Lion,你可以尝试在codesign之前运行这个:

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

#3


42  

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

确保你的目标信息中的“可执行名称”(CFBundleExecutable)条目。plist匹配在目标设置中指定的“产品名称”。

#4


10  

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.

当我试图从终端进行设计时,我遇到了这个问题。在卸载Xcode 3.0之后,我刚刚安装了Xcode 4.4。查看了Xcode首选项中的下载,并注意到没有安装命令行工具。安装好后,我的问题就解决了。我猜想,考虑到这里的解决方案,问题会更加复杂,但这可能是将来的用户想要检查的东西,在他们开始深入挖掘之前。

#5


7  

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

对我来说,这是在升级到XCode 4.5之后发生的。

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

解决方案就是选择/下载并安装最新的命令行工具。

#6


4  

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.

我有同样的问题,尝试各种各样的构建设置GCC4.0,搜索路径等等。它是与构建设置在我的情况下,问题是我把一个点即在目标的名字。我是针对v3.0 SDK 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!

我开始一个全新的项目命名为“Grenade3zero”,从最初的进口来源,固定在appdelegate名称与项目名称等构建,它第一次加载到设备和模拟器也很好当我检查它。看起来像一些字符目标名称是非法的!

#7


4  

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!

我有两种选择,armv6和armv7。我把它改回到正常的一个入口,它就建好了!

iPhone Codesign对象文件格式无效或不适合。

#8


3  

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:

emcmanus的回答对我来说很有用,但由于Xcode 4.3现在已经安装在应用程序文件夹中,我删除了旧的/Developer文件夹,所以我必须更改codesign_的路径:

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


2  

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"

出口CODESIGN_ALLOCATE = " /应用程序/ xcode /内容/开发/ 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

我在研究我的问题时偶然发现了这篇文章:http://mobiledevelopertips.com/mac-osx/code-signing-error-object-file-format- un- invalid-or-unsuitable.html。

#10


2  

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"

Xcode 4。x:出口CODESIGN_ALLOCATE = " /应用程序/ xcode /内容/开发/ usr / bin / CODESIGN_ALLOCATE”

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

对于XCode 5:导出codesign_= "/ application / XCode .app/Contents/Developer/ toolchain/ XcodeDefault.xctoolchain/usr/bin/ codesign_"

#11


1  

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

在詹金斯在Mountain Lion和Xcode 5.x上运行类似的问题。x没有任何命令行实用程序。因为命令行实用程序现在与Xcode 5.1.x绑定在一起。

the following worked

下面的工作

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

sudo ln - s /应用程序/ xcode /内容/开发/工具链/ XcodeDefault。xctoolchain / usr / bin / codesign_allocate /usr/bin/

#12


1  

  1. Go to 'Build Settings'
  2. 去“建立设置”
  3. Go to 'Build Options' tab
  4. 转到“构建选项”选项卡。
  5. 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.
  6. 在build options选项卡内找到“调试信息格式”,并将其值从“DWARF”改为“DWARF with dSYM文件”。应该在下拉菜单。

It should work for you guys.

它应该对你们有用。

#13


0  

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.

例如,将“Mat应用程序”重命名为“Mats应用程序”,它将构建。您当然可以在显示名称中有特殊字符。

#14


0  

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


0  

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

我认为它是由Xcode DP(开发者预览版)引起的。它可以更改默认的Xcode。应用程序路径到Xcode DP。

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

因此,可以通过Xcode -select—printpath来检查Xcode路径。

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

如果你有一个错误的目录,那么U可以通过xcode-select -switch改变路径。

check this thread. change xcrun developer path

检查这个线程。改变xcrun开发路径

#16


0  

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.

最好使用xcrun来定位codesign_的正确版本,因为它可能不同,取决于它是OS X二进制还是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)

导出codesign_deploy =$(xcrun -sdk iphoneos——找到codesign_deploy)

#17


0  

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.

当我试图在我的OS/X(非iOS)应用程序上签名时,我将会得到这个错误,我的公司从一个不同于苹果的根认证机构购买了一个数字证书。当我通过Safari下载证书时,问题就会出现。使用Firefox下载证书帮助我摆脱了错误。