xcode 如何使用ldid?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12768109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use ldid?
提问by Vitalii
I am trying to run unsigned application on iOS 5.1/iPhone 4s (jailbroken). What I did:
我正在尝试在 iOS 5.1/iPhone 4s(越狱)上运行未签名的应用程序。我做了什么:
Disable code signing in XCode.
Built unsigned iPhone app.
Copied it to my iPhone via SSH to location /User/me/development/HelloWorld.app
Now I try to simulate its signing to run this application on iPhone. I run follwing commands:
在 XCode 中禁用代码签名。
内置未签名的 iPhone 应用程序。
通过 SSH 将它复制到我的 iPhone 到位置 /User/me/development/HelloWorld.app
现在我尝试模拟它的签名以在 iPhone 上运行这个应用程序。我运行以下命令:
.
.
cd /User/me/development
chmod -R 777 HelloWorld.app
ldid -S HelloWorld
However, I receive following error:
但是,我收到以下错误:
util/ldid.cpp(567): _assert(78:arch != NULL)
What are possible reason of such error and now to fix it?
这种错误的可能原因是什么,现在要解决它?
回答by Nate
1)Using ldid -S
is the correctusage. Not lowercase (-s
).
1)使用ldid -S
是正确的用法。不是小写 ( -s
)。
2)Usually, when I get this error, it's because I built my app with the wrong architectures. Most older versions of ldid
that I've used cannot sign fatbinaries (but see Updatebelow). Fat binaries are ones with more than one architecture inside. For example, a dual armv6
and armv7
executable. Or with Xcode 4.5, it's probably defaulting to arvm7
and armv7s
.
2)通常,当我收到此错误时,是因为我使用错误的架构构建了我的应用程序。ldid
我使用过的大多数旧版本都不能对胖二进制文件进行签名(但请参阅下面的更新)。胖二进制文件是包含多个架构的二进制文件。例如,双重armv6
和armv7
可执行文件。或者使用 Xcode 4.5,它可能默认为arvm7
和armv7s
。
In the project build settings, use the Architectures, Valid Architecturesand Build Active Architecture Onlysettings to determine which architecture executable is built. For jailbreak development, I usually set Build Active Architecture Onlyto YES
. And valid archictures set to armv6
and armv7
.
在项目构建设置中,使用Architectures、 Valid Architectures和Build Active Architecture Only设置来确定构建了哪个体系结构可执行文件。对于越狱开发,我通常将Build Active Architecture Only设置为YES
. 并且有效架构设置为armv6
和armv7
。
3)Also, some older versions of ldid
cannot sign armv7
executables. If you get the pre-built copy from KennyTM's site here, it supports armv7
. Note that this ldid
is built for Mac OS X, so it's designed to be run on the executable on your Mac, after building without signing in Xcode, but beforeyou upload to your iPhone.
3)此外,一些旧版本的ldid
无法签署armv7
可执行文件。如果您从此处的 KennyTM 站点获得预构建副本,则它支持armv7
. 请注意,这ldid
是为 Mac OS X 构建的,因此它旨在在您的 Mac 上的可执行文件上运行,在没有登录 Xcode 的情况下构建之后,但在您上传到您的 iPhone 之前。
Newer phones can generally run executables built for older architectures, but not the other way around. So, build for the oldest architecture you want to support. You just will lose some optimizations in the newer architectures (which most people don't care too much about ... let me know if your app needs these optimizations, and I'll post more).
较新的手机通常可以运行为旧架构构建的可执行文件,但反过来不行。因此,为您想要支持的最古老的架构构建。你只会在较新的架构中失去一些优化(大多数人不太关心......让我知道你的应用程序是否需要这些优化,我会发布更多)。
So, if you want to support old devices (iPhone < 3GS), I would set Architecturesto onlyarmv6
, making sure to remove the default setting of $(ARCHS_STANDARD_32_BIT)
. If you only need support for relatively new ones, then pick armv7
, but make sure you use a version of ldid
that can sign armv7
binaries.
因此,如果您想支持旧设备(iPhone < 3GS),我会将Architectures设置为onlyarmv6
,确保删除$(ARCHS_STANDARD_32_BIT)
. 如果您只需要对相对较新的支持,请选择armv7
,但请确保您使用的版本ldid
可以对armv7
二进制文件进行签名。
Edit:to determine if the executable you were trying to sign was a fat one, run this at the command line:
编辑:要确定您尝试签名的可执行文件是否为胖可执行文件,请在命令行中运行:
> cd HelloJB.app
> ls
HelloJB Info.plist PkgInfo date.zip en.lproj
> lipo -info HelloJB
Non-fat file: HelloJB is architecture: armv7
As you can see in the above output, my HelloJB
executable is not fat, and only has armv7 code.
正如你在上面的输出中看到的,我的HelloJB
可执行文件并不胖,只有 armv7 代码。
Update
更新
I believe that the pre-built version of ldid found herecannow sign fat executables, although there are still ldid
versions floating around that cannot. Also, I think that if you install a recent version of iOSOpenDev, it will give you a version of ldid
that can sign fat executables (default install location of /opt/iOSOpenDev/bin/ldid
).
我相信这里找到的ldid的预构建版本现在可以签署胖可执行文件,尽管仍有一些ldid
版本不能。另外,我认为如果您安装最新版本的iOSOpenDev,它将为您提供一个ldid
可以签署胖可执行文件的版本(默认安装位置为/opt/iOSOpenDev/bin/ldid
)。
回答by Omar
Starting from what seems Xcode 4.5 onward, maybe as early as 4.4 have not checked, in order to pseudo code sign using the ldid tool, you need to download and install 'Command Line Tools' from hereor you can download it from within Xcode, Preferences->Downloads
从 Xcode 4.5 开始,可能早在 4.4 就没有检查过,为了使用 ldid 工具进行伪代码签名,您需要从这里下载并安装“命令行工具”,或者您可以从 Xcode 中下载它,首选项->下载
Otherwise you will get errors like
否则你会得到类似的错误
- util/ldid.cpp(584):
- ./minimal/mapping.h(54): _assert(2:false)
- util/ldid.cpp(567)
- and so on
- util/ldid.cpp(584):
- ./minimal/mapping.h(54): _assert(2:false)
- util/ldid.cpp(567)
- 等等
You still need to make sure it is not a "fat" binary and only armv7 as armv6 is no longer supported.
您仍然需要确保它不是“胖”二进制文件,并且只有 armv7,因为 armv6 不再受支持。
ldid -S ExampleApp
ldid -S ExampleApp
回答by Urs Koster
The error assert(2:false) comes from the fact that HelloJB (not HelloJB.app) is write protected!
错误 assert(2:false) 来自于 HelloJB(不是 HelloJB.app)被写保护的事实!
- Start Terminal.app
- Go to directory HelloJB.app
- chmod +aw HelloJB
- ldid -S HelloJB works !
- 启动 Terminal.app
- 转到目录 HelloJB.app
- chmod +aw HelloJB
- ldid -S HelloJB 有效!