Xcode projects depending on each other?

Hello,


I've been struggling with a problem now for quite a while and was hoping for some advice.


I have an Xcode workspace. There are three projects in it: A, B, and C.


A is a Swift project that produces a framework. B relies on A (as well as a system framework, libedit), and produces a framework as well. C is a very simple Objective-C application that depends on the frameworks A and B. (The idea is that A is the primary 'product'; a user could stick the framework in their own app; B and C are for a demo app that shows off A.)


Now, the way I'm setting up these dependencies is that for projects B and C, I go to the project settings --> General tab --> "Linked Frameworks and Libraries" section, and then add my dependencies (frameworks and/or system libraries). This works great as long as I'm at my own computer.


The problem is this: my workspace and projects live in a Git repository. When I check out the repository on a different computer and open the workspace and projects in Xcode, the framework 'links' are broken. If I try building my project, B and C can't find the frameworks they depend upon, even when A builds successfully. I have to go to the project settings, remove them from "Linked Frameworks and Libraries", and re-add them before things will start building again.


This is pretty frustrating for me, since the project is publicly available and I'd like interested people to be able to clone it, open the workspace in Xcode, and just press the Build button and have things work. Am I configuring my projects incorrectly? Is there best practice for how I should be doing this? Any help or tips would be greatly appreciated.


I'm currently using Xcode 8 beta, but this has been a problem with every version of Xcode 7 as well.


Thanks in advance,

Austin

Accepted Reply

Xcode kinda prefers that you put each project in a separate repository. It used to be possible (and probably still is, though I haven't tried recently) to use the git command line to force multiple projects into a single repository, but it probably isn't worth it.


Next, if you want to auto-clone dependent repositories when a client clones the "main" repository, then you need to have the dependent projects/repositories in the workspace of the "main" repository. If you're using an explicit workspace, then you need the workspace to have its own repository, so that this can be the "main" one. (Again, you might be able to mitigate the repository bloat by putting multiple projects in a single repository, but you're going to have to work at that.)


In your current scenario, you might be better off by putting everything into a single project, with 3 targets for the various pieces. The whole dependent auto-clone thing is really for (say) combining 3rd party projects from multiple sources, rather than what you're doing here, where it really all goes together. If you do it this way, there's only one repository for a client to get.

Replies

Xcode kinda prefers that you put each project in a separate repository. It used to be possible (and probably still is, though I haven't tried recently) to use the git command line to force multiple projects into a single repository, but it probably isn't worth it.


Next, if you want to auto-clone dependent repositories when a client clones the "main" repository, then you need to have the dependent projects/repositories in the workspace of the "main" repository. If you're using an explicit workspace, then you need the workspace to have its own repository, so that this can be the "main" one. (Again, you might be able to mitigate the repository bloat by putting multiple projects in a single repository, but you're going to have to work at that.)


In your current scenario, you might be better off by putting everything into a single project, with 3 targets for the various pieces. The whole dependent auto-clone thing is really for (say) combining 3rd party projects from multiple sources, rather than what you're doing here, where it really all goes together. If you do it this way, there's only one repository for a client to get.

Thanks for the detailed reply, Quincey! I will probably end up trying the "three targets in one project" approach.