Carthage is a great dependency management tool for both Swift and Objective-C. However, finding the right workflow adopt when developing with carthage can be a bit tricky.
This is especially true if you are building your own frameworks and would like to use carthage to manage them in your application project.
Suppose the following scenario.
You have a
cat-names framework and a
dog-names that you wrote yourself and
are building a
After hard days of work you have now reached version
v0.1.0 of both
Dog-names.framework. It’s now time to build you app, so in the app’s
Cartfile you specify
git "file:///Users/blender/Code/cat-names" ~> 0.1.0 git "file:///Users/blender/Code/dog-names" ~> 0.1.0
Nice! Now you
carthage bootstrap, link the framework, add the
(from now on referred as Carthage Copy Framework) phase and develop you app.
As you develop the
iPuppyApp application you find a bug in
Unfortunately even if the sources are in
Carthage/Checkouts Xcode won’t Open Quickly
nor Jump to definition. No break points for you.
The Carthage/Checkouts way
You decide to add to your project the
CatNames.xcodeproj found in
- removing the old library from “Linked Libraries and Frameworks” (because that’s the one in
- adding the new library auto-discovered from the products by Xcode after you dragged in
- changing the Carthage Copy Framework to copy
CatNames.frameworkas a target dependency
I will call this the Linking Dance.
Great! You build, debug, find the bug and make the change to the library and surprise surprise… the
change you just made to the library is not under version control. You can’t even
Depending on how used you are to this dance, you have now just wasted 3 to 5 minutes, and don’t even have your changes under version control. Imagine if you project had a longer list of in house dependencies. This can easily take half an hour so to set up and tear down afterwards.
The symbolic link way
The right thing do to here is actually to:
- turn the
Carthage/Checkouts/cat-namesdirectory in your app’s project directory into a symbolics link to where your sources under version control are. This will ensure that any change that you make is under version control.
- turn the
Carthage/Builddirectory in your framework into a symbolic link to your app’s project
Carthage/Builddirector. This will ensure that both your framework and your app can access all other frameworks build with carthage.
then do the the Linking Dance.
At this point your productivity is below zero and you’re wondering what got you into software development in the first place.
But don’t despair, I’m here to help.
I have put together develop.rb a ruby script that will do and undo all of this for you without touching your project.
It will create another copy of you project called
The script assumes that both the source of our frameworks and your app are in the same parent directory like the following:
. .. |- cat-names |- dog-names |- iPuppyApp
[RepositoryMap] cat-names = CatNames dog-names = DogNames
Note that for the purpose of Rome this is not a valid Romefile, but it will do for the script
Run the script from the same directory where your
TARGET_NAME="iPuppyApp" ./develop.rb start cat-names dog-names
Get help by running
I am not a ruby developer and this is the first time I use ruby so feel free to suggest improvements.
Thanks to @netbeatwork who inspired much of the Symbolic Link method