I use Xcode 16.3. When I create a new project, it is automatically assigned to Swift 5. I would like to Swift 6. I know how to change for an existing project, but I would like to do it by default for every new project. How?
The Swift language version setting is actually specified as part of the project template. It is written in
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/Base/Base_ProjectSettings.xctemplate/TemplateInfo.plist
At the end of this file, there is a part that looks like this:
...
<key>Targets</key>
<array>
<dict>
<!-- Declare basic stuff that is true of all Swift targets, but mark this non-concrete so it won't cause actual creation of a target. -->
<key>Concrete</key>
<false/>
<key>SharedSettings</key>
<dict>
<key>SWIFT_VERSION</key>
<string>5.0</string>
</dict>
</dict>
</array>
...
Change that "5.0" and "6.0", then restart Xcode, and Voila!
Note that since this file is inside Xcode.app, you need sudo to change it. I opened the file in VSCode, then upon saving, VSCode prompts me to use sudo and enter my password. On the other hand, if I open the file in Xcode, Xcode just says it cannot be saved. I'm not a command line guy, but you could probably also cp the file to somewhere else, edit it, then sudo cp it back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With