What's Coming to Xcode 16🔥

At this year's WWDC, Apple unveiled new shiny✨ features for Xcode 16. With Swift Testing already exciting iOS Developers, Swift 6 and all the new features look promising.

🩷
I love sharing free content to help fellow developers. Your support means a lot! Please follow me on LinkedIn, GitHub, and Twitter.
Let's connect and grow together! 🚀

Code Completion

Apple Intelligence has arrived in force and will be implemented in Xcode 16. The new code completion is trained explicitly for Swift and Apple SDKs.

It also uses the surrounding code context (function names) and your comments to provide a suggestion faster (similar to what already happens with GitHub Co-Pilot).

Swift 6

One significant improvement with Swift 6 is providing concurrency safety guarantees. It can now warn about data races detected during runtime into compile-time issues.

This improves accuracy and safety. You can also add these features to your project to safely update to Swift 6.

How to Incrementally Switch to Swift 6

⚠️
To make these changes, you need to use Xcode 16.
  1. Go to your Project/ Build Settings
  2. Search for Upcoming Features on the 🔎 filter
  3. You can turn on each feature one at a time

Check the following example of the project that was presented in the session "What's new in Xcode 16" on WWDC 24 [2]:

⚠️
You will see warnings on your project during this time.

How to Transition Fully to Swift 6

When you're ready, you can just set the language version for your project to Swift 6.

Here's how:

  1. Go to your Project/ Build Settings
  2. Under the Option Swift Compiler - Language/ Swift Language Version
  3. Choose Swift 6

The previous warnings will now appear as errors during build time.

Explicit Modules

Xcode 16 also includes significant improvements to builds. At this year's WWDC, Apple introduced explicit modules.

⚠️
For Objective-C apps, the Explicit Modules is on by default and you can opt-in if you're using Swift.

What Does it Improve?

  • Improved Parallelism
  • Better Diagnostics
  • Faster Debugging

How to Turn On Explicit Modules

  1. Go to your Project Build Settings
  2. Search for Explicit Modules
  3. Click on the option and turn it on.

How Does it Work

With explicit modules, Xcode now splits up your compilation unit into 3 phases:

  1. Scan
  2. Build Modules
  3. Build Original Code

Before Xcode 16, the first two phases were filed implicitly, which means that you couldn't see what was happening underneath.

This allows you to get a more detailed breakdown of the build since the scan phase and build modules are split into different commands when you build your project.

Instruments

This tool may not be new, but new updates are coming to Xcode 16. Now, it will be possible to see a Flame Graph, which is a representation of a weighted percentage of time they took in the trace.

Here's the representation of the Flame Graph during WWDC's Xcode 16 session:

As you can see by the bottom part of the screen, several colors indicate which function takes the most of the execution time (with the color 🟪 being the processes that take the most time).

In the case of this session, you can see that the only interesting process that is taking a lot of the execution time is Asset.load().

If you look at the right pane, it is being called by a closure inside the SwiftUI view and loaded in the Main Thread.

Using the Flame Graph, a performance issue could be detected and fixed by sending this load to a background thread.

Why is a Flame Graph Helpful

A Flame graph shows which functions take the most time during execution, which can help improve code performance.

It's beneficial for call-trees, like the case stated above.

Conclusion

With excellent sessions from WWDC, it's paramount for an iOS Developer to check what's coming to the editor we use the most. Even though Apple Intelligence was the most anticipated feature, Xcode 16 has many improvements.

What is your favorite feature that is coming to Xcode 16?

References

  1. Platform State of the Union: WWDC 24
  2. What's new in Xcode 16