Questions tagged [swift5]

Use this tag only for questions directly related to changes in version 5 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 5 is a version of the Swift language developed by Apple and was released March 26th, 2019 with Xcode 10.2. The language is open source and available on GitHub (see ).

Swift 5 follows and .

Swift 5 Release Notes for Xcode 10.2.

3158 questions
480
votes
9 answers

How do I write dispatch_after GCD in Swift 3, 4, and 5?

In Swift 2, I was able to use dispatch_after to delay an action using grand central dispatch: var dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC))) dispatch_after(dispatchTime,…
brandonscript
  • 68,675
  • 32
  • 163
  • 220
416
votes
16 answers

What is the "some" keyword in Swift(UI)?

The new SwiftUI tutorial has the following code: struct ContentView: View { var body: some View { Text("Hello World") } } The second line the word some, and on their site is highlighted as if it were a keyword. Swift 5.1 does not…
Half
  • 5,078
  • 2
  • 10
  • 20
197
votes
1 answer

“SimulatorTrampoline.xpc” would like to access the microphone

I recently upgraded to Swift 5, Xcode version 10.2 (10E125), and after fixing a few compile issues on an app in progress, see this new and never-seen-before request. I can find no evidence of it in my project via direct searching, and no search…
drew..
  • 3,234
  • 3
  • 16
  • 19
190
votes
12 answers

Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler

I have a framework (in this instance it's RxSwift) which I've compiled using Xcode 11.0 into the traditional RxSwift.framework style package This imported fine into Xcode 11.0 and also 11.1 never had any problems with it Today, upon Apple's release…
Orion Edwards
  • 121,657
  • 64
  • 239
  • 328
175
votes
12 answers

'Module was not compiled for testing' when using @testable

I'm trying to use Swift's @testable declaration to expose my classes to the test target. However I'm getting this compiler error: Intervals is the module that contains the classes I'm trying to expose. How do I get rid of this error?
hgwhittle
  • 9,316
  • 6
  • 48
  • 60
136
votes
1 answer

UIAlertController's actionSheet gives constraint error on iOS 12.2 / 12.3

On iOS 12.2, while using UIAlertController's actionSheet, Xcode gives constraint error. Anyone having this problem? This same code runs on iOS 12.1 with no error. I have tested this code on Xcode 10.2 and 10.1. class ViewController: UIViewController…
L03n
  • 1,421
  • 2
  • 10
  • 12
64
votes
7 answers

What does the SwiftUI `@State` keyword do?

The SwiftUI tutorial uses the @State keyword to indicate mutable UI state: @State var showFavoritesOnly = false It offers this summary: State is a value, or a set of values, that can change over time, and that affects a view’s behavior, content, or…
Taylor
  • 5,871
  • 2
  • 30
  • 64
46
votes
2 answers

Swift: 'Hashable.hashValue' is deprecated as a protocol requirement;

I've been facing following issue (it's just a warning) with my iOS project. 'Hashable.hashValue' is deprecated as a protocol requirement; conform type 'ActiveType' to 'Hashable' by implementing 'hash(into:)' instead Xcode 10.2 Swift 5 Source…
Krunal
  • 77,632
  • 48
  • 245
  • 261
42
votes
1 answer

Xcode 12 IPHONEOS_DEPLOYMENT_TARGET warning for SPM dependencies

After updating to Xcode 12, I've got lots of warnings for SPM dependencies (including RxSwift and Facebook). The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is…
abagmut
  • 911
  • 1
  • 10
  • 22
38
votes
6 answers

Warning: Initialization of 'UnsafeBufferPointer' results in a dangling buffer pointer

After update to Swift 5.2 / Xcode 11.4 got a warning to following code: extension Data { init(from value: T) { var value = value let pointer = UnsafeBufferPointer(start: &value, count: 1) self.init(buffer: pointer) …
Exey Panteleev
  • 1,260
  • 3
  • 13
  • 15
38
votes
5 answers

Difference between switch cases "@unknown default" and "default" in Swift 5

From Swift 5, new case attribute @unknown is introduced. What is the exact difference when @unknown is being used and not being used? In which case we have to use @unknown keyword?
Saranjith
  • 11,242
  • 5
  • 69
  • 122
37
votes
6 answers

This copy of libswiftCore.dylib requires an OS version prior to 12.2.0

The app crashes on launch when running from XCode 10.2 (before and after Swift 5.0 migration) with this on console This copy of libswiftCore.dylib requires an OS version prior to 12.2.0. I understand the error, but not sure what is required to…
msk
  • 8,885
  • 6
  • 41
  • 72
36
votes
4 answers

SwiftUI dynamic List with Sections does not Layout correctly

I'm trying to create a simple dynamic list grouped into sections. (SwiftUI iOS13 Xcode11 beta 2) A simple static example would be : struct StaticListView : View { var body: some View { List { Section(header: Text("Numbers"),…
Bo Frese
  • 893
  • 1
  • 8
  • 9
34
votes
6 answers

How to have text in shapes in SwiftUI?

I want to add text (eg. Hi) in a shape (eg. Square) in SwiftUI and make them act as a single object. It looks like there's no direct way to add text in shape in SwiftUI.
AtharvSalokhe
  • 463
  • 1
  • 4
  • 13
1
2 3
99 100