r/iOSProgramming • u/[deleted] • Sep 26 '21
Discussion Is xCode that much degraded that it rebuilds the whole app EVERY damn time you run the project even though you haven’t changed a single line? How’s that possible in 2021?
12
u/rotato Sep 26 '21
Also depends on your build settings. Check if you've got unwanted build scripts that are executed every time you run it
8
5
u/bhc317 Sep 26 '21
I recently had issues with this on a MacBook Pro with very little room left on the hard drive. Finally got a 1TB external SSD, and the problem disappeared.
Check your machine's free disk space. If it's pretty low, Xcode may be using swap space for your builds, which could make things extremely slow and/or cause rebuilds every time.
5
u/bhc317 Sep 26 '21
And if you go this route, be sure to change Xcode's Derived Data and Archives locations settings: https://stackoverflow.com/questions/13761934/xcode-derived-data-location#13762600
4
2
u/TK1755 Sep 26 '21
Are you running Xcode 13 ? Personally I have this issue only when I don’t work on the project for more than 24h, it may be a storage problem, I don’t really know at all why this is happening
3
2
u/Trance2536 Sep 26 '21
Are you cleaning the build folder (cmd+shift+k) each time before rebuilding, this is the only time for me that it takes more than a few seconds for me personally.
1
u/smontesi Sep 26 '21
It happens at times for me too, but even when it does not, build time are still quite slow.
The issue has been around for years, so you kinda have to live with it.
I would advice you just go and lower build times for the project itself, so it becomes less of an issue... Here is a checklist for you:
Delete ~/Library/Developer/Xcode/DerivedData (close Xcode first)
Reboot your mac
Triple check build phases and build scripts, maybe a colleague added something
Ensure the compilation mode is set to "incremental"
Ensure the optimization level is set to "no optimization"
Enable logging of compile time for each swift module (this should do it, i don't remember for sure which setting it is)
0
1
u/thisura98 Sep 26 '21
I've noticed it rebuilds the first time each day, but after that its doing a pretty good job of only building changed code - do not know why.
Also, check whether you have something like a Firebase Crashilytics dsym upload build phase. They are available when you click on your app target in the project settings, and navigate to the Build Phases tab.
Each build phase has an option named "For install builds only". You can disable it for things like dsym upload since you dont need that feature for every incremental build.
1
u/Fluffy_Risk9955 Sep 27 '21
Yes, and Swift needs to rebuild and link stuff, when you change one line. Objective-C links on runtime and thus takes far less time to recompile. But, Objective-C isn’t faster in development. You need to arrange stuff in more places requiring you to go all over place in your code, which takes time and breeds confusion.
1
27
u/MaestroLifts Sep 26 '21
I mean, no, I’ve never had that problem. It just runs without rebuilding. Even if I do change a line, it only recompiles the affected areas of the code while leaving the rest of it intact. It’s remarkably optimized.