在资源中移动.lproj文件 [英] Moving .lproj file inside Resources

查看:108
本文介绍了在资源中移动.lproj文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开始项目的本地化,并且已经有了英文版本的Localizable.strings.我现在正尝试将法语添加到该文件中,正如我期望的那样,该文件正在创建fr.lproj文件夹.但是,它将其放入我的项目根目录中,并且我希望将其放入我的项目的Resources目录中.

I'm trying to begin localization on a project, and I've already got an English version of Localizable.strings going. I'm now trying to add French to that file, which is creating an fr.lproj folder, as I'd expect. However, it's putting it in my project root, and I'd like it inside my project's Resources directory.

Xcode似乎对让我移动文件没有兴趣,并且如果我在Finder中移动它,它会按预期在Xcode中变成红色,但不会让我单击以查找文件.

Xcode seems to have no interest in letting me move the file, and if I move it in Finder, it goes red in Xcode as expected, but doesn't let me click to locate the file.

我尝试过在Finder中移动它,然后在文本编辑器中编辑project.pbxproj,以在其中唯一提及fr.lproj/Localizable.strings的行之前添加Resources/,并且行得通,但这样做之后,该项目的目标在Xcode中也变成了红色,并且构建应用程序并不会改变这一事实.很奇怪..知道会发生什么,或如何使它继续吗?

I've tried moving it in Finder, then editing project.pbxproj in a text editor to add Resources/ in front of the only line in there that mentions fr.lproj/Localizable.strings, and that has worked, but after doing that, the project's targets also turned red in Xcode, and building the app doesn't change that fact. Very odd.. any idea what could be going on, or how to get this going?

推荐答案

这可能是真正的痛苦.尝试更正不需要的文件位置时,我甚至使XCode崩溃.我发现最好的方法是将本地化文件(为.strings.xib)创建为XCode之外的源语言版本的副本,然后将其拖放到XCode中.如果执行此操作,则XCode将正确显示它,并且目标的构建阶段">复制捆绑包资源"设置会将其包含在正确的位置.我不知道为什么您的目标以红色显示,如果万一那里有问题,您可能会在复制捆绑资源"下查看,或者如果您尚未这样做,还可以选择您的项目并单击验证设置".

This can be a real pain. I even had XCode crash on me when trying to correct unwanted file locations. I found that the best way is to create the localized file (be it .strings or .xib) as a copy of the source language version outside of XCode, then drag and drop it into XCode. If you do this then XCode will display it correctly and your targets' Build Phases > Copy Bundle Resources settings will include it with its correct location. I don't know why your targets are displayed in red, perhaps you could look under Copy Bundle Resources in case anything is wrong there, or also select your project and click Validate Settings in case you haven't already done so.

此外,如果您已经在模拟器中进行测试,请当心 XCode不能清除应用包中的文件 –您可能要删除该应用并再次运行,以确保它可以在您的新位置使用.

Also, if you have been testing in the simulator beware of how XCode does not clean up the files in your app bundle--you may want to delete the app and run it again to make sure it's working with your new location.

这篇关于在资源中移动.lproj文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆