简体   繁体   English

Xcode 12 如何将现有项目添加到工作区

[英]Xcode 12 how to add an existing project to a workspace

I cannot believe how hard this is.我不敢相信这有多难。 Perhaps because the word 'workspace' is overloaded by Apple and perhaps because the UI keeps changing every version.可能是因为 Apple 过度使用了“工作区”这个词,也可能是因为每个版本的 UI 都在不断变化。 For a newbie to iOS, Xcode and Apple it's a nightmare.对于 iOS、Xcode 和 Apple 的新手来说,这是一场噩梦。

  • I have Xcode 12我有 Xcode 12
  • I have created a project.我创建了一个项目。
  • I used File / save as workspace to create a workspace to (eventually) hold multiple projects.我使用文件/另存为工作空间来创建一个工作空间来(最终)保存多个项目。
  • Gave it a name.给了它一个名字。
  • I have another already created project (a static library) that I would like to add to this workspace.我有另一个已经创建的项目(一个静态库),我想添加到这个工作区。

I cannot for the life of me figure out how to do it.我一生都无法弄清楚该怎么做。 I see things for previous Xcode versions but those UI options are not present in 12.我看到了以前 Xcode 版本的东西,但这些 UI 选项在 12 中不存在。

In the end I want to have a workspace where I have a demo project that uses the static library project for Bluetooth LE communications.最后,我希望有一个工作区,其中有一个演示项目,该项目使用静态库项目进行蓝牙 LE 通信。 I will be spending 90% of my time developing the BT library so I want to be able to access the source of both projects.我将花费 90% 的时间来开发 BT 库,因此我希望能够访问这两个项目的源代码。

By the way, I am not using Storyboards.顺便说一句,我没有使用故事板。 Not sure if that makes a difference, but just in case!不确定这是否会有所不同,但以防万一!

Thanks for any help谢谢你的帮助

As far as I can tell it just doesn't seem possible.据我所知,这似乎是不可能的。
The only option seems to be to create the workspace in XCode 11 add the projects there then open in XCode 12唯一的选择似乎是在 XCode 11 中创建工作区,在其中添加项目,然后在 XCode 12 中打开

You can do this by你可以这样做

  1. Close the project to add in Xcode关闭要在 Xcode 中添加的项目
  2. Drag the existing.xcodeproj file (one you closed) from Finder to Xcode and drop it next to existing sources/projects in the workspace将现有的.xcodeproj 文件(您关闭的文件)从 Finder 拖到 Xcode 并将其放在工作区中现有源/项目旁边

Xcode settings are often painful for even seasoned developers.即使是经验丰富的开发人员,Xcode 设置也常常很痛苦。 And every update seems to break something.而且每次更新似乎都会破坏一些东西。

If you already have a Workspace (ie a .xcworkspace file) ready to go, all you need to do is:如果您已经准备好工作区(即.xcworkspace文件),您需要做的就是:

  1. Close your project关闭您的项目
  2. Open your Workspace打开您的工作区
  3. Go to File > Add Files to "<your_workspace_name>"...转到文件 > 将文件添加到“<your_workspace_name>”...
  4. Select your existing project选择您现有的项目
  5. Xcode will duplicate the references to your files, so you manually have to go to the Project navigator (shortcut: ⌘ + 1), select the duplicated references (they'll be at your Workspace's root) and delete them (select Remove Reference, not Move to Trash) Xcode 将复制对您文件的引用,因此您必须手动转到项目导航器(快捷键:⌘ + 1),选择重复的引用(它们将位于您工作区的根目录)并删除它们(选择删除引用,而不是移到废纸篓)
  6. Enjoy your Workspace!享受您的工作空间!

For good measure, select your scheme (most times it'll become available immediately, but sometimes you'll need to restart Xcode), build, and run your project to verify that everything went well.为了更好地衡量,选择您的方案(大多数情况下它会立即可用,但有时您需要重新启动 Xcode),构建并运行您的项目以验证一切顺利。

Verified in Xcode 13.在 Xcode 13 中验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM