Once you create a brand new Swift Bundle in Xcode 16, the Bundle.swift
contents will look a bit like this:
// swift-tools-version: 6.0
// The swift-tools-version declares the minimal model of Swift required to construct this bundle.
import PackageDescription
let bundle = Bundle(
title: "AppCore",
merchandise: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "AppCore",
targets: ["AppCore"]),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "AppCore"
)
]
)
Discover how the bundle’s Swift instruments model is about to six.0. In order for you your mission to reference iOS18 for instance, you are going to have to have you ever Swift instruments model set to six.0. A aspect impact of that’s that your bundle will now construct within the Swift 6 language mode. Which means that you’ll get Swift’s full suite of sendability and concurrency checks in your bundle, and that the compiler will flag any points as errors.
You won’t be prepared to make use of Swift 6.0 in your new packages but. In these circumstances you may both set the Swift instruments model again to five.10 in case you’re not utilizing any options from the 6.0 toolchain anyway or you may set your bundle’s language mode to Swift 5 whereas protecting the 6.0 toolchain:
// swift-tools-version: 6.0
// The swift-tools-version declares the minimal model of Swift required to construct this bundle.
import PackageDescription
let bundle = Bundle(
title: "AppCore",
platforms: [.iOS(.v18)],
// ... the remainder of the bundle description
swiftLanguageModes: [.v5]
)
It is also attainable to assign the swift language mode for particular targets in your bundle as an alternative. Here is what that appears like:
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "AppCore",
swiftSettings: [.swiftLanguageMode(.v5)]
)
]
By utilizing the Swift 5 language mode you may proceed to write down your code as standard till you are prepared to begin migrating to Swift 6. For instance, you may wish to begin by enabling strict concurrency checks.