r/iOSProgramming • • Oct 03 '21

Discussion PSA for everyone who just now started learning SwiftUI in Xcode 13 - downgrade to 12.

With the release of Xcode 13 I thought it would be a good idea to rewrite some stuff in SwiftUI since it's way easier to put under svn/git than storyboards.

Whilst building and testing was so slow that development was close to impossible, one ViewController with 10 elements was literally impossible to render since RAM usage went up to 20gb and Xcode kept spawning new swiftui-related processes 6-10GB in size.

Similar issues on both intel as well as arm machines.

I found a few related threads on reddit and after downgrading to Xcode 12.x, the seemingly illegal ViewController rendered just like it should without frying my laps.

I still think SwiftUI is way too inefficient to use in a professional manner since it seems to slow down the workflow to like 3x the time it would take in storyboards but at least with 12.x it's somewhat usable again.

So if you have just started with SwiftUI because you need it, skip Xcode 13 until Apple gets their shit together

EDIT: And no it's not about the stupid derived data or "Clean Build Folder", I literally have shell scripts because I do this like 10 times a week

6 Upvotes

13 comments sorted by

0

u/[deleted] Oct 03 '21

[deleted]

2

u/Reiszecke Oct 03 '21

>implying I don't do this every 6 hours

7

u/[deleted] Oct 03 '21 edited Oct 03 '21

Seconded. Indeed, as software developers, one should not just shrug their shoulders and make conclusions like "SwiftUI + Xcode 13 sucks". Why is it behaving that way? I mean, specifically? That's what you do as a software engineer, because lots of little issues like this will pop up constantly.

You need to understand the tools that you're using and how they operate on a fundamental level. What's Xcode doing when you hit "build"? It's invoking a build system that in turn invokes compilers and linkers; searching pre-defined paths for header files and dylibs, skipping compilation on cached object files, setting build and link flags according to your project settings.

So why is it acting "weird"? Is it your system? Your configuration? Or is it actually on Apple's end? And if so, why?

These aren't unreasonable things to ask a software engineer to understand; indeed, it's in the name "engineer."

EDIT: for context, I live in Zsh, manage deps with brew, and typically use CMake with C/C++ projects. You get very familiar very quickly with DYLD_LIBRARY_PATH, PATH, CPATH, etc. and how easy it is for mismanaged environment variables to screw up your build process.

3

u/Reiszecke Oct 03 '21

You spent so much time writing all this down based on the false premise that this in fact solves the issue for me, it does not.

0

u/[deleted] Oct 03 '21

[deleted]

-2

u/[deleted] Oct 03 '21

At first, but once you "grok" this stuff, figuring out issues like this becomes way, way easier. You go from bashing your head against the wall, stuck until you stumble on the one SO post with an answer, to saying "ah, I bet X is making Y behave like this, so I need to do Z." I mean, that's what u/bcgroom did, I'm assuming.

3

u/bcgroom Oct 03 '21

Actually I’ve just switched between Xcode versions enough to figure out it’s a problem ¯_(ツ)_/¯ The iOS build toolchain is very complicated, I’d be surprised if anyone fully understood it.

14

u/morenos-blend Oct 03 '21

At this point it’s laughable that Xcode doesn’t do that automatically, especially after updating

2

u/_Pho_ Oct 03 '21

I think they're scared of breaking someone's existing config/environment; but yeah I totally agree

1

u/editor_of_the_beast Oct 03 '21

So Xcode can’t clean up it’s own garbage, which means that it is Xcode’s fault

1

u/bcgroom Oct 03 '21

Which is why I said Xcode 13 as the post states there is an issue with this version specifically. Of course it’s Xcode’s fault and they should improve it.

1

u/[deleted] Oct 03 '21

[removed] — view removed comment

5

u/Reiszecke Oct 03 '21

Around 2019 I was 2 Xcode versions behind until I actually needed a new feature since I'm so fed up with Xcode releases. I honestly don't understand why Apple puts them out of beta so early when they are clearly unfit.

4

u/[deleted] Oct 03 '21

[removed] — view removed comment

1

u/Reiszecke Oct 03 '21

By far the worst, yet claiming to be the best.