添加 XIB 本地化会搞乱 Xcode 中的源代码控制系统
当在 Xcode 中获取非本地化的 XIB 文件并使其可本地化时,它会自动将默认区域/本地化添加到 XIB 文件中,例如“en”或“English”。这实际上将 XIB 文件移动到 en.lproj 或 English.lproj 目录中。如果 XIB 文件位于 SVN 等版本控制系统中,SVN 就会开始崩溃,因为该文件未在版本控制系统中移动,并且它认为该文件丢失了。该怎么办?有没有办法让 Xcode 以版本控制友好的方式移动 XIB 文件,或者我是否需要使用终端中的 SVN 命令提示符移动文件?
When one takes a non-localized XIB file in Xcode, and makes it localizable, it automatically adds the default region/localization to the XIB file, e.g. "en" or "English." This actually moves the XIB file into the en.lproj or English.lproj directories. If the XIB file is in a version control system such as SVN, SVN starts to freak out because the file was not moved within the version control system, and it thinks that it is missing. What to do? Is there a way to have Xcode move the XIB files in a version control-friendly way, or do I need to move the files with the SVN command-prompt in Terminal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我应该发布我自己的解决方案来解决这个问题。这不是最“优雅”的解决方案,但它对我有用。本质上,我不会直接“本地化”XIB 文件,而是将每个包含文本的 UI 对象连接到 IBOutlet,并在 UIView 类中以编程方式设置文本。这样,我的所有字符串最终都会出现在常规字符串文件中,而不是为 XIB 文件提供一组单独的字符串文件。到目前为止,它运行得很好。
I figured I'd post my own solution to this problem. It's not the most "elegant" solution, but it works for me. Essentially, I don't "localize" the XIB files directly, but I hook up every UI object that has text in it to an IBOutlet, and set the text programmatically in my UIView class. That way, all of my strings end up in the regular strings files rather than having a separate set of strings files for the XIB files. So far, it's working pretty well.
当我最初尝试本地化签入 SVN 的 .xib 文件时,我最初收到“svn:无法将 '{path}/.svn/tmp/entries' 移动到 '{path}/.svn/entries” ':不允许操作。”错误。
根据这篇博客文章(http://www.devcha.com/2008/03/mac-os-cant-move-svntmpentries-to.html),我通过在包含 .从终端获取有问题的 xib 文件:
然后我就能够从 Xcode 中本地化 .xib 文件。之后,SVN 正确地跟踪了从相关文件夹中删除 .xib 文件的操作,以及添加新的本地化文件夹(在我的例子中为 en.lproj)以及将 .xib 文件移动到此新文件夹的情况。
根据 chflags 的 man 条目,-R 代表“更改以文件为根的文件层次结构的文件标志,而不仅仅是文件本身。”,“nouchg”代表“清除用户不可变标志(所有者或超级用户)仅用户)”并使用“。”然后字符将更改应用到当前文件夹。
When I originally attempted to localize an .xib file that was checked in to SVN, I initially got the "svn: Can't move '{path}/.svn/tmp/entries' to '{path}/.svn/entries': Operation not permitted." error.
Based on this blog post (http://www.devcha.com/2008/03/mac-os-cant-move-svntmpentries-to.html), I successfully fixed the error by performing the following in the directory containing the .xib file in question from the terminal:
I was then able to localize the .xib file from within Xcode. Afterwards, SVN correctly tracked the deletion of the .xib file from the folder in question as well as the addition of the new localized folder (en.lproj in my case) and the moved .xib file to this new folder.
Based on the man entry for chflags, -R stands for "Change the file flags for the file hierarchies rooted in the files instead of just the files themselves.", "nouchg" stands for "clear the user immutable flag (owner or super-user only)" and using the "." character afterwards applies the change to to the current folder.