迁移 Xcode 项目后无法更改位置/路径设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7807278/
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
Unable to change location / path settings after migrating Xcode project
提问by Fruity
I've migrated an Xcode project (iOS app) from one mac to another (same Dev Account and Code Signing preferences). Now the build fails and I get errors stating that certain files (MainWindow.xib, MyappViewController.xib and InfoPlist.string) don't exist. I've already read that several people have had this problem before and tried out the answers they got, but nothing seems to work.
我已将 Xcode 项目(iOS 应用程序)从一台 mac 迁移到另一台(相同的开发帐户和代码签名首选项)。现在构建失败,我收到错误消息,指出某些文件(MainWindow.xib、MyappViewController.xib 和 InfoPlist.string)不存在。我已经读过一些人之前遇到过这个问题并尝试了他们得到的答案,但似乎没有任何效果。
As I understand, the problem lies within the path preferences for the NIB files. The error messages give the files' path as Users/Meonmyoldmac/etc - which I should change, because it's an absolute path and therefore doesn't make sense on another computer. But: when I try to open those files under Groups & Files their location is already set to 'Relative to group' and their path is given as Users/Meonmynewmac/etc. - which is exactly how I actually want it to be. (Oddly enough, the file type is listed as 'Default - Unknown' )
据我了解,问题在于 NIB 文件的路径首选项。错误消息将文件的路径指定为 Users/Meonmyoldmac/etc - 我应该更改它,因为它是绝对路径,因此在另一台计算机上没有意义。但是:当我尝试在“组和文件”下打开这些文件时,它们的位置已经设置为“相对于组”,并且它们的路径为 Users/Meonmynewmac/etc。- 这正是我真正想要的。(奇怪的是,文件类型被列为“默认 - 未知”)
I've already tried… - cleaning the project - deleting those files from the project and putting them back in again - restarting Xcode several times
我已经尝试过...... - 清理项目 - 从项目中删除这些文件并将它们重新放回 - 多次重新启动 Xcode
that's possibly important: - I'm talking about a Universal iOS App, yet only iPhone files are affected; their iPad equivalents work fine - I changed the app localization to German, so the mentioned files are located in a folder called de.lproj - I created the project with Xcode 4 on my older Snow Leopard Mac and use Lion/Xcode 4.2 on the new one - does that play any role here?
这可能很重要: - 我说的是通用 iOS 应用程序,但只有 iPhone 文件受到影响;他们的 iPad 等效项工作正常 - 我将应用程序本地化更改为德语,因此提到的文件位于名为 de.lproj 的文件夹中 - 我在较旧的 Snow Leopard Mac 上使用 Xcode 4 创建了该项目,并在新的雪豹 Mac 上使用 Lion/Xcode 4.2一 - 这在这里有什么作用吗?
Thanks in advance, Fruity
提前致谢,果味
回答by marmor
If you have absolute paths to some of your files, you'll need to change them to relative paths:
如果您有某些文件的绝对路径,则需要将它们更改为相对路径:
- In the
Project Navigator
, locate the missing files (colored red for not being found) and highlight one of them. - Show the
File Inspector
- Under
Location
changeAbsolute Path
toRelative to group
orRelative to project
, - Then next to the path, there's a little white icon, click it and choose the file's location.
- 在 中
Project Navigator
,找到丢失的文件(未找到的红色)并突出显示其中之一。 - 显示
File Inspector
- 在
Location
更改Absolute Path
为Relative to group
或 下Relative to project
, - 然后在路径旁边,有一个白色的小图标,单击它并选择文件的位置。
回答by Jim
Right-click on the files in Finder, select Get Info
. Check that you have permission to read the files.
右键单击 Finder 中的文件,选择Get Info
。检查您是否具有读取文件的权限。
Edit: Just noticed the error messages refer to the old path, so it can't be a permissions problem.
编辑:刚刚注意到错误消息指的是旧路径,所以它不可能是权限问题。
Groups can have paths set as well. Select the groups and verify that their paths are correct.
组也可以设置路径。选择组并验证它们的路径是否正确。
回答by Fruity
I performed the terminal search suggested by Jim yesterday, found some 'source tree: absolute' entries in project.pbxproj and tried to manipulate them, which didn't work - couldn't even open the project in Xcode afterwards - so I called it a day.
我昨天执行了 Jim 建议的终端搜索,在 project.pbxproj 中找到了一些“源代码树:绝对”条目并尝试操作它们,这不起作用 - 之后甚至无法在 Xcode 中打开该项目 - 所以我称之为一天。
Just now I did what I already tried yesterday before posting my question: I deleted the files from the project and copied them back in again. That miraculously eliminated all red warning signs from my project and just gave me a nice green SIGABRT when I tried to run it on the simulator. Cleaned project, restarted Xcode - perfect. Oh, and I checked the targeted device family setting, found that it was set to iPhone and switched it to iPhone/iPad - no idea if that was part of the issue.
刚才在发布我的问题之前,我做了昨天已经尝试过的事情:我从项目中删除了文件并再次将它们复制回来。这奇迹般地消除了我项目中的所有红色警告标志,当我尝试在模拟器上运行它时,它只给了我一个漂亮的绿色 SIGABRT。清理项目,重新启动 Xcode - 完美。哦,我检查了目标设备系列设置,发现它被设置为 iPhone 并将其切换到 iPhone/iPad - 不知道这是否是问题的一部分。
I'm not sure if that's really an answer to the problem - but the problem has vanished...
我不确定这是否真的是问题的答案 - 但问题已经消失了......
Thanks for your help!
谢谢你的帮助!
回答by Owen Hartnett
In XCode 4, when you have all three panes open, select the file in the left most pane. In the right most pane, select the white document icon at the top, looking for the header "Identity and Type." Under the popup for "location" is the name of the file. To the right of that name is a tiny icon like a window. Click on that, and you can set the location of the file.
在 XCode 4 中,当您打开所有三个窗格时,选择最左侧窗格中的文件。在最右侧的窗格中,选择顶部的白色文档图标,查找标题“身份和类型”。在“位置”的弹出窗口下是文件的名称。在该名称的右侧是一个像窗口一样的小图标。单击它,您可以设置文件的位置。
回答by YvesJusot
A less-actions solution. You can change manually in the project definition file.
一个少动作的解决方案。您可以在项目定义文件中手动更改。
- Close xCode
- Open .xcodeproj file in a text editor: in fact it's a folder, so edit in a text editor the inside file: project.pbxproj.
- Search for the string: absolute(for sourceTree param) For each entry (file with a absolute path set), change absoluteto group.
- 关闭 xCode
- 在文本编辑器中打开 .xcodeproj 文件:实际上它是一个文件夹,因此在文本编辑器中编辑内部文件:project.pbxproj。
- 搜索字符串: absolute(对于 sourceTree 参数)对于每个条目(具有绝对路径集的文件),将absolute更改为group。
And change the pathparameter to a relative path. example: path = en.lproj/PilotInfoViewController.xib; - Save the file and reopen xCode.
并将路径参数更改为相对路径。例如:path = en.lproj/PilotInfoViewController.xib; - 保存文件并重新打开 xCode。
PS: Make a backup copy of your project file before doing this manipulation.
PS:在进行此操作之前,请备份您的项目文件。