Setting default actor isolation in Xcode 26 – Donny Wals


With Swift 6.2, Apple has made a a number of enhancements to Swift Concurrency and its approachability. One of many largest modifications is that new Xcode initiatives will now, by default, apply an implicit important actor annotation to all of your code. This basically makes your apps single-threaded by default.

I actually like this alteration as a result of with out this alteration it was far too straightforward to by accident introduce a great deal of concurrency in your apps.

On this put up I would prefer to take a fast take a look at how one can management this setting in addition to the setting for nonisolated(nonsending) from Xcode 26’s construct settings menu.

Setting your default actor isolation

Open your construct settings and search for “Default Actor Isolation”. You need to use the search function to make it simpler to search out the setting.

Setting default actor isolation in Xcode 26 – Donny Wals

New initiatives could have this set to MainActor whereas present initiatives could have this set to nonisolated. I extremely advocate attempting to set this to MainActor as a substitute. You have to to refactor a few of your code and apply specific nonisolated declarations the place you supposed to make use of concurrency so you may wish to allocate a while for this.

MainActor and nonisolated are the one two legitimate values for this setting.

Enabling nonisolated(nonsending)

One other function that is launched by Swift 6.2 is nonisolated(nonsending). This function makes it in order that your nonisolated sync capabilities routinely inherit the calling actor’s isolation as a substitute of at all times operating on the worldwide executor with out being remoted to any actor. To get the outdated conduct again you may annotate your capabilities with @concurrent. You’ll be able to be taught extra about this in my put up about Swift 6.2’s modifications.

You’ll be able to activate nonisolated(nonsending) in considered one of two methods. You’ll be able to both allow the function flag for this function or you may activate “Approachable Concurrency”.

WIth Approachable Concurrency you’re going to get nonisolated(nonsending) together with a few different modifications that ought to make the compiler smarter and extra smart in relation to how concurrent your code will actually be.

When you’re undecided which one it is best to use I like to recommend that you just go for Approachable Concurrency.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles