Questions tagged [swift5.1]

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

Swift 5.1 is a version of the Swift language developed by Apple and released in 2019 with Xcode 11. The language is open source and available on GitHub (see ).

Swift 5.1 follows , and .

Xcode 11 beta Release Notes.

184 questions
310
votes
13 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…
Nicholas
  • 3,643
  • 2
  • 7
  • 17
154
votes
7 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
  • 113,829
  • 60
  • 223
  • 307
47
votes
6 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
  • 4,661
  • 2
  • 24
  • 46
31
votes
2 answers

Instantiated optional variable shows as nil in Xcode debugger

Since I upgraded to Xcode 11 and Swift 5.1 I've encountered a strange issue -- after an optional variable is instantiated, it can still show as up nil in the Xcode debugger! I have an optional class variable called booking: var booking:…
Dylan
  • 2,015
  • 1
  • 17
  • 28
21
votes
2 answers

How to confirm an enumeration to Identifiable protocol in Swift?

I'm trying to make a list with the raw values of the cases from an enumeration with the new SwiftUI framework. However, I'm having a trouble with conforming the 'Data' to Identifiable protocol and I really cannot find information how to do it. It…
15
votes
8 answers

iOS 13 Schedule iOS background tasks

I am implementing BackgroundTasks Framework for updating the data. But I got the below issue Could not schedule refreshApp: Error Domain=BGTaskSchedulerErrorDomain Code=1 "(null)" Could not schedule data featch: Error…
Gurjinder Singh
  • 5,576
  • 44
  • 41
11
votes
1 answer

Google AdMob error after update to Xcode 11 Swift 5.1

Since I have updated to Xcode 11 the interstitial ads in my app won't load anymore. (Before that everything worked fine. The app was even released on the App Store. We are now creating an updated version of the app) I installed the Google AdMobs…
Daniel Götz
  • 111
  • 4
10
votes
6 answers

Conditional property in SwiftUI

How can I add an additional property based on a condition? With my code below I got the error Cannot assign value of type 'some View' (result of 'Self.overlay(_:alignment:)') to type 'some View' (result of 'Self.onTapGesture(count:perform:)') import…
Ben Keil
  • 598
  • 6
  • 22
9
votes
4 answers

How can I center a placeholder text in a TextField

My code is as follow: TextField("Enter Your Email", text: self.$username) How can I make the placeholder "enter your email" be centered in the TextField?
Damion Silver
  • 361
  • 2
  • 10
8
votes
1 answer

How to pass a value from an EnvironmentObject to a class instance in SwiftUI?

I'm trying to assign the value from an EnvironmentObject called userSettings to a class instance called categoryData, I get an error when trying to assign the value to the class here ObserverCategory(userID: self.userSettings.id) Error says: Cannot…
Lorenzo R
  • 515
  • 1
  • 5
  • 8
8
votes
3 answers

SwiftUI: Navigation bar of destination view has no background and is not animated on scroll

I'm trying to make navigation view that leads to destination view with scroll view, where navigation title of destination view would animate towards inline display mode or at least scroll behind the nav bar itself. Basically I'm trying to replicate…
Anton
  • 83
  • 1
  • 5
7
votes
4 answers

Getting currently focused UIScene when multiple connected scenes are active in foreground

I have a problem getting the current UIScene when multiple scenes are connected. Specifically, my app (iOS 13) supports multiple windows on the iPad. When I have two windows side by side and I access the apps connected scenes (with…
freshking
  • 1,686
  • 15
  • 26
6
votes
1 answer

Access self in Swift 5.1 Property Wrappers

I would like to create a property wrapper which is invalidating the layout of my UICollectionViewLayout. Therefore I created this property wrapper @propertyWrapper class LayoutInvalidating { private let layout: UICollectionViewLayout …
BilalReffas
  • 6,834
  • 3
  • 43
  • 63
6
votes
1 answer

New delegates for carPlay

I am devleoping navigation app for CarPlay and in iOS 12 there were two methods from CPApplicationDelegate to detect if CarPlay is on: func application(_ application: UIApplication, didConnectCarInterfaceController interfaceController:…
impresyjna
  • 61
  • 2
1
2 3
12 13