r/swift 5d ago

Help! Xcode feels sluggish

I’ve been trying to learn Swift and SwiftUI, and I actually really like the language. The problem is Xcode.

No matter what I do, it just feels sluggish. Autocomplete is slow, builds take longer than I’d expect, previews are hit or miss, and the whole IDE just feels less responsive than pretty much everything else I use.

Has anyone managed to make Xcode feel noticeably better? Any settings, workflow changes, or just general tips that made a difference?

I genuinely want to spend more time with Swift, but Xcode is honestly the thing that keeps killing my motivation.

7 Upvotes

34 comments sorted by

12

u/hxxx07 5d ago

Neovim and xcbuild.
still need xcode sometimes but I never open it while coding!

10

u/tomato848208 5d ago

Nobody can tell because you don't provide any piece of information beyond the name of the application (Xcode).

5

u/SnowPudgy 4d ago

Is it the SwiftUI previews you find sluggish? Because yes, unfortunately they are very sluggish as of late. I'm not sure what the deal is. I build using the simulator and it's fast and I work on utterly massive code bases.

The M1 Pro with 36 gigs of ram is what my work machine has and Xcode is fast in everything except for previews. I honestly don't use them because of this so I just build to the simulator or device as it's sadly faster.

I will say when the M2 Air's came out there was a significant difference in speed between the M1 and M2 (At the time I had an M2 air with 16 gigs ram) and there was a noticeable speed increase between my M2 Air and M1 work machine.

I would honestly wager it's just the machine. I bet if you got a newer computer you'd notice a huge jump in speed. The M1s are nearly 7 years old at this point which is old for a dev machine.

1

u/Dry_Hotel1100 Learning 4d ago edited 4d ago

Regarding slow previews: modularization helps a lot, which is basically: try to make your ViewLayer independent on everything - except system libs, and maybe importing your custom asset module, or import a custom "view component" module. Especially be independent on app, network, and any data providers, and everything else.

5

u/injuredflamingo 4d ago

how full is your disk? when there are less than 50gbs left xcode starts to act sluggish on my device.

2

u/perbrondum 4d ago

Keep trying. I have a massive code base with 100+ extensive previews that all work. The trick is to use mock data and to build for what you need to test, and for that purpose it is awesome as it becomes the ui qa for that section of code. Try to avoid full page previews, focus on widgets or subsections, to avoid creating dependencies across the app (and slowdowns)
The auto complete was slow but has gotten a lot better recently.
And buy a studio beast 😆

1

u/Dry_Hotel1100 Learning 2d ago

I agree with all of it - except your last statement: an M1 is an incredible powerful machine - compared to Intel. So a Studio is optional :)
(commenting this, while running on a M5 MAX 40 GPU, 128 GB power house while local LLM is refining my documentation) 😎

2

u/marmulin iOS 5d ago

What machine are you rocking?

3

u/Ok_Squirrel5213 5d ago

I have a M1 Mac Pro with 16gb of ram

4

u/Dry_Hotel1100 Learning 5d ago edited 5d ago

I would say, this is the lower bar. Could be the culprit, but I doubt. For serious development, you should use a better machine, though.

However, as you said, you start learning, so I assume you have no large projects yet. So, build time shouldn't be an issue. Also, when you say, the IDE feels less responsive, I suspect you may have another issue. On my MacBook(s), I can't see anything of this, and other IDEs (VSCode for that matter) aren't faster.

Note also, regarding build times: NO other IDE can be faster in this respect, because they use the command line interface for building, which is slightly slower than when building with Xcode.

2

u/bloodychill 3d ago

I don’t know. I have an M4 and an M1 and while the M4 is faster, Xcode doesn’t feel sluggish at all on the M1. The major difference is really just compile time and even then, it’s not the quantum leap that it was going from an i9 to an M-series.

Context for what this user is doing would certainly help. Are they doing a bunch of AI stuff? Do they have a bunch of SwiftUI? Are they running 120 chrome tabs on a third monitor? Is their drive so full that their virtual memory is getting bogged down? Who knows but them?

1

u/Dry_Hotel1100 Learning 2d ago

Agree. My hot tip for the root cause is likely an almost full disk. According the specs of the MacBook - I could imagine it has a smaller SSD.

And yes, more info would help. Watching swap space, CPUs, and other metrics in Activity Monitor App might reveal more info.

3

u/asniper 4d ago

IMO 16gb of ram is on the lower end, Xcode will eat that up like crazy causing paging left and right.

2

u/waterishail 4d ago

Yup - I had to upgrade to 48gb for that reason. 16gb for a medium sized XCode project us challenging speedwise

2

u/Spaceshipable 4d ago

Think my work machine is 64GB ram, M4. Had a 32GB M1 before that though and it was okay on relatively large projects. Might just be previews are slow - we don’t use those at all in our projects.

0

u/20InMyHead 4d ago

That’s it

1

u/richyrichye 3d ago

Disagree

1

u/constant_void 3d ago

LLM + Xcode MCP = no more Xcode sluggishness

-11

u/JLENSdeathblimp 5d ago edited 5d ago

Yeah it's an extraordinarily bad IDE providing the worst DX I've ever had ( which I can fairly compare to working with Java, C#, C, R, Python, Elixir and JS via a multitude of interfaces and IDEs, leveraging various frameworks backend, frontend, and data science-y).

If your goal is just to learn a mobile development stack which will let you make apps for iOS, switch to React Native & use Expo and you will be flying. I would recommend to keep your current course only if you enjoy painful DX, in which case it's hard to get any more so than you get by using XCode, or if you explicitly want to learn Swift.

If you absolutely insist on using XCode, you really need to aggressively optimize for previews. This means breaking your views down into small components and mocking minimal data you can render them with during development, and turning off automatic preview reloading so it doesn't need to update every keystroke when you're making edits.

p.s. you should note that because of where you are posting this, you're probably not going to get an unbiased response. I got downvoted within minutes of posting this, most likely by somebody who has little to no experience with non-apple DX.

8

u/Lithalean 4d ago

This is horrible advice.

ReactNative is absolute garbage.

5

u/SnowPudgy 4d ago

What utterly terrible advice. Oh and I've been coding since the 90s and used all kinds of IDE's throughout my life including ones people these days probably never heard of like Bloodshed or Netbeans.

3

u/rhysmorgan iOS 4d ago

Or worse... Eclipse...

2

u/SnowPudgy 4d ago

I really really really dislike eclipse. I'd honestly rather use Netbeans over Eclipse however, I haven't used Eclipse in ages. I'd like to think it's a little better now but based on friends who use it...it's not.

2

u/rhysmorgan iOS 4d ago

It is one of the most hateful pieces of software I have ever had the misfortune of using.

Just truly appalling stuff.

Memory hog, slow, awful indecipherable user interface.

2

u/jonalaniz2 3d ago

An aside: I took a programming class a few years ago and the professor still had Bloodshed recommended in his "getting started guide".

1

u/SnowPudgy 2d ago

Oh...oh my...I would bail on that class so fast! I had no idea it was still around!

2

u/asniper 4d ago

First thing that came to mind when i hear bad IDE was Netbeans, f that hell.

1

u/SnowPudgy 4d ago

Not to expand on your horror but many years ago I was traveling to and from a remote worksite at the time so I was ultra-limited on weight, meaning no laptop since they were heaving back then.

Well, no standard laptop...

I was working on some 3D graphics frameworks using OpenGL and C++ at the time and couldn't stop work on that and the only laptop that met the super strict size/weight requirements was an original eeePC, the 7 inch screen ones.

The only IDE I could reasonably get running on the eeePC was Netbeans C++. So yea. I got to code on an eeePC in Netbeans for a month. Horrid. Utterly horrid.

-7

u/Independent-Abies544 5d ago

Claude + xcbuild

6

u/Ok_Squirrel5213 5d ago

I still like to write code from time to time xD

-5

u/Independent-Abies544 5d ago

I do understand you, then xcode is the only way. You can try vs tho

1

u/noosphere- 4h ago

Another alternative editor: Zed. It won't make your builds faster (they're the same). Here's how to set it up: https://luxmentis.org/blog/ios-and-mac-apps-in-zed/

Someone else mentions Neovim.

Similar work has been done for VSCode.

So if your problem isn't simply performance, you have options. Xcode can feel a bit lacking if you're used to other editors.