The Correct Way to Add Existing Project to Workspace

Why

I run into an awesome open source framework called Eureka, an elegant iOS form builder in Swift 2. I reckoned this might be quite helpful in my project, so I read from Apple documents on how to import other project as a framework, and I got the idea of workspace, where I could work with multiple projects.

Problem

I “accidentally” find an option “Save As Workspace” under “File” in menubar, this way I can convert my project into a workspace. Then I read Adding an Existing Project to a Workspace from Apple, and successfully add Eureka into the newly created workspace. I think this should work because I explicitly followed Apple’s instruction, but when I import Eureka in a swift class, Xcode gives me an error “no such module ‘Eureka’ “. Googling with key words “Xcode workspace no such module” only gives suggestions like adding framework search path, but those don’t work on me, as the error remains. Frustrating, especially when google doesn’t help.

Solution

I look here and there into target settings, and find an entry “Link Binary With Libraries” a little promising, so I add Eureka under this entry and try to build again, finally, Xcode builds successfully.

The problem is solved, but I still wonder why Apple doesn’t give this information? I try to google with the keywords “Xcode workspace Link Binary With Libraries“, another keyword appears several time in search results–dependency. Another googling with keywords “Xcode workspace dependencies” leads me to Working on Related Projects. Turns out Apple does give instructions, but falling into another section, a section that contains no keywords that can explicitly describe my needs.

Conclusion

So the correct way to add an existing project to a workspace is:

  1. Convert current project into a workspace: File -> Save As Workspace,
  2. Drag and drop the framework Eureka.xcodeproj into the root of project navigator in Xcode , same level as current project,
  3. Add Eureka.framework under target -> Build Phrases -> Link Binary With Libraries.

And I learned

  1. There are times Apple thinks and speaks differently from normal people (I am pretty normal, I guess),
  2. There are times Google doesn’t help…

Leave a Reply

Your email address will not be published. Required fields are marked *