Enabling Concurrency warnings in Xcode 14 – Donny Wals


If you wish to guarantee that your code adopts Swift concurrency as appropriately as doable in Swift 5.7, it is a good suggestion to allow the Strict Concurrency Checking (SWIFT_STRICT_CONCURRENCY) in your undertaking.

To do that, choose your undertaking’s goal and navigate to the Construct Settings tab. Ensure you choose All from the checklist of settings that’s proven (Fundamental is the default) and kind Strict Concurrency within the searchbar to seek out the Strict Concurrency Checking construct setting.

The screenshot beneath reveals all of the related components so that you can see:

The default worth for this setting is Minimal which boils right down to the Compiler solely checking express Sendable annotations amongst different issues. This setting is the least restrictive and enforces as little of Swift Concurrency’s constraints as doable in the intervening time.

You may bump your checking to Focused which is able to implement Sendable and actor-isolation checks in your code, and it’ll explicitly very that Sendable constraints are met if you mark one in every of your varieties as Sendable. This mode is basically a little bit of a hybrid between the conduct that is meant in Swift 6, and what’s allowed now. You need to use this mode to have a little bit of checking in your code that makes use of Swift Concurrency with out an excessive amount of warnings and / or errors in your present codebase.

With Full you’ll get the total suite of concurrency constraints, primarily as they are going to work in Swift 6. Personally I might suggest enabling this setting for brand new tasks the place you need your entire code to be correctly checked instantly. In an present codebase this mode is perhaps a bit of too strict, however alternatively it would flag numerous issues that will probably be necessary in Swift 6.

Leave a Reply