Description
This is a follow up to #832 with details on a possible solution.
The story:
We've all been aware since the very beginning that debugging projects that include pre-compiled (Carthage) frameworks has been very broken. As Apple promised that this got better in Xcode 7.2, a few people on #832 did the test (I still can't test it myself because reasons), and realized that it's still just as broken.
Upon further investigation, looks like DWARF files use absolute paths everywhere, based on when they were compiled.
As you can see, they're full of paths to the derived data directory of the user who built the framework.
Needless to say, it's not just a problem because we can't share these frameworks with other devs, but also for personal use, given how extremely frequent one must clear derived data to work around Xcode.
This is why I finally decided to file a radar, because after two years this is still utterly broken: http://www.openradar.me/23551273.
Of course, I don't expect this to be fixed (ever?), so we need a solution.
Proposed solutions
Abandon Carthage
:
We can go back to working like animals, adding all dependencies as submodules. However, this just doesn't cut it, Apple, when will you see this?
- Swift compilation times are already insanely long. Khan Academy was taking 15 minutes for a clean build before I changed
Swift
dependencies to pre-compiled frameworks. - Nested dependencies: this solution would not be feasible if you have multiple dependencies that depend on a common one. This is one of the reasons why
CocoaPods
was born:
CocoaPods
(Yeah, I went there, but I wanted to analyze this too)
- Obviously deals with the dependency graph problem.
- It's invasive and very complex, which is why Carthage was born.
- It's still not what we want for development. It's the year 2015, we want to be able to distribute built dependencies and compile our applications in the order of seconds, not minutes.
Work around it in Carthage
I have an idea that might work. Distributing pre-compiled frameworks would still be broken (so --no-use-binaries
would have to be the only option), but we'd be able to compile once and forget:
xcodebuild -sdk $SDK -project $PROJECT -configuration Release -scheme $SCHEME ONLY_ACTIVE_ARCH=NO SYMROOT=$DIR/Carthage/Build/$PLATFORM/$FRAMEWORK clean build
Notice the SYMROOT
parameter. In my tests compiling with this option correctly sets the absolute paths in the DWARF
to that path, instead of derived data! Which means that debugging should hopefully work.
With this, the recommended approach would be to .gitignore
Carthage/Build
, and using carthage update
to build the frameworks.
Once we do that, one can freely clear derived data, and that won't affect the compiled frameworks.
It's still not clear that this is enough, though. It's possible that we'll also need OBJROOT
, and putting everything in Carthage/Build
:
Prolonged sigh.