本文是根据某个帖子写的(帖子链接在最后放出),但是在配置的过程中,遇到了一个纠结的问题,这个问题折腾了我N久,一直没搞明白到底是什么原因,问题如下:
按照原帖上写的每一步去做了,但是在最后编译的时候出现:
File "/Applications/Xcode.app/Contents/Developer/iphoneentitlements/gen_entitlements.py", line 7 print "Usage: %s appname dest_file.xcent" % sys.argv[0] ^ SyntaxError: invalid syntax /Users/Tim/Library/Developer/Xcode/DerivedData/Test2-fbgyiarlglmedvgshdatrgbksdvu/Build/Products/Debug-iphoneos/Test2.app/Test2.xcent: cannot read entitlement data Command /bin/sh failed with exit code 1
网上也看到有人问过这个问题,但是没有人解答,首先,确认了iPhone是已经越狱的了,而且也通过Cydia安装了AppSync,原帖说的每一步我都仔细的对过,没有问题,但是始终卡在这里,在最后本来想放弃的时候,突然想到会不会是python的环境变量问题?加上了下面那一句话之后,果然...
export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"(注意将这里的路径改成你本机安装的python路径)
事实上这一句话在我的bash_profile里已经加了的,在Terminal里执行python -V也是可以显示python的版本号的,我不明白为何在XCode的Build Phase的Run script里却找不到python的执行环境,求高人指点,anyway,现在问题总算解决了,实际上就是在原帖说的最后一步,“在Build Phases中添加一个Phase,右下角的Add Build Phase,然后单击Add Run Script,输入以下脚本” ,这里,在“export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate”前加上面的那句话就OK了,全部代码如下(注意修改python的路径):
export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate if [ "${PLATFORM_NAME}" == "iphoneos" ] || [ "${PLATFORM_NAME}" == "ipados" ]; 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
----------------------------------------------------------------