无法在 OS X El Capitan 中使用命令 genstrings

Unable to use command genstrings in OS X El Capitan

我正在使用 Xcode 6.4 in OS X 10.11 El Capitan (Beta 3) 开发 iOS 应用程序。

每当我尝试使用终端命令 genstrings 进行本地化时,我都会收到消息

genstrings: error: unable to find utility "genstrings", not a developer tool or in PATH

我从第二个测试版开始就遇到这个错误。

有人需要处理这个问题吗?提前致谢!

你好,当我尝试在 OS X El Capitan 中使用 Xcode 6.4 的 genstrings 和 Xcode 时,我也 运行 遇到了这个问题7 个已安装。

由于某种原因,/Applications/Xcode.app/Contents/Developer/usr/bin 中 Xcode 6.4 的 genstrings 缺失。我尝试通过 运行 xcode-select --install 重新安装 Xcode 开发人员工具,但无济于事。

我正在使用的解决方案是一种 hack,它正在从 Xcode 7 中的 genstrings 到 Xcode 6.4 的 Developer/usr/bin 路径中创建符号链接如下命令所示。

sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/usr/bin/genstrings /Applications/Xcode.app/Contents/Developer/usr/bin

Apple 似乎没有提供长期解决方案

OS X El Capitan no longer ships with genstrings. That utility is instead provided by Xcode 7. This means that older versions of Xcode won’t find genstrings in /usr/bin like they would on older versions of OS X. (19708961)

Xcode 7 Release Notes

OS X 10.11 (El Capitan) 不再包含 genstrings(参见 Xcode 7 Release Notes)。它现在包含在 Xcode 7 中。如果您选择 Xcode 6.4 作为命令行工具,您将无法 运行 genstrings。但是,您可以使用 xcrun 并将 DEVELOPER_DIR 环境变量从 Xcode 7 设置为 运行,即使未选择该版本作为命令行工具:

DEVELOPER_DIR=<path to Xcode 7.x> xcrun genstrings

例如,如果您将 Xcode 的最新版本安装为 /Applications/Xcode.app,您可以执行

DEVELOPER_DIR=/Applications/Xcode.app xcrun genstrings

对我来说,我需要更改我的活动开发者目录的路径。

您可以通过运行以下内容查看您当前的活动开发者目录:

$ xcode-select -p

最初输出 /Library/Developer/CommandLineTools

解决方案:

我不得不 运行

$ sudo xcode-select -s /Applications/Xcode.app

然后将第一个命令的输出更改为 /Applications/Xcode.app/Contents/Developer。之后就正确找到了genstrings命令