Enabling Concurrency warnings in Xcode 15 – Donny Wals

If you want to make sure that your code adopts Swift concurrency as correctly as possible in Swift 5.9, it’s a good idea to enable the Strict Concurrency Checking (SWIFT_STRICT_CONCURRENCY) flag in your project.

To do this, select your project’s target and navigate to the Build Settings tab. Make sure you select All from the list of settings that is shown (Basic is the default) and type Strict Concurrency in the searchbar to find the Strict Concurrency Checking build setting.

The screenshot below shows all the relevant parts for you to see:

Screenshot of the strict concurrency checking settingsScreenshot of the strict concurrency checking settings

The default value for this setting is Minimal which boils down to the Compiler only checking explicit Sendable annotations amongst other things. This setting is the least restrictive and enforces as little of Swift Concurrency’s constraints as possible for the time being.

You can bump your checking to Targeted which will enforce Sendable and actor-isolation checks in your code, and it will explicitly very that Sendable constraints are met when you mark one of your types as Sendable. This mode is essentially a bit of a hybrid between the behavior that’s intended in Swift 6, and what’s allowed now. You can use this mode to have a bit of checking on your code that uses Swift Concurrency without too much warnings and / or errors in your current codebase.

With Complete you will get the full suite of concurrency constraints, essentially as they will work in Swift 6. Personally I would recommend enabling this setting for new projects where you want all of your code to be properly checked immediately. In an existing codebase this mode might be a little too strict, but on the other hand it will flag lots of things that will be mandatory in Swift 6.

Latest articles


Related articles

Leave a reply

Please enter your comment!
Please enter your name here