ios - Xcode 导出本地化抛出错误 "Argument list too long"

标签 ios xcode build

关于 Xcode 本地化过程,我有一个非常奇怪的错误要分享。我会尽量在法律允许的范围内分享更多细节。

我正在尝试从 Xcode 导出一个 XLIFF 文件以通过“编辑器 > 本地化导出”发送给我们的翻译人员。但是,这会立即引发错误消息:

The operation couldn't be completed. Argument list too long

这确实令人困惑,因为我在任何地方都找不到更详细的日志(我已经尝试检查我的 Console.app)。所以,我花了很多时间谷歌搜索——无济于事。我找不到这样的类似案例。错误本身仅在我尝试导出本地化时发生。我可以很好地构建和运行该应用程序。

事实

~ $ xcodebuild -version
Xcode 8.2
Build version 8C38
~ $ xcode-select -version
xcode-select version 2347.
~ $ echo $PATH
/Users/david.christiandy/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/david.christiandy/arctools/arcanist/bin:/usr/local/go/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
  1. 我在 macOS Sierra 10.12.5 上使用 Xcode 8.2。
  2. 错误仅在我尝试从本地化导出时发生。当我通过 xcodebuild -exportLocalizations 运行本地化过程时也是如此。
  3. 我可以很好地构建和运行该应用程序。 (我相信)我的标题搜索路径没有问题。

尝试

  • 以为代码有问题,所以我尝试在 CI 中运行导出过程(通过 xcodebuild 命令)。不知何故,它的工作。作为记录,我使用的 Bitrise CI 与我的系统具有相同的堆栈(Xcode 8.2.x,macOS 10.12)
  • 请同事在他们的机器上运行导出过程,他们有同样的错误。
  • 这使我认为配置一定有问题。所以我做了一个独立的项目来确认导出过程一直失败。事实证明,它工作得很好!

所以,我目前得到的假设是:

  • 代码中可能有问题,并且
  • 可能有一些工具/软件(我们的大多数 iOS 工程师都安装了)可能导致错误(因为 CI 完成得很好)。

我不知道为什么 CI 可以很好地运行导出过程,我也不知道它什么时候会突然停止运行(就像我们本地的机器一样)。

感谢在此问题上的任何帮助。谢谢!

最佳答案

我也在 Apple 开发者论坛上问过这个问题,这里是链接:https://forums.developer.apple.com/thread/86762

“Argument list too long” sounds like E2BIG, which you get when you try to run a child process with a huge argument list (I believe the current limit is 256 KiB). I suspect that Export for Localizations is running some sort of command line tool to do that work (probably the extractLocStrings tool, which you’ll find lurking within Xcode’s app bundle) and passing it full paths to each of the files in your project. Depending on how many files you have and how long those paths are, it’s easy to run into problems like this.

One of the ‘fun’ things about bugs like this is that they are dependent on where you place your project. Things might work if the project is at the top of your home directory but fail if it’s nested deep inside a subdirectory. That also suggests a potential workaround, namely, to move your project further up in the directory hierarchy.

Finally, you should definitely file a bug about this. I believe we’ve seen this before (r. 30703294) but your report will help reinforce that this is causing problems for developers in the field. Please post your bug number, just for the record.

几天前,在我阅读此答案之前,我通过 Xcode 删除了一些文件夹(仅删除引用),设法使导出工作正常进行。最初我怀疑我删除的文件夹中存在无效格式,但当我尝试删除其他文件夹时,导出过程工作正常。

我也尝试过使用 Xcode 9 导出字符串,但没有遇到问题。所以希望这个错误只适用于 Xcode 8.3.3 及以下版本。

关于ios - Xcode 导出本地化抛出错误 "Argument list too long",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44368532/

相关文章:

android - sqlcipher - sqlcipher 有多安全?它被黑客入侵了吗?

ios - 在 Xcode 中的 .Swift 文件之间传递数据

xcode - 在应用程序级别的 Xcode 中从 USB 设备获取序列号

xcode - xcode 中的 Bash 脚本返回 Shell 脚本调用错误

linux - 无法从 CentOS 中的源构建 Mercurial

angularjs - Grunt 构建在 'Dist' 中遗漏了一个新目录

iphone - 在Appdelegate类中控制一个类的AVAudioPlayer

ios - UIImageView 在单 View 应用程序中遵循循环路径,如何?

ios - 委托(delegate)可以为 2 个委托(delegate)使用单一方法吗?

xcode - IPA 中两次包含 Swift 库