Questions tagged [swift3]

Use this tag only for questions directly related to changes in version 3 of Apple's Swift programming language. Use the tag [swift] for more general language questions, or the tags [ios], [cocoa], [apple-watch] etc for questions about developing on Apple platforms.

Swift 3 is the version of Apple's programming language Swift. It was released on September 13, 2016. The language is open source and available on Github (see ).

The development of Swift 3 and its goals can be viewed on the Swift Programming Language Evolution repository on Github.

For more information, please visit Swift's Getting Started page.

18453 questions
159
votes
18 answers

Type of expression is ambiguous without more context Swift

I am getting a 'Type of expression is ambiguous without more context ' on this part of code from a project I am trying to upgrade to latest Swift version. I can't seem to figure it out. I tried different things but can't get it to work. The problem…
Florian VIDAL
  • 1,601
  • 2
  • 9
  • 8
157
votes
10 answers

What is a good example to differentiate between fileprivate and private in Swift3

This article has been helpful in understanding the new access specifiers in Swift 3. It also gives some examples of different usages of fileprivate and private. My question is - isn't using fileprivate on a function that is going to be used only…
Nikita P
  • 4,226
  • 5
  • 31
  • 55
156
votes
7 answers

How to check current thread in Swift 3?

How do I check which one is the current thread in Swift 3? In previous versions of Swift it was possible to check if the current thread was the main one by doing this: NSThread.isMainThread()
BalestraPatrick
  • 9,944
  • 4
  • 30
  • 43
148
votes
18 answers

How to fix "SWIFT_VERSION '3.0' is unsupported, supported versions are: 4.0, 4.2, 5.0" error in Xcode 10.2?

I'm trying to run downloaded from app, try to open in Xcode and have an error: " Showing Recent Messages :-1: SWIFT_VERSION '3.0' is unsupported, supported versions are: 4.0, 4.2, 5.0. (in target 'SimpleWeather')"
vlad uvarov
  • 1,489
  • 2
  • 6
  • 3
147
votes
12 answers

The "++" and "--" operators have been deprecated Xcode 7.3

I am looking at Xcode 7.3 notes and I notice this issue. The ++ and -- operators have been deprecated Could some one explain why it is deprecated? And am I right that in new version of Xcode now you going to use instead of ++ this x +=…
Oleg Gordiichuk
  • 15,240
  • 7
  • 60
  • 100
144
votes
5 answers

print without newline in swift

In swift 2.0, print() automatically adds a newline character. In swift 1.2, println() and print() used to be separate functions. So how do I print some text and not add a newline to it since swift no longer has a print function that does not append…
Ankit Goel
  • 6,257
  • 4
  • 36
  • 48
133
votes
13 answers

How do you create custom notifications in Swift 3?

In Objective-C, a custom notification is just a plain NSString, but it's not obvious in the WWDC version of Swift 3 just what it should be.
132
votes
16 answers

Bundle.main.path(forResource:ofType:inDirectory:) returns nil

Try not to laugh or cry -- I'm just getting back into coding after 20 years out... I've spent more than 4 hours looking at references and trying code snippets to get Bundle.main.path to open my text file so I can read in data for my app (my next…
132
votes
9 answers

'var' parameters are deprecated and will be removed in Swift 3

Alright so I just update Xcode to 7.3 and now I get this warning: 'var' parameters are deprecated and will be removed in Swift 3 How to fix this when I need to use the var in this function: public func getQuestionList(var language: String) ->…
SDW
  • 1,880
  • 4
  • 19
  • 30
131
votes
30 answers

Error: Could not build Objective-C module 'Firebase'

When I compile the application I get an error equal to this: Could not build Objective-C module 'Firebase' This error appear in import Firebase of my file swift.
sebas.varela
  • 1,535
  • 2
  • 10
  • 12
127
votes
5 answers

What does "% is unavailable: Use truncatingRemainder instead" mean?

I get the following error when using code for an extension, I'm not sure if they're asking to just use a different operator or modify the values in the expression based on an internet search. Error: % is unavailable: Use truncatingRemainder…
Laurence Wingo
  • 3,912
  • 7
  • 33
  • 61
124
votes
11 answers

Correctly Parsing JSON in Swift 3

I'm trying to fetch a JSON response and store the results in a variable. I've had versions of this code work in previous releases of Swift, until the GM version of Xcode 8 was released. I had a look at a few similar posts on StackOverflow: Swift 2…
user2563039
  • 1,418
  • 2
  • 11
  • 15
124
votes
11 answers

Registering for Push Notifications in Xcode 8/Swift 3.0?

I'm trying to get my app working in Xcode 8.0, and am running into an error. I know this code worked fine in previous versions of swift, but I'm assuming the code for this is changed in the new version. Here's the code I'm trying to run: let…
123
votes
3 answers

Non-'@objc' method does not satisfy optional requirement of '@objc' protocol

Overview: I have a protocol P1 which provides a default implementation of one of the Objective-C optional functions. When I provide a default implementation of the optional function there is a warning Compiler Warning: Non-'@objc' method…
user1046037
  • 16,755
  • 12
  • 92
  • 138
118
votes
8 answers

Xcode 9 Swift Language Version (SWIFT_VERSION)

I've recently updated xcode to version 9. Before that in Xcode 8.x whenever I use to do pod update it shows me an update code to convert the code to Swift 3 and doing that solve the errors. But now it is giving me this error: The “Swift Language…
Chaudhry Talha
  • 7,231
  • 11
  • 67
  • 116