UPDATE: 中文版在文章后半部分。
About iCosta
iCosta is a dynamic shared library which provides Chinese input facility when it’s loaded before SpringBoard. iCosta achives this through overriding some of the methods in UIKit. Since it’s a dynamic shared library, it may apply to various firmware versions as long as the methods it overrides do not change calling interfaces. The iCosta 1.0.5 initially supports iPhone firmware version 1.1.3, but it’s actually working on 1.1.4 as well, though you can’t install it through Installer because it has version check. This article describes how to install it manually.
Manual Installation
You may get the iCosta installation package from its developers’ site at http://iphone.freecoder.org/iCosta.html. I only use Pinyin so I downloaded iCostaPy_1.1.2.pxl.
NOTICE: The version 1.0.4 has permission issues and slightly leaks memory upon each (UIKit based) application startup, so please download the latest version 1.0.5.
1. Extract package files
Rename the downloaded package filename extension from .pxl to .zip, then unzip it, you’ll get the following files:
PxlPkg.plist README.txt README_cn.txt bin/iCosta.dylib (interposing library) iCostaImages/* (bitmaps for keyboard) icon.png util/iCostaCtl (setup utility)
2. Upload files
Create a folder on iPhone:
/Library/iCosta
This folder holds all the keyboard images. Upload all PNG files (in iCostaImages) to the newly created folder.
Upload the iCosta.dylib to /usr/lib on iPhone.
Upload the iCostaCtl to /usr/bin on iPhone.
In order to ensure all files/folders have correct permissions, enter these commands:
chmod 755 /Library/iCosta chmod 644 /Library/iCosta/* chmod 755 /usr/bin/iCostaCtl chmod 755 /usr/lib/iCosta.dylib
Check if there’s a file called .GlobalPreferences.plist in /var/root/Library/Preferences, if the file is missing, enter the following command in SSH or Term-vt100 to create a symbolic link:
ln -s /var/mobile/Library/Preferences/.GlobalPreferences.plist /var/root/Library/Preferences/.
3. Activate iCosta
Enter this command to activate iCosta:
iCostaCtl -install111
Reboot iPhone and enjoy your new Chinese IME.
Manual Uninstallation
1. Deactivate iCosta
Enter command in SSH or Term-vt100:
iCostaCtl -uninstall111
Reboot to deactivate iCosta.
2. Cleanup
Enter commands:
rm -rf /Library/iCosta rm -f /usr/lib/iCosta.dylib rm -f /usr/bin/iCostaCtl
You have completely removed iCosta from your iPhone.
—
关于 NativeCn 和 iCosta
UPDATE: iCosta 1.0.5版已经修正了文件权限,并解决了应用初始化时的内存泄漏问题,可以直接从Installer安装。
—
UPDATE: 用于Dev Team Jailbreak 1.1.3以及Zibri Jailbreak 1.1.3。
UPDATE: 也可用于1.1.4。
NativeCn使用了苹果自己的固有的键盘机制,利用了日文输入法键盘,在没有针对1.1.3更新之前,可能尚无法直接支持1.1.3版。
iCosta本质上是一个附加库,通过dyld在启动SpringBoard时被自动载入, 并通过覆盖(override)部分方法(我猜测是UIKit的方法,没有逆向分析过)来实现中文输入,因此对于1.1.2的版本仍然可以用于1.1.3版。不过,目前的安装脚本不允许在1.1.3上直接安装,需要手工安装,这篇文章就是讲手工安装的方法的。
UPDATE: iCosta有比较明显的内存泄漏问题。在安装后,类似下面的这种错误随处可见:
*** _NSAutoreleaseNoPool(): Object 0x204680 of class NSConcreteValue autoreleased with no pool in place - just leaking *** _NSAutoreleaseNoPool(): Object 0x206960 of class NSCFString autoreleased with no pool in place - just leaking
该错误发生在应用初始化阶段。从错误信息看,显然是在创建可自动释放(autorelease)的对象之前没有创建NSAutoreleasePool实例,长期不重启的话,会逐渐导致系统可用内存越来越小。
安装方法
先下载好需要的iCosta 1.0.4版的PXL文件,我用的是拼音输入法,因此下载了 iCostaPy_1.1.2.pxl,其他的输入法安装方法与这里描述的完全一样。
1. 把文件改名成.zip,然后解压,得到以下内容:
PxlPkg.plist README.txt README_cn.txt bin/iCosta.dylib (植入库) iCostaImages/* (键盘需要的图片) icon.png util/iCostaCtl (用来安装和卸载的程序)
2. 在iPhone上建一个目录:
/Library/iCosta
然后把iCostaImages里面所有的PNG图片上传到建立的目录中去。完成后检查一下文件属性,应该所有人(Owner, Group, Other)都可读,否则调出输入法后看不见键盘的(注:原PXL中有权限错误),在 iPhone 上输入下面命令确保所有属性都正确:
chmod 755 /Library/iCosta chmod 644 /Library/iCosta/*
3. 把bin目录中的iCosta.dylib上传到iPhone的/usr/lib目录中去。如果对文件属性不确定, 可以输入下面命令保证权限正确:
chmod 755 /usr/lib/iCosta.dylib
4. 把util目录中的iCostaCtl上传到iPhone的/usr/bin目录中去。如果对文件属性不确定, 可以输入下面命令保证权限正确:
chmod 755 /usr/bin/iCostaCtl
5. 确定存在/var/root/Library/Preferences/.GlobalPreferences.plist文件,如果这个文件不存在,可以用符号连接指向mobile账号下的同名文件:
ln -s /var/mobile/Library/Preferences/.GlobalPreferences.plist /var/root/Library/Preferences/.
感谢Tice指出缺少.GlobalPreferences.plist文件的可能性。因Dev JB 113把root有关文件移动到了mobile账号(假如安装时没有选择保留用户数据),因此在root账号下的有关配置可能是空的。
6. 在iPhone上执行下列命令安装植入库并载入字典:
iCostaCtl -install111
以上命令修改了com.apple.SpringBoard.plist,在其中插入了植入库,并修改了全局配置文件.GlobalPreferences.plist,加入了zh_CN条目。
7. 重启SpringBoard使植入库生效:
launchctl remove com.apple.SpringBoard launchctl load /System/Library/LaunchDaemons/com.apple.SpringBoard.plist
在SpringBoard重启动的时候会通过dyld载入iCosta.dylib植入库,并进行初始化。iCosta.dylib通过重载部分方法来实现中文输入法。至此,已经可以正常输入中文了。
卸载方法
1. 修改SpringBoard配置文件并恢复设置:
iCostaCtl -uninstall111
该命令恢复经过修改的配置文件。
2. 重新启动SpringBoard:
launchctl remove com.apple.SpringBoard launchctl load /System/Library/LaunchDaemons/com.apple.SpringBoard.plist
3. 删除安装文件:
rm -rf /Library/iCosta rm -f /usr/lib/iCosta.dylib rm -f /usr/bin/iCostaCtl
至此,已经彻底删除了iCosta。
常见问题
为什么切换到中文输入法时看不到键盘,却可以“摸黑”输入?
这是因为用于输入法的键盘图片权限不对,无法读取造成的。iCosta的文件包里面iCostaImages目录中的文件权限不对,有部分文件只有所有者(Owner)才能读取,如果从 Unix操作系统上通过SCP或SFTP传到 iPhone后就需要修改权限(因为Unix系统的这种复制会连带属性一起复制,除非目标文件已经存在),修改的方法前面已经讲过了。
为什么以前安装没有这个权限问题?
因为以前SpringBoard应用都是以root身份运行的,可以读取任何文件,而自1.1.3开始,SpringBoard改为以mobile身份运行,而由于iCosta PXL文件本身的错误导致需要对文件权限进行调整。实际上,由于这个权限问题,很多第三方应用在1.1.3上都需要进行调整,比如Installer必须SUID root才能正确运行。
为什么用Natetrue的方法没有问题,用其他的就有问题?
还是权限问题。Natetrue的方法最后mobile实际上等同于root,拥有与root同等的权限,当然不会有读不到文件的问题了。Dev Team的方法是遵循了苹果的模式,让mobile与root区分开来,所以有权限问题。UPDATE: Natetrue的方法不是个好方法,只是临时的解决方案,最终还是要遵循Apple的多用户框架的。

35 Comments
多谢分享!
LumaQQ
mkdir -p /var/root/Library/LumaQQ
chmod 777 LumaQQ
chmod -R 755 /Applications/LumaQQ/
still have to check the permission in this folder tho..
Hi, George
It’s working on Dev official 1.1.3-3 upgrade?
Stephen,
Yes, should work for ALL kinds of jailbroken 1.1.3.
No. It is not iCosta’s issue. As you pointed, iCosta is a dynamic library and all its resources were from and controlled by host process. Memory leaking messages exist in many Apple’s own iPhone applications. You can also get them even if you didn’t install iCosta.
Holly,
Those errors never appear when iCosta was not installed, but appear immediately after the iCosta installation, so I’ll say it’s because there’s some kind of memory leaking in iCosta. Besides, I’ve also written the dylibs before and didn’t have such leaking issues.
And my guess is, when the overrided methods are called, the leak happens, but the syslog doesn’t log it as iCosta’s leak, it logs as its host applications error.
OK. I will do more checks. Basically nothing in iCosta would be touched until a Chinese keyboard is invoked to popup.
Well, if I got some spare time, I might do some reversing on iCosta cos I’m curious on everything iPhone related ;)
BTW, nice job, holly!
Thanks, but I think reversing iCosta is not a good idea :-) If someday I can go to HangZhou or you can go to Shanghai, I can tell you all secrets there. iCosta itself is just another reversing result from UIKit :-)
Holly,
LOL, nevermind, I’m just curious, reversing is a good way to learn stuffs. To be honest, iCosta implementation method is good, it’s flexible and easy to upgrade in case interfaces are changed in the future firmwares, it can’t be beaten unless Apple officially releases their SDK. Keep up the good job, man!
George:
能否研究一下weFIT,weiphone最新推出的输入法
似乎对于nate ture的jailbreak 1.1.3工作是正常的,但是对于Dev的jailbreak 1.1.3就无法正常工作。估计也是mobile/root的问题。
谢谢
非正式版没兴趣。
George, I am trying to follow your guide here but when I tried to use Term-vt100 to run some of the commands, I am unable to login as the root/alpine combination would not worked. Any ideas?
Johnson,
Read the article “Fix 3rd Party Application Issues in 1.1.3″.
thank u too much, icosta fonction, very nice!
great job
Hi George, I followed your guide and fix the Term-vt100 issue. Still having problems with the iCosta install. This is my 5th iteration…. i am pressing on and trying to get it to work on 1.1.3. If i fail again, i may have to go back to 1.1.2 until the new released of iCosta. Wish me luck…. and Happy New Year!
Ok Johnson, good luck and Happy New Chinese Year!
Hi George, it seems that after I have done with the Term-vt100 fix. Now, when I tried to use Installer for anything else, I get the “Main script execution failed” message. And I am also unable to sync with iTunes now. BTW, I was also unable to get iCosta to work. I did had it working on my #3 try but had to redo 1.1.3 install as I also had the same problem with iTunes then. Looks like I have to live with 1.1.2 for now. Thanks.
Hi George,
iCostaCtl -install111 need to access /private/var/root/Library/Preferences/.GlobalPreferences.plist. But, this file is located in /private/var/mobile/Library/Preferences/.GlobalPreferences.plist. I have to create a symbolic link otherwise the installer was failed.
Just for your inforamtion
Tice, yeah that may happen if you didn’t choose to keep the user data during the jailbreak, I’ve modified the article to make sure the preferences file exist. Thanks for the FYI.
谢谢你的帮助,我已成功安装并卸载了,呵呵。
hi, i was wondering if you could publish the installation instructions in english for iCOsta for firmware 1.1.3 on your blog cuz i can’t read chinese very well. would be very helpful indeed.
thanks!
hong
How do you enter Chinese if you can’t read it ? :)
Hi,
Any idea of when 1.1.4 will be supported? It seems to be a minor update, so maybe releasing a version should be relatively simple? (although I of course don’t know this!!)
Looking forward to having iCosta on again. :)
Best!
iCosta has no problem installing on 1.1.4 using the same trick in this article.
Hi, Ok - I’ll have a look, though I’d much prefer if there was a version in the Repository :-)
With regards to the English version - I second that. I use the input method because I’m learning Chinese - that does not mean that I yet can read all Chinese. And add to that - it takes much (!) longer at the moment. But having a Chinese input method is very good for learning more characters.
But having skimmed the article above, I guess I can read that with some assistance from Pera-Kun etc. I’ll have a look soon.
Best!
Ok - got it working. Thanks!!! :-)
Basically - for anyone interested. Once you have the file - upload images to /Library/iCosta, iCosta.dylib to /usr/lib, iCostaCtl to /usr/bin. Then run the above commands under installation - and you should be there. Correct me if I’m wrong, but thats what I did.
Best!
Anders
@Anders Gjerlov, yes, it’s exactly what the article describes :)
Added the English version ;)
Thanks - I guess my Chinese is getting better :-D Thanks again!! All the best!
Hi George, I followed step by step your instruction for my iPhone 1.1.4 and I get two errors in terminall and failed the installation:
for chmod 644 /Library/iCosta/* I get “Operation not permitted” for each *.png and for iCostaCtl -install111
“failled to create logfile
zsh: bus error iCostaCtl -install111
Any suggestion??:> Thanks!!
@Andra, check if you login as ‘root’.
Hrmm…am hoping someone can help. I’m on this website (http://iphone.freecoder.org/iCosta-113.html) and am trying to download iCosta 1.2.3 for my iphone 1.1.4, but I can’t seem to find where to download the actual file. My chinese is rusty, and I even have co-workers looking on the website but they can’t seem to find the download link either. Can anyone help me out here? Or provide a mirror site? I’d like to get this on my iphone…Any help would be appreciated. Thanks!!! :)
Btw, 1.1.4 is still unable to install this via Installer app, correct? If it now can, how do I go about doing so?
Hi BChou,
It is interesting to see this comment today. iCosta now can install on all official version of iPhone firmware, for 1.x you need add source http://iphone.freecoder.org/rep/ into Installer. For 2.x you need add source of freecoder.org in Cydia.
The website provides detailed instructions in Chinese as we assume the user can read Chinese. If you have trouble, how about consult google translate to get rough idea of the page?