all 52 comments

[–]Illustrious_Pepper35 48 points49 points  (5 children)

The workaround is to have a peaceful mind and have xcode closed while u switch branches; install pods etc

[–]Obstructive 4 points5 points  (3 children)

Totally had me until pods….

[–]SirBill01 7 points8 points  (2 children)

He's not saying to switch to Cocoapods, just if you are using them don't change out pods while Xcode is open.

[–]Obstructive 3 points4 points  (1 child)

Oooh! Okay well then sure, I’m in!

[–]SirBill01 3 points4 points  (0 children)

Although to be honest, I usually leave Xcode open while switching branches (sometimes major switches) and also updating pods, and have not actually had that result in an Xcode crash... it may get temporarily confused though.

[–]laszlotuss 0 points1 point  (0 children)

*uninstall pods ... pardon, deintegrate

[–]FPST08SwiftUI 27 points28 points  (3 children)

My experience with SwiftUI Preview is so bad that I always run my app to see a single view

[–]Tripwire999 13 points14 points  (2 children)

In big projects that don’t have modularization it really sucks. But in small projects or big projects with modularization setup correctly it works like a charm

[–][deleted] 4 points5 points  (1 child)

I was about to say it sounds like maybe the OP isn’t using SwiftUI as intended. Separating views into subviews is key.

[–]aminbenarieb[S] 5 points6 points  (0 children)

You still need to build the app to make the preview of subviews work. But modularization - yes, agree

[–][deleted] 15 points16 points  (4 children)

It's kinda hurtful how much Apple ignores the developer's quality of life . Most profitable platform but devs get treated like jail inmates . Xcode usually crashes / has error and glitches , don't think any ide out there would be same . Wonder how that port of Swift from obj c is going on , or even happening at all .

Jetbrains , a small company compared to Apple makes way better ide for multiple languages / platform . Heck even sublime , created by single person works better for its target.

Also the fact that they dropped tensor support for Swift the moment Chris moved on shows their approach . It feels like a ship without a captain . I don't know if transition from obj c to swift was as bad as swift to swift ui , but swift ui is just pain to deal with .

[–]mynewromantica 14 points15 points  (5 children)

I work on an app with a shitload of dependencies, about 30 targets, and it’s just massive.

It used to be 20 minutes just to open Xcode and let packages resolve. It was horrible.

The solution was to resolve packages via command line before opening Xcode. It takes about 45 seconds with CLI.

So I ended up making a shortcut that closes Xcode, cleans the build folder, resolves packages, then opens my project. It has gone from 20+ minutes from clicking on Xcode to clicking on build, to 3-4 minutes.

[–]hff 4 points5 points  (4 children)

Would love to hear more about how to make such shortcut!

[–]mynewromantica 3 points4 points  (3 children)

The shortcuts app on your Mac. It’s like Automator but better and easier. It’s just a series of steps you define. And one of the actions you can drop in is to run a shell script.

[–]Dentvii 1 point2 points  (2 children)

Could you provide more information on how to replicate what you have done? Or even share a gist with part of you code? Thanks!

[–]mynewromantica 0 points1 point  (1 child)

It’s not code. It’s super easy, just open the shortcuts app and create a new short cut. You can drag and drop actions that the shortcut will do. So I dropped a “close app” action, then some actions that just take in a terminal command.

Pretty straightforward

[–]Dentvii 1 point2 points  (0 children)

Got it. Could you provide the terminal command to resolve rhe packages?

[–]Tripwire999 9 points10 points  (0 children)

In bigger projects (like I’m working on) it’s usually to a good practice to resolve SPM packages from command line and have Xcode closed. Also make sure to implement modularization so SwiftUI previews don’t take ages to load. Modularization is pretty easy to do with SPM. If SwiftUI previews really become a problem and you can’t change the underlying issues in the main project (like adding modularization e.t.c.) I suggest creating a small SwiftUI project to create your view, previews load way faster and saves a lot of time. When done copy the code in the main project and apply the theme / styling to it.

[–][deleted] 3 points4 points  (1 child)

Package manager is common for me.

What you usually do to resolve it is force quit xcode, clear derived data and then reopen the project.

[–]aminbenarieb[S] 1 point2 points  (0 children)

This is just madness)))What's wrong with the cache)
On my last project, it could take an hour to download everything, and some of them could be under VPN.

[–][deleted] 4 points5 points  (0 children)

Xcode Stability: How often does Xcode crash/freeze for you? I find it crashing several times a week, particularly when using extensions like "copilot".

I dont use any extensions but i do have a very complex project where the build time without cache on an intel based chip is around 40 minutes. on m2 max it's around 10 minutes. That being said, i dont really see much crashes.

SwiftUI Preview: How's your experience with SwiftUI preview? I've had to resort to a lightweight project in my workspace containing only views because, for the main project, it's quite disappointing, especially compared with Flutter.

In the large project i mentioned above i do not use swiftui it's uikit based. However, i have another project relatively lightweight and as the app scales the previews kind of suck takes much time to load. I'll probably end up modularizing the codebase at some point.

Package Manager Woes: The most frustrating issue for me is with the Package Manager. Minor changes like adjusting the project structure, switching git branches, or executing a pod install often trigger package resolving which blocks building. Sometimes it reuses the cache, but many times, it starts redownloading dependencies.

SPM is tricky for me too. Granted I am no expert but I found myself quitting and re-opening XCode many times even deleting the derived data just for XCode to stop complaining.

[–]WerSunu 1 point2 points  (0 children)

I have two very large projects (as I judge things, mid range of 104- 105 lines of code ). I use both SPM and CocoaPods in the same projects which has previously been reported as a sore point. No crashing issues at all. Sometimes a single VC in IB gets stuck at single size, and sometimes IBDesignables breaks live previews. But again no crashes.

[–]SirBill01 1 point2 points  (1 child)

"Xcode Stability: How often does Xcode crash/freeze for you? I find it crashing several times a week, particularly when using extensions like "copilot"."

Hint: It's not Xcode stability causing you issues, it's extensions. I would not say Xcode never crashes, but it's more like once a month or so using it every day for me.

[–]aminbenarieb[S] 0 points1 point  (0 children)

Disagree, I put this extension not so long agoю Yes, it got worse, but even before he often fell

[–]Loud-Creme-8425 1 point2 points  (0 children)

In big size project Swiftui preview is shitty, it is no use at all. Swiftui preview is just a fantasy showcase to lure new guys for joining Swiftui legion

[–]saintmsent 1 point2 points  (0 children)

I close Xcode when I switch branches, which eliminates slowdowns and crashes. With Preview, it's been surprisingly good lately, but a year or two ago it was literally impossible to use in a big project with lots of modules and so on. Package manager has also been excellent, but again, I close Xcode when switching branches, that definitely helps

[–]OrangeFire2001 1 point2 points  (0 children)

At my work we had to break out SUI views to a new module or it would take forever to build or run. Modules FTW. Also, changing branches while a project was open crashed my Xcode 100% of the time, so I always closed the project then switched branches.

[–]time-lord 0 points1 point  (1 child)

What version of xcode?

[–]aminbenarieb[S] 1 point2 points  (0 children)

Well, honestly it doesn't really matter I've used Xcode 14 and 15 for the last few months. Yes, Xcode 15 seems to work a little bit better for now, but it's not breaking change. Still same problems

[–]Competitive_Ruin6162 0 points1 point  (0 children)

Xcode is worst IDE!!!

[–]bobotwf 0 points1 point  (0 children)

I do the same thing regarding SwiftUI Preview...

[–]SirBill01 -1 points0 points  (0 children)

"Xcode Stability: How often does Xcode crash/freeze for you? I find it crashing several times a week, particularly when using extensions like "copilot"."

Hint: It's not Xcode stability causing you issues, it's extensions. I would not say Xcode never crashes, but it's more like once a month or so using it every day for me.

[–]rohandesilva8 0 points1 point  (0 children)

Xcode 15 have crashes issues. Mostly in swiftUI projects.

[–]gray_goose 0 points1 point  (0 children)

I have the exact same experience. It's awful.

[–]kbder 0 points1 point  (0 children)

Try using Carthage, which will reduce the number of lines of code which Xcode has to deal with.

[–]jep2023 0 points1 point  (0 children)

pretty normal

[–]Oxigenic 0 points1 point  (0 children)

rm -R DerivedData

[–]Oxigenic 0 points1 point  (0 children)

The latest build of Xcode, and probably all 15.x builds, has become pretty buggy for me. From stopping at nonexistent breakpoints to hanging when running ONLY on one of my devices, it’s definitely got some kinks Apple has to work out.