xcode 无法打开文件 InfoPlist.strings
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9359835/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The file InfoPlist.strings couldn't be opened
提问by Andrey Chernukha
Can anyone please help me? What should i do to fix the error "The file InfoPlist.strings couldn't be opened because there's no such file"? It's appeared after i've updated my project from SVN. Actually THERE IS InfoPlist.strings in my project, i have no idea why Xcode doesn't see it.
谁能帮帮我吗?我应该怎么做才能解决错误“文件 InfoPlist.strings 无法打开,因为没有这样的文件”?它出现在我从 SVN 更新我的项目之后。实际上我的项目中有 InfoPlist.strings,我不知道为什么 Xcode 看不到它。
Maybe the following information will help you to understand what's going on: when i expand InfoPlist.strings by clicking on the triangle next to it, then it shows: InfoPlist.strings (English), InfoPlist.strings(German), InfoPlist.strings(French). The English is black, but French and German are red, so i suppose it is probable something wrong with them and it might be the cause of the error. Also, i've got Localizable.strings, which behaves in similar way. It has (when expanded) Localizable.strings (English), Localizable.strings(German), Localizable.strings(French) and just as in InfoPlist.strings English is black whereas French and German are red.
也许以下信息会帮助您了解发生了什么:当我通过单击旁边的三角形展开 InfoPlist.strings 时,它会显示:InfoPlist.strings(英语)、InfoPlist.strings(德语)、InfoPlist.strings(法语)。英语是黑色的,但法语和德语是红色的,所以我想它们可能有问题,这可能是错误的原因。另外,我有 Localizable.strings,它的行为方式类似。它有(扩展时)Localizable.strings(英语)、Localizable.strings(德语)、Localizable.strings(法语),就像在 InfoPlist.strings 中英语是黑色的,而法语和德语是红色的。
When i look inside my project's folder - there is the following there: a folder named en.lproj contains Localizable.strings and InfoPlist.strings. Folders named fr.lproj and de.lproj contains the same - Localizable.strings and InfoPlist.strings. Seems like i've described everything. Please explain me what to do. I work with Xcode 4.2
当我查看我的项目文件夹时 - 那里有以下内容:名为 en.lproj 的文件夹包含 Localizable.strings 和 InfoPlist.strings。名为 fr.lproj 和 de.lproj 的文件夹包含相同的内容 - Localizable.strings 和 InfoPlist.strings。好像我已经描述了一切。请解释我该怎么做。我使用 Xcode 4.2
回答by Mutix
I have just managed to fix this problem !
我刚刚设法解决了这个问题!
My second Strings.plist file (FR) had an absolute path. The drop down menu for path type (absolute, relative) was greyed out in the info pane of xcode so I could not change it to a relative path.
我的第二个 Strings.plist 文件(FR)有一个绝对路径。路径类型(绝对、相对)的下拉菜单在 xcode 的信息窗格中显示为灰色,因此我无法将其更改为相对路径。
The solution is to change it manually in the project.pbxproj
file:
解决方法是在project.pbxproj
文件中手动更改:
If you open the file to view the source, and search for "plist", find the following line:
如果打开文件查看源码,搜索“plist”,找到以下行:
/* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = /Users/[YOUR-USER]/[PATH_TO_PROJECT]/fr.lproj/InfoPlist.strings; sourceTree = "<absolute>"; };
Notice that the path
attribute is the full path to the file, and that the sourceTree
attribute is set to <absolute>
.
请注意,该path
属性是文件的完整路径,并且该sourceTree
属性设置为<absolute>
.
Now change the path
so that it's relative:
现在改变path
它,使它是相对的:
/Users/[YOUR-USER]/[PATH_TO_PROJECT]/fr.lproj/InfoPlist.strings
should become
应该成为
fr.lproj/InfoPlist.strings
Also change the sourceTree
value from <absolute>
to <group>
还将sourceTree
值从更改<absolute>
为<group>
The line should now look like this:
该行现在应如下所示:
/* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/InfoPlist.strings; sourceTree = "<group>"; };
Repeat these steps for all your localizations that are stuck with absolute paths.
对所有被绝对路径卡住的本地化重复这些步骤。
Save the file, commit the changes, and voilà!no more no such fileproblem :)
保存文件,提交更改,瞧!不再有这样的文件问题:)
回答by kai
info.plist source code: like: .... {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; ....
info.plist 源代码:如:.... {isa = PBXFileReference; lastKnownFileType = text.plist.strings; 名称 = zh; 路径 = en.lproj/InfoPlist.strings; 源树 = ""; }; ....
check "path" is a absolute path?
检查“路径”是绝对路径吗?
回答by HixField
Had the same problem, easy fix for me: select the plist file in xcode and make sure its "Target Membership" is ON (for the build you are doing).
有同样的问题,对我来说很容易解决:在 xcode 中选择 plist 文件并确保它的“目标成员资格”是 ON (对于你正在做的构建)。
回答by Jay Bhalani
The solution for this particular instance of the error was “Info.plist couldn't be opened because there is no such file” was that I had deleted all of the files in the "Project Tests" folder, but was still had "Project Tests" listed under my targets. After deleting the "tests" target, the project built successfully.
这个特定错误实例的解决方案是“Info.plist 无法打开,因为没有这样的文件”是我已经删除了“项目测试”文件夹中的所有文件,但仍然有“项目测试” “列在我的目标下。删除“tests”目标后,项目构建成功。
回答by www_sq
I got this error when i pulled my cohort's changes to my local so that i can review and test them. I checked all settings suggested in this thread but they all looked correct-ish. My fix was just to blow away the branch, reset to master and pull the updates to a clean branch. The ol' reboot everything technique.
当我将我的群组的更改拉到我的本地以便我可以查看和测试它们时,我收到了这个错误。我检查了此线程中建议的所有设置,但它们看起来都正确。我的修复只是吹走分支,重置为 master 并将更新拉到一个干净的分支。ol' 重启一切技术。
回答by joerick
The path to your Info.plist file is defined in the build settings for the target. Look and see what it's set to. If the project has come from a different machine, it might be an absolute path, but it really should be a path relative to the project root, like Sources/Info.plist
.
Info.plist 文件的路径在目标的构建设置中定义。看看它的设置。如果项目来自不同的机器,它可能是一个绝对路径,但它确实应该是一个相对于项目根目录的路径,比如Sources/Info.plist
.
回答by John Stack
Best information is right here. Sorry to be so cheesy as to put a link to this - but they edited it in September - and now it makes sense...
最好的信息就在这里。很抱歉这么粗鲁地放了一个链接——但他们在 9 月编辑了它——现在它是有道理的......
回答by Harald Hauknes
I just recreated the files (with empty content) it asked for in the paths it asked for them, since I am new to XCode and it didn't seem to affect my current project I decided that was a acceptable solution/shortcut to proceed.
我只是在它要求的路径中重新创建了它要求的文件(带有空内容),因为我是 XCode 的新手,它似乎没有影响我当前的项目,我认为这是一个可接受的解决方案/快捷方式。