38

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?

4

17 回答 17

78

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
于 2011-07-21T00:01:59.577 回答
52

在 Mountain Lion 中,您可以尝试在codedesign之前运行它:

export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"
于 2012-07-30T14:48:30.950 回答
42

确保目标 info.plist 中的“可执行名称”(CFBundleExecutable) 条目与目标设置中指定的“产品名称”匹配。

于 2011-05-11T03:08:53.447 回答
10

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

于 2012-07-30T17:40:21.087 回答
7

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

解决方案只是转到首选项/下载并安装最新的命令行工具。

于 2012-10-05T09:24:16.227 回答
4

我遇到了同样的问题,并尝试了各种构建设置 GCC4.0、搜索路径等。在我的情况下,结果与构建设置无关,问题是我在目标名称中添加了一个点,即我是以 v3.0 SDK 为目标,因此我将目标称为 Granade3.0。

我开始了一个名为“Grenade3zero”的全新项目,从原始导入源,修复了 appdelegate 名称以匹配项目名称等。构建并运行,它第一次加载到设备上,当我检查时模拟器也很好. 看起来有些字符在目标名称中是非法的!

于 2011-01-30T18:30:46.743 回答
4

以为我也会为这个问题添加我的解决方案......我已经为这个问题苦苦挣扎了几个星期......检查了上面的所有解决方案并进行了更多更改。

我的解决方案是在 target 中build settings

我输入了两个选项,armv6并且armv7. 我把它改回了一个条目,normal它就建好了!

构建设置

于 2011-11-29T10:18:25.723 回答
3

emcmanus 答案对我有用,但由于 Xcode 4.3 现在安装在 Applications 文件夹中,并且我删除了旧的 /Developer 文件夹,因此我不得不更改 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
于 2012-06-28T16:59:58.060 回答
2

我尝试了以上所有方法均无济于事。对我有用的是将以下内容添加到我的构建脚本中:

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

我在研究我的问题时遇到了这篇文章:http: //mobiledevelopertips.com/mac-osx/code-signing-error-object-file-format-unrecognized-invalid-or-unsuitable.html

于 2012-12-21T16:56:33.233 回答
2

在开始签名过程之前,对于 Mountain Lion 请将以下命令作为第一个命令运行。

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

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

于 2013-10-18T11:51:13.337 回答
1

在没有任何命令行实用程序的情况下,在 Mountain Lion 和 Xcode 5.xx 上运行的 Jenkins 遇到了类似的问题。因为命令行实用程序现在与 Xcode 5.1.x 捆绑在一起

以下工作

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

于 2014-05-27T08:14:56.417 回答
1
  1. 转到“构建设置”
  2. 转到“构建选项”选项卡
  3. 在构建选项选项卡中找到“调试信息格式”并将其值从“DWARF”更改为“DWARF with dSYM File”。应该在下拉列表中。

它应该对你们有用。

于 2016-08-29T06:20:18.747 回答
0

最好使用 xcrun 来定位 codesign_allocate 的正确版本,因为它可能会有所不同,具体取决于它是 OS X 二进制文件还是 iOS。

这也允许 Apple 在不破坏脚本的情况下更改各种工具的位置。

使用类似的东西:

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

于 2014-07-15T07:27:06.033 回答
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.

于 2012-02-06T14:23:11.600 回答
0

如果您的应用在目标构建设置中的产品名称中有特殊字符,请将其删除。

例如,将“Mat's app”重命名为“Mats app”,它就会构建。您当然可以在显示名称中包含特殊字符。

于 2011-12-05T17:11:59.873 回答
0

我认为这是由 Xcode DP(开发者预览版)之一引起的。它可以将默认 Xcode.app 路径更改为 Xcode DP。

因此,您可以通过以下方式检查 Xcode 路径xcode-select --print-path

如果你有一些错误的目录,那么你可以改变路径xcode-select --switch

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

于 2013-08-27T09:49:32.943 回答
0

尝试使用我的公司从不同于 Apple 的根证书颁发机构购买的数字证书对我的 OS/X(不是 iOS)应用程序进行签名时,我会收到错误消息。每当我通过 Safari 下载证书时,都会出现此问题。使用 Firefox 下载证书帮助我摆脱了错误。

于 2014-09-05T19:04:27.677 回答