Questions tagged [swift4.1]

Use this tag only for questions directly related to changes in version 4.1 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 4.1 contains updates to the core language, including more support for generics, new build options, as well as minor enhancements to Swift Package Manager and Foundation. There was also significant progress made in stabilizing the ABI.

Swift 4 is the fourth version of the Swift language developed by Apple that was released in 2017. The language is open source and available on Github (see ).

The development of Swift 4 and its goals can be viewed on the Swift Programming Language Evolution repository on GitHub

229 questions
113
votes
6 answers

Status bar could not find cached time string image. Rendering in-process

I get the above runtime message after I upgraded to Swift4.1 and Xcode 9.3. Before the upgrade I did not have this message in my console window. Status bar could not find cached time string image. Rendering in-process. comes up every few minutes…
mac_eric
  • 1,230
  • 3
  • 12
  • 12
37
votes
4 answers

Codable 'has no initializers' in Xcode 9.3 (Swift 4.1)

After updating to Xcode 9.3 (which uses Swift 4.1), the following issue was found: Create an empty project, add a new .swift file to it and create two new classes: class CodableOne: Codable { let some: String } class CodableTwo: Codable…
EBDOKUM
  • 1,696
  • 3
  • 15
  • 33
32
votes
6 answers

Xcode 9.4 : unexpected service error: The Xcode build system has crashed

I’m getting strange error while building project in Xcode 9.4 Build system information - unexpected service error: The Xcode build system has crashed. Please close and reopen your workspace. I tried Xcode quit and reopen but that didn’t worked.…
Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
30
votes
3 answers

Difference between flatMap and compactMap in Swift

It seems like in Swift 4.1 flatMap is deprecated. However there is a new method in Swift 4.1 compactMap which is doing the same thing? With flatMap you can transform each object in a collection, then remove any items that were nil. Like…
BilalReffas
  • 8,132
  • 4
  • 50
  • 71
18
votes
3 answers

How to do two concurrent API calls in swift 4

Thanks in advance for help, I have two API calls, both are concurrent and any call could be success first(I don't want call in sequence), after success of both calls, I have to stop my activity indicator and reload my tableView, Here is my code but…
King
  • 259
  • 1
  • 4
  • 12
14
votes
1 answer

Swift's canImport analogue in Objective-C

Swift 4.2 has a special condition canImport that helps developers to check whether a module can be imported in project. It was introduced in Swift 4.1. Now I am working on iOS project written in Objective-C. I use modules, and for each target these…
Roman Podymov
  • 4,168
  • 4
  • 30
  • 57
13
votes
1 answer

@objc keyword extension subclass behaviour

Can someone explain why @objc keyword is needed here to compile the code? As I understood this keyword is used in order to work ObjC message method dispatch. But this is not an NSObject instance. class MyClass { } extension MyClass { @objc…
Vyacheslav
  • 26,359
  • 19
  • 112
  • 194
12
votes
3 answers

Using JSONSerialization() to dynamically figure out boolean values

I am getting a JSON string from the server (or file). I want to parse that JSON string and dynamically figure out each of the value types. However, when it comes to boolean values, JSONSerialization just converts the value to 0 or 1, and the code…
kgaidis
  • 14,259
  • 4
  • 79
  • 93
11
votes
2 answers

Why does compactMap return a nil result?

Consider this code snippet: var a: String? = "abc" var b: String? let result = [a, b].compactMap { $0 } After executing it, result will be ["abc"] which is the expected result. The element of result (ElementOfResult) here is…
tonymontana
  • 5,728
  • 4
  • 34
  • 53
9
votes
1 answer

Cast Any to Float always fails in swift4.1

In the former version, to get a float value from a [String: Any] dictionary, I can use let float = dict["somekey"] as? Float, but in swift4.1, it doesn't work. It seems the type of dict["somekey"] has been implicitly inferred as Double before I get…
LYM
  • 251
  • 3
  • 9
9
votes
1 answer

warning in Xcode 9.3

I'm getting this warning in Xcode when I run my app in the simulator. What can I do to get rid of it? objc[6529]: Class VCWeakObjectHolder is implemented in both…
arakweker
  • 1,535
  • 4
  • 18
  • 40
7
votes
1 answer

text changed event in UITextView

I have @IBOutlet weak var messageTextView: UITextView and I want that when there is a change inside the text then print to console: blabla. I tried to add the following function, but when I change the text nothing happens: func textViewDidChange(_…
trycatch
  • 135
  • 1
  • 8
7
votes
1 answer

How to encode a mixed-value-type dictionary to JSON in Swift 4.1

The code below works in Xcode 9.2 (Swift 4.0) but gives an error in Xcode 9.3 (Swift 4.1). let dict: [String: Any] = [ "status_code": 5, "status_message": "message" ] let data = try! JSONEncoder().encode(dict) //…
Dov
  • 15,530
  • 13
  • 76
  • 177
7
votes
2 answers

Swift 4.1 - Subclass UIImage

I get Overriding non-@objc declarations from extensions is not supported error when subclass UIImage with custom init after upgrading to Swift 4.1 class Foo: UIImage { init(bar: String) { } required init?(coder aDecoder: NSCoder) { …
Daniel Nilsson
  • 101
  • 1
  • 6
6
votes
3 answers

Xcode10: The operation couldn't be completed. (DVTCoreSimulatorAdditionsErrorDomain error 0.)

I have tried: restart the simulator and Xcode delete Xcode and reinstall it run xcrun simctl erase all this command I already try but can't solve this issue
Mitesh Ramani
  • 131
  • 2
  • 8
1
2 3
15 16