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
18
votes
3 answers

App crashes randomly with NSInvalidArgumentException unrecognized selector sent to instance 0x800000000000000

My app uses core data. I have recently upgraded to Xcode 10.2 and swift 5 and since then I am receiving random crashes that has something to do with core data. From what I have gathered this happened when trying to change Core Data from a background…
Yoni Reiss
  • 320
  • 2
  • 8
17
votes
1 answer

iOS Swift - how to get aspect ratio of local and remote video?

Scenario: I'm building a WebRTC view inside an app The container for videos will always have a height of 160. In the center of the container there should be displayed the remote video with a max height of 160, width should be scaled to respect the…
John
  • 1,081
  • 1
  • 9
  • 34
17
votes
2 answers

Updating @Published variable of an ObservableObject inside child view

I have a published variable isLoggedIn inside a ObservableObject class as follows: import Combine class UserAuth: ObservableObject{ @Published var isLoggedIn: Bool = false } I want to update this variable to true in a particular view…
39fredy
  • 1,923
  • 2
  • 21
  • 40
17
votes
2 answers

SwiftUI: Generic parameter 'Subject' could not be inferred

I built a LoadingView with SwiftUI for showing some loading stuff in my app while I'm fetching remote data from an API. I am on Xcode Version 11.0 beta 5. This is the LoadingView: struct LoadingView: View where Content: View { @Binding…
Teetz
  • 3,475
  • 3
  • 21
  • 34
17
votes
2 answers

Invalid redeclaration of 'variable.storage' in Swift 4.2 after updating to Xcode 10.2

We have an iOS project. The Swift language version is 4.2. We were previously building it in Xcode 10.1 with no compile errors. After updating to Xcode 10.2 (but keeping Swift 4.2), the project is now riddled with errors like Invalid redeclaration…
Phlippie Bosman
  • 5,378
  • 3
  • 26
  • 29
16
votes
8 answers

How do I use TabbedView in SwiftUI?

struct ContentView : View { var body: some View { NavigationView { TabbedView { PasswordGenerator() .tabItemLabel { Image("KeyGlyph") …
SmushyTaco
  • 1,421
  • 2
  • 16
  • 32
15
votes
2 answers

Fill height in scrollView in swiftUI

I am coding useing swiftUI and I have a vertical scrollView (see screenshots), and inside that scrollView I have another horizontal scrollView, and below that I have a VStack that I want the height to fill the rest of the screen to the bottom of the…
Gor Manukyan
  • 153
  • 1
  • 1
  • 5
15
votes
1 answer

What is the correct syntax for using Publishers.debounce() in Swift Combine?

In Apple's 2019 WWDC video Swift Combine in Practice, they demonstrate using a debounce publisher to slow down the rate of messages. return $username .debounce(for: 0.5, scheduler: RunLoop.main) .removeDuplicates() …
kennyc
  • 5,490
  • 5
  • 34
  • 57
15
votes
1 answer

Conversion to Swift 5 is available

I'm getting this warning in Xcode 10.2: Conversion to Swift 5 is available When I click this error, it's opening this window: When we click Next what will happen?
Naresh
  • 16,698
  • 6
  • 112
  • 113
15
votes
1 answer

Optional unowned reference versus weak in Swift 5.0

This is allowed in Swift 5.0: class Person { unowned var child: Person? } This is supported by this release notes: unowned and unowned(unsafe) variables now support Optional types. (47326769) I understood exactly the difference between…
J. Doe
  • 12,159
  • 9
  • 60
  • 114
14
votes
6 answers

asyncDetached falling back into main thread after MainActor call

I'm trying out the new async/await stuff. My goal here is to run the test() method in the background, so I use Task.detached; but during test() I need to make a call on the main thread, so I'm using MainActor. (I realize that this may look…
matt
  • 515,959
  • 87
  • 875
  • 1,141
14
votes
2 answers

Module was not compiled with library evolution support; using it means binary compatibility for can't be guaranteed

Recently I face this compile time warning for a SDK. Does it means it is not build with the Target setting "Build Libraries for Distribution"?.
Rajesh Maurya
  • 3,026
  • 4
  • 19
  • 37
14
votes
1 answer

How to use "responseDecodable" method in Alamofire?

I have been trying to use "responseDecodable" method from Alamofire, but I'm getting "Generic parameter 'T' could not be inferred" error while using it. Can someone guide me how to fix this?
Arun_
  • 1,806
  • 2
  • 20
  • 40
14
votes
1 answer

What should I pass to the .success() for `Result`?

I have a network request, but I don't really care about the success response, so I use a Result for return value. The problem is when I assign .success() to it, the compiler return the following error: Missing argument for parameter #1…
Yiming Dong
  • 1,530
  • 2
  • 9
  • 11
14
votes
1 answer

New Swift 5 warnings for Objective-C enums: how to get rid of them?

As of Xcode 10.2, when using enums I've defined in Objective-C, but in a Swift 5 switch statement, I get the following warning, even if I've exhausted all the possible enum values. Switch covers known cases, but 'MyObjectiveCEnumName' may have…
Clay Bridges
  • 11,602
  • 10
  • 68
  • 118