我创建了一个新的目标阶段,并运行脚本,如下所述:
http://yeahrightkeller.com/2008/10/19/xcode-run-script-build-phase-tip/
我编写了一个Python脚本,用于解析程序Info.pList
from Foundation import NSMutableDictionary
但是,编译时脚本失败并向构建结果报告以下错误:
Running a custom build phase script: gitversion.py Traceback (most recent call last): file "/Users/jorge/documents/Programming iPod/Pruebas/RowOrder/Scripts/gitversion.py",line 9,in <module> from Foundation import NSMutableDictionary file "/System/library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/Foundation/__init__.py",line 8,in <module> file "/System/library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/__init__.py",line 26,in <module> from _brIDgesupport import * file "/System/library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/_brIDgesupport.py",in <module> import pkg_resources file "/System/library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py",line 651,in <module> class Environment(object): file "/System/library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py",line 654,in Environment def __init__(self,search_path=None,platform=get_supported_platform(),python=PY_MAJOR): file "/System/library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py",line 55,in get_supported_platform plat = get_build_platform(); m = macosversionString.match(plat) file "/System/library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py",line 181,in get_build_platform plat = get_platform() file "/System/library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/util.py",line 97,in get_platform cfgvars = get_config_vars() file "/System/library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py",line 525,in get_config_vars func() file "/System/library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py",line 408,in _init_posix raise distutilsPlatformError(my_msg) distutils.errors.distutilsPlatformError: $MACOSX_DEPLOYMENT_TARGET mismatch: Now "10.5" but "10.6" during configure Finished running custom build phase script: gitversion.py (exit status = 1)
很明显,distutils以某种方式硬编码它是为版本10.6(SNow Leopard,我正在使用的那个)编译的,但该项目将MacOSX部署目标设置为10.5.
如果我尝试将项目中的此变量设置为10.6,那么我得到:
ld: library not found for -lcrt1.10.6.o
关于如何解决这个问题的任何想法?提前致谢.
解决方法 我有同样的问题,我想保留python版本,因为通过NSMutableDictionary处理pList比在Info.pList上使用正则表达要好得多.基于Maxence的答案,解决方案是将python代码从Run Script构建阶段剥离到gitversion.py文件中:
#!/usr/bin/env pythonimport osfrom Foundation import NSMutableDictionaryfrom subprocess import Popen,PIPEp = Popen( "/sw/bin/git rev-parse --short head",stdout=PIPE,close_fds=True,shell=True)version = p.stdout.read()print versioninfo = os.environ['INFOPList_file']print infopList = NSMutableDictionary.dictionaryWithContentsOffile_(info)print pListpList['revision'] = version[:-1]pList.writetofile_atomically_(info,1)
然后用shell脚本替换原始的Run Script:
env MACOSX_DEPLOYMENT_TARGET=10.6 python gitversion.py
请务必记住将Shell设置更改为/ bin / sh.
总结以上是内存溢出为你收集整理的iphone – Xcode目标阶段Python脚本全部内容,希望文章能够帮你解决iphone – Xcode目标阶段Python脚本所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)