Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics An Introduction to Swift Programming What Is Swift?

Shame Fox
Shame Fox
124 Points

Is this Swift 4?

I hope the lessons teach me the newest knowledge

2 Answers

Michael Hulet
Michael Hulet
47,912 Points

Since Swift 4 was only just released, the current Swift courses are all in Swift 3. However, Swift 3 is still perfectly valid syntax in most cases, but it'll be 100% valid all the time if you set the compiler for your project to run in Swift 3.2 mode. That being said, there's currently a What's New in Swift 4 workshop where you can get a feel for the differences and start to use them in practice

David Nissolle
David Nissolle
2,168 Points

Hi Michael! How would I go about setting the compiler to run in Swift 3.2 mode?

Michael Hulet
Michael Hulet
47,912 Points

Click on your project in Xcode's sidebar so it brings up the information about it (display name, team info, build target, frameworks you've linked, etc)

Project settings screen

Next, click on the tab along the top for "Build Settings" to bring up the build settings view

Project settings screen

Do a quick search in the search bar on that page for "Swift". To run the compiler in Swift 3.2 mode, change the setting next to "Swift Language Version" to "3.2". To mimic true Swift 3 behavior, you'll also have to set "Swift 3 @objc Inference" to "On", but I recommend you leave it "Off", as it results in smaller app sizes. If you're having trouble with your app, you can turn it back on, or you can mark all the methods/properties that you want UIKit/Foundation/whatever Objective-C framework you're using (target/action selectors, delegate methods, anything that an Objective-C framework has to know about) as @objc before its func or var keyword.

Project settings screen

You'll have to repeat that for every entry in the sidebar with the titles "Project" and "Targets", here:

Project settings screen

After that, Swift will behave like it does in all of the current videos on Treehouse

Nathaniel Idahosa
Nathaniel Idahosa
2,795 Points

Since Swift 4 has been around for a while now, has the version for the iOS Development Techdegree been Updated to version 4?

Michael Hulet
Michael Hulet
47,912 Points

This question is likely best for one of the staff members in the iOS Techdegree Slack workspace. That being said, I recently joined the iOS Techdegree, and I'm near submitting project 1. It didn't look like the videos in unit 1 have been re-recorded in about 2 years, but there also didn't seem to be any difference between the code in the videos and what you'd write in Swift 4. Swift 4 doesn't have very many breaking changes from Swift 3, so it's just fine imo to learn from Swift 3 videos and read a Swift 3 -> Swift 4 changelog (or take the overview workshop I linked in my answer). It seems to me that the current iOS videos are still valid in the vast majority of all cases