ios开发学习

界面文件 后缀为.nib或.xib,4.2以后改为storyboard。

真机开发

钥匙串访问(keychain)中创建证书,用于程序签名:

钥匙串访问-> 证书助理 -> 创建证书:

名称:iPhone Developer 证书类型:代码签名

修改Xcode下SDK配置:

XCode4.5中路径为

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ open iPhoneOS6.0.sdk/SDKSettings.plist

文件不再是xml文件,而是二进制文件了,使用Xcode或Plist Editor Pro编辑,将DefaultProperties中CODE_SIGNING_REQUIRED值改为NO。

XCode4.3以后Xcode作为独立应用程序,所有的文件都打包在Xcode里面,之前/Developer下的文件现在变为/Applications/Xcode.app/Contents/Developer/。

Xcode4.3中为:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ sudo vi iPhoneOS5.0.sdk/SDKSettings.plist

Xcode4.2及其以前的版本中:

$ cd /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
$ sudo vi iPhoneOS5.0.sdk/SDKSettings.plist

将如下内容:

15         <key>CODE_SIGNING_REQUIRED</key>
16 <string>YES</string>

中YES改为NO。

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/

将XCiPhoneOSCodeSignContext中的iPhoneOS删掉:

$ sudo vi Info.plist
:1,$s/XCiPhoneOSCodeSignContext/XCCodeSignContext/g

二进制补丁

XCode4.3中路径为:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS

XCode 4.2中路径为:

$ cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS

然后:

$ sudo su
# dd if=iPhoneOS\ Build\ System\ Support of=working bs=500 count=255
# echo -n xc3x26x00x00 >> working
# chmod 755 working
# mv iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.orig
# mv working iPhoneOS\ Build\ System\ Support

自定义生成后脚本

$ mkdir /Applications/Xcode.app/Contents/Developer/iphoneentitlements
$ cd /Applications/Xcode.app/Contents/Developer/iphoneentitlements
$ wget -q http://www.alexwhittemore.com/iphone/gen_entitlements.txt -O gen_entitlements.py
$ chmod 755 gen_entitlements.py

修改工程设置

Add Build Phrase -> Add Run Script,输入以下内容:

export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
if [ "${PLATFORM_NAME}" == "iphoneos" ]; then
/Applications/Xcode.app/Contents/Developer/iphoneentitlements/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";
codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"
fi

参考资料:

http://hi.baidu.com/jaywclove/blog/item/0782355562849cdab645ae14.html

http://slj.me/2010/10/50-open-source-iphone-apps-for-iphone-developers/

git

https://github.com/haqu/tweejump.git

https://github.com/freshbooks-addons/freshbooks-iphone-project.git

tagged by
comments powered by Disqus