【发布时间】:2017-10-07 00:20:13
【问题描述】:
每次我在 Xcode 中构建我的应用程序时,我都会尝试运行一个简单的 Python 脚本。 Python 脚本名为test.py,作为.xcodeproj 文件的同级文件驻留在我的项目文件夹中。
我想我遵循了 Stack Overflow 帖子中的说明
Is this possible to run a python script before Xcode doing compiling? 但我收到错误 Shell Script Invocation Error: Command /bin/sh failed with exit code 1
我安装了Python 3.5.2,但是当我在终端中输入python -V 时,我得到Python 2.7.10。但是,当我在终端中输入python3 -V 时,我得到Python 3.6.0。在终端中输入which python 会返回/usr/bin/python,而在终端中输入which python3 则会返回/Library/Frameworks/Python.framework/Versions/3.6/bin/python3。
按照Xcode: Running a script before every build that modifies source code directly 中的说明,我还将构建阶段中的运行脚本部分移至编译源之前。
这就是我的运行脚本部分的样子。我有一种强烈的感觉,即修复非常简单,但试图找出我做错了什么/在 Google 或 Stack Overflow 中使用什么搜索词没有成功。
当然,让我知道我可以提供哪些其他信息来帮助调试。
编辑:除了允许我在每次构建时运行 Python 脚本外,我对使用的 Python 版本没有偏好。我刚刚安装了 Python 3.5.2,因为我认为它可能会有所帮助。
编辑 2: 除了 Clean (Cmd-Shift-K) 和 Cleaning Build Folder... (Cmd-Shift-Alt -K) 仍然没有运气。
【问题讨论】:
-
如果你想要 Python3.5,你需要在命令行上运行
python3.5而不是运行 Python 3 的最后一个版本的python3,即你安装的 Python 3.6.0。