HomeiOS DevelopmentSetting default actor isolation in Xcode 26 – Donny Wals

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 greatest adjustments is that new Xcode tasks will now, by default, apply an implicit most important actor annotation to all of your code. This primarily makes your apps single-threaded by default.

I actually like this modification as a result of with out this modification it was far too simple to unintentionally introduce a great deal of concurrency in your apps.

On this publish I might wish 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 should use the search function to make it simpler to search out the setting.

Setting default actor isolation in Xcode 26 – Donny Wals

New tasks can have this set to MainActor whereas present tasks can have this set to nonisolated. I extremely suggest making an attempt to set this to MainActor as an alternative. You’ll need to refactor a few of your code and apply specific nonisolated declarations the place you meant to make use of concurrency so you may need 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 features robotically inherit the calling actor’s isolation as an alternative of all the time operating on the worldwide executor with out being remoted to any actor. To get the outdated habits again you’ll be able to annotate your features with @concurrent. You’ll be able to be taught extra about this in my publish about Swift 6.2’s adjustments.

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

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

When you’re unsure which one you must 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

- Advertisment -
Google search engine

Most Popular

Recent Comments