在 Xcode 4 中将项目添加到工作区的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5908041/
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
Problems adding Projects to Workspace in Xcode 4
提问by McKrassy
I have a couple of projects that I had started under Xcode 3.2.x some time ago. I switched to Xcode 4 a few days ago and want to make use of the Workspace feature as both projects. Basically, my plan is to extract some common features out of the two projects and make them a common library that both projects depend on. However, before I even get to the tricky bit of dependencies I get stuck just adding my two projects to the workspace.
我有几个项目是我前段时间在 Xcode 3.2.x 下启动的。几天前我切换到 Xcode 4,并希望将工作区功能用作两个项目。基本上,我的计划是从两个项目中提取一些共同特征,并使它们成为两个项目都依赖的公共库。然而,在我什至解决棘手的依赖关系之前,我只是将我的两个项目添加到工作区。
I tried creating a new workspace and selecting "Adding files to " from the context menu; I then select the .xcodeproj file from my first project and it appears in the left-hand side tree browser in my workspace. However, it's just the file, not the project that I get. That is, rather than getting a two-line entry in the tree browser where the first line states the project name and the second line says something like "1 target, iOS SDK 4.3" like in the Apple documentation, I get a single line simply stating the name of the .xcodeproj file including the extension. There is also no triangle on the left to expand the node. It's like I just dragged some file in the workspace, not a project. The same goes for the second project.
我尝试创建一个新工作区并从上下文菜单中选择“将文件添加到”;然后我从我的第一个项目中选择 .xcodeproj 文件,它出现在我工作区的左侧树浏览器中。但是,这只是文件,而不是我得到的项目。也就是说,我没有在树浏览器中获得两行条目,其中第一行表示项目名称,第二行表示类似 Apple 文档中的“1 个目标,iOS SDK 4.3”之类的内容,我只得到一行说明 .xcodeproj 文件的名称,包括扩展名。左边也没有三角形来扩展节点。就像我只是在工作区中拖动了一些文件,而不是一个项目。第二个项目也是如此。
I have also created a new Project "Foo" from scratch in Xcode 4 and added it to my workspace, with the same result. I looked at Apple documentation and watched the 16 second video about a dozen times now, but cannot work out what I am doing wrong (if the problem is indeed in the chair and not in the computer).
我还在 Xcode 4 中从头开始创建了一个新项目“Foo”,并将其添加到我的工作区,结果相同。我查看了 Apple 文档并观看了 16 秒视频大约十几次,但无法弄清楚我做错了什么(如果问题确实出在椅子上而不是电脑上)。
回答by rayascott
I had this exact same problem. I think it stems from having another workspace already open referencing the project you want to add. I got it working by:
我有这个完全相同的问题。我认为这源于另一个工作区已经打开,引用了您要添加的项目。我得到它的工作:
- shutdown xcode completely
- double-click the workspace to launch Xcode and open just that workspace
- drag and drop the project file from the Finder
- 完全关闭 xcode
- 双击工作区以启动 Xcode 并仅打开该工作区
- 从 Finder 拖放项目文件
Worked fine. I have many workspaces all referencing an openssl project, and it seems to work OK when you only have one workspace open at a time in Xcode.
工作得很好。我有很多工作区都引用了一个 openssl 项目,当你在 Xcode 中一次只打开一个工作区时,它似乎可以正常工作。
回答by IncrediApp
Actually, I made it work without exiting Xcode. All you have to do is make sure the projects you want to add are closed, since Xcode is having trouble adding open projects to a workspace. So:
实际上,我在不退出 Xcode 的情况下就让它工作了。您所要做的就是确保要添加的项目已关闭,因为 Xcode 无法将打开的项目添加到工作区。所以:
- Close the projects you want to add
- In the Workspace window, choose "Add Files to MyWorkspace"
- Add the .xcodeproj file of the project you want to add
- 关闭要添加的项目
- 在工作区窗口中,选择“将文件添加到我的工作区”
- 添加你要添加的项目的.xcodeproj文件
回答by Emmy
I had the same problem. SO I just exit xcode, restart it. Then I can see the files under the project.
我有同样的问题。所以我只是退出 xcode,重新启动它。然后我就可以看到项目下的文件了。
回答by Himanshu Mahajan
Exiting Xcode completely and then double-clicking the .xcodeproj file to open the project.
完全退出 Xcode,然后双击 .xcodeproj 文件打开项目。
回答by Abhi Thakkar
It works but when you add an activity to the project than r.java
file is automatically removed and errors are coming.
它可以工作,但是当您向项目添加活动时,r.java
文件会自动删除,并且会出现错误。