最近在研究越狱下的iOS开发,经过stackOverFlow上大神以及Google的帮助,总算有了个初步的了解,虽然截止到目前还没有完全成功,ldid工具会报错,但是还是把流程记录下来。
stackOverflow上的帖子在这里:http://stackoverflow.com/questions/12768109/how-to-use-ldid
帖子的提问者先讲了一个大致的步骤:
-
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的签名,然后build一个没有签名的APP。好了,来看另一篇文章,很详细地讲解了如何取消XCode的签名然后build一个app文件出来 。
Step 1:
GoTo /Applications then right click Xcode.app and click "Show Package Contents"
在“应用程序”中找到Xcode,然后右键,选择“显示包内容”
Copy this modified SDKSettings.plist file back to
To make an IPA:
右键拖进来的这个app,选择show in Finder,会看到一个.ipa的文件
Important Notes :
1. In Step 8, if the Archive menu is disabled this is most likely because the a simulator option is currently selected as the run target in the Xcode toolbar. Changing this menu either to a connected device, or the generic iOS Device target option should enable the Archive option in Product menu.2. You will also need to install AppSync in your iPhone via Cydia.
上面的步骤都执行完之后,其实我们就完成了
-
Disable code signing in XCode.
-
Built unsigned iPhone app.
按照我的理解,我们可以在Mac OX上或者在iPhone里面利用ldid工具进行签名,这两个地方都是可行的。
在iPhone上使用ldid工具比较简单,去cydia里面搜索ldid,会出来两个插件,第一个Link Identity Editor就是我们要用的ldid,然后安装了之后,在终端上SSH进去你越狱后的iPhone(同样需要在cydia里面安装openSSH插件),命令行是
ssh root@xxx.xxx.xxx.xxxxxx表示IP地址,关于如何SSH就不在这里介绍了,google一下有很多文章介绍,可以在wifi或者通过数据线连接进入
然后把之前得到的app文件夹拖到一个目录下面,cd到这个目录下,然后执行
ldid -S projectname
这个命令,如果顺利的话,签名就完成了,不幸的是,我总会得到这样的错误提示:
_assert(false); errno=2
或者在Mac OX上执行签名
首先需要下载ldid文件, https://github.com/downloads/rpetrich/ldid/ldid.zip
不太确定这个是不是最新的ldid文件,因为有的ldid不能签名fat project(关于这个过会儿再讨论)
然后把它放到/usr/bin路径下,如果找不到这个路径,直接在终端里面输入 open /usr/bin 就可以了
然后执行
chmod -R 777 ldid
关于这个命令上篇文章已经介绍过了,这里就不再重复说明。
接下来就可以使用ldid给之前拖到桌面的app文件签名了,命令同样是 -S+projectname
但是目前我仍然没法正常使用这个命令。
回到之前在stackOverFlow上的那个问题,最佳答案里面提到了fat project的概念,
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 fat binaries (but see Update below). 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
.
In the project build settings, use the Architectures, Valid Architectures and Build Active Architecture Only settings to determine which architecture executable is built. For jailbreak development, I usually setBuild Active Architecture Only to YES
. And valid archictures set to armv6
and 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 before you upload to your 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 Architectures to only armv6
, 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.
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.
但是不知道ldid是不是能够支持fat的程序。
关于越狱的东西我会继续搞,如果有进展会再做记录。如果有网友知道如何解决ldid命令失败的原因,请指教,谢谢!