I recently checked out a fresh version of our iOS app from git and built from command line via xcodebuild
. I then built a second time using the exact same command, while making no changes to files in the repo whatsoever (not even opening them).
I expected the second build to take no time at all, but it actually took longer than the first:
user$ time xcodebuild -sdk 'iphonesimulator' -scheme 'DemoApp' -configuration 'Debug' -target 'DemoApp' build > /dev/null
real 5m45.849s
user 0m15.270s
sys 0m5.640s
user$ time xcodebuild -sdk 'iphonesimulator' -scheme 'DemoApp' -configuration 'Debug' -target 'DemoApp' build > /dev/null
real 6m8.858s
user 0m12.904s
sys 0m4.198s
If I do builds in xcode with no changes, it builds and runs in a matter of seconds.
Here are things I've tried to get incremental builds on command line:
- I tried adding
-derivedDataPath ~/Library/Developer/Xcode/DerivedData
, but got the same results. - I've added the
-incremental
flag to other Swift arguments. - I've turned off all shell scripts and ensured no files have changed between builds
Does xcodebuild
not support incremental builds? Is there a way to figure out why this is happening?
I'm using the latest Xcode and the new Xcode 10 build system. Most of the code is in swift if that makes any difference.
Edit: changing back to the old build system builds incrementally via xcodebuild
in under 30 seconds.
Update:
The way I'm testing this: I have a Jenkins job that will clone the repo and do a hard clean: running xcodebuild clean and deleting the build directory and and derived data directory by hand just in case. Then it does a build. Then it makes no changes and does a build again. The second build is the one I'm timing.
-target
? Target shouldn't be there since you are using scheme. – UnsocialCompilation Mode
set toWhole Module
. – Unsocial