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
6
votes
1 answer

SwiftUI: Cannot infer contextual base in reference to member

I wrote an extension for SwiftUI Font which introduces a couple of custom fonts. extension Font { static let solDisplay: Font = .custom("Gilroy", size: 36) static let solHeadline: Font = .custom("Gilroy", size: 24) } Now for some reason…
JaWeilBaum
  • 67
  • 1
  • 1
  • 4
6
votes
0 answers

iOS ARView and MTKView - how to restore camera position?

I have an iOS point cloud app and am trying to allow the user to keep adding points to an existing point cloud across multiple sessions. I have a Metal MTKView, overlaid and aligned with an ARView underneath. When I have the .showSceneUnderstanding…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
6
votes
1 answer

Cannot convert value of type 'Codable' (aka 'Decodable & Encodable') to expected argument type 'T.Type'

I'm working on a small struct that handles the parsing of JSON. Up until now it is all working except I am wanting to pass a custom struct as a structure to use on the decode in JSONDecoder().decode(type.self, from: data) but this is throwing the…
Joe Scotto
  • 10,936
  • 14
  • 66
  • 136
6
votes
0 answers

Unable to change color of menu items in NavigationBarItems in SwiftUI

I have menu items at the leading and trailing edges of the NavigationBar. I am not able to change the color of the menu items. I am, however able to change the color of the icon of the Navigation bar itself but not the menu items that are under the…
RXP
  • 517
  • 4
  • 18
6
votes
1 answer

How to detect if Local Network permissions are granted in iOS 14

How to detect if the user has granted the local network permission in the app for iOS 14? I have to show an error screen if the user has denied permission and redirects to os settings to grant permission. Has Apple provided any way to find out just…
riyaz
  • 514
  • 4
  • 17
6
votes
2 answers

Swift - Cannot get real text from UITextField - get NCIStr result instead

I have a UITextField that has the "Secure Text Entry" checked in my storyboard. When I assign the text of the UITextField.text property to a variable I get a value of: class name = _NSClStr instead of the actual value of the text which is: ABCD If I…
TJ Asher
  • 737
  • 9
  • 27
6
votes
2 answers

SwiftUI drag gesture freezes with multi-touch

I am trying to drag a view in SwiftUI. The drag works perfectly until I place my second finger on screen, after that the drag stops and neither of the code blocks (onChanged, onEnded) gets called. But, when I again start dragging with a single…
SandeepAggarwal
  • 1,273
  • 3
  • 14
  • 38
6
votes
0 answers

CoreData has problems with sync data to cloud on a MacOS app due to pending request error

I am writing an app for MacOS and main feature will be syncing data to iCloud. All that I've already done is - project with Core-Data and CloudKit options turned on, - created a model and some basic routine to create model by importing file to…
metal_man
  • 580
  • 1
  • 9
  • 22
6
votes
1 answer

Swift : cannot convert return expression of any view to return type some view

I don't know what I have this error : cannot convert return expression of any view to return type some view I try some things but nothing nothing worked... And I found nothing on the web Thanks for your help... struct LoginView: View { …
Keal Mlj
  • 103
  • 1
  • 9
6
votes
0 answers

iOS 13.4 When app goto background from foreground network is getting disconnect

Steps to reproduce: Create a new app and call any API to the server to get data immediately take the app to background network get disconnects below is the log: 2020-03-26 17:21:00.894598+0530 TestApp[783:152843] Connection 2: received failure…
lreddy
  • 449
  • 6
  • 19
6
votes
2 answers

'Cannot use mutating getter on immutable value: 'self' is immutable' when iterating?

Does anyone know why the self.indexCount in the ForEach is giving the error Cannot use mutating getter on immutable value: 'self' is immutable error? I can provide aView with indexCount, but it's not very convenient. I'm not changing indexCount. Is…
HelloWorld
  • 370
  • 1
  • 7
  • 18
6
votes
1 answer

How to resize UIHostingController to wrap it's SwiftUI View?

I have a basic SwiftUI component. struct PopupModal: View { var body: some View { Text("Hello, World!") } } struct PopupModal_Previews: PreviewProvider { static var previews: some View { PopupModal() } } And I have…
Aidan Rosswood
  • 1,212
  • 1
  • 10
  • 21
6
votes
0 answers

UITests fail when run with Fastlane

I am working on an iOS app and the goal is to successfully run tests using Fastlane. When I run tests with Xcode, everything works fine. Tests are only failing when run using Fastlane. This is the error message: Failed to get matching snapshots:…
arber
  • 61
  • 1
  • 2
6
votes
1 answer

How to integrate Google reCAPTCHA in Swift

I am working on an iOS project the client requirement is to put the Google reCAPTCHA authentication in the registration form.so, is there any way that I can do it as an android or website. I searched a lot but I didn't get any specific exact…
Kumar Lav
  • 234
  • 1
  • 3
  • 9
6
votes
2 answers

How to write Unit Test for UserDefaults

I have 2 functions where one basically retrieves string in User Defaults and another writes the string in User Defaults. I'm not able to understand that should I do the unit test or no? and I'm pretty new to the concept for Unit testing. I scoured…
Kane D
  • 63
  • 1
  • 4