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

Swift 5.3 Compiler Crash for TableView Getter

while doing xcodebuild, compiler is getting crashed at below first line where the tableView was declared. var tableView: UITableView? { get { var table: UIView? = superview while !(table is UITableView) && table != nil { …
Madhu Avinash
  • 933
  • 2
  • 8
  • 27
8
votes
5 answers

Unit test that verifies runtime error is thrown in Swift

Googling has led me to general Swift error handling links, but I have a more specific question. I think the answer here is "no, you're out of luck" but I want to double check to see if I'm missing something. This question from a few years ago seems…
Elliot Schrock
  • 1,406
  • 2
  • 9
  • 20
8
votes
2 answers

Realitykit - Custom Material

Using Realitykit, trying to change the material of moon Entity to a custom .jpg and then tapping the screen to spawn that object based off hitTest. Nothing shows up when I tap and getting the following error in debug: [Collision] Bad paramater…
Lawlitrix
  • 81
  • 3
8
votes
2 answers

How to get the image URL from LPLinkMetadata in Swift

I am trying to get the URL for the image associated with a given URL. Using Apple's LPLinkMetadata, I am able to get the URL's title and description, but I cannot figure out how to access the metadata's image URL. I have access to data.imageProvider…
Lane Faison
  • 278
  • 4
  • 7
8
votes
3 answers

Get Shape for view dynamically in SwiftUI

Using Swift 5.2 I would like to create a function to dynamically change the Shape I have a view like import SwiftUI struct CardView: View { let suit : Suite let rank : Rank var body: some View { getShape(suite: .heart) …
Ryan Heitner
  • 13,119
  • 6
  • 77
  • 119
8
votes
2 answers

Fatal error: could not demangle keypath type

I have a simple class and I want to use keypath in the init, something like this: class V: UIView { convenience init() { self.init(frame: .zero) self[keyPath: \.alpha] = 0.5 } } let v = View() When I run this code I get a…
Anton Belousov
  • 1,140
  • 15
  • 34
8
votes
6 answers

Navigation bar appear on click on view

I attach the video of my issue. When i click on anywhere in viewcontroller navigation bar is appear override func viewWillAppear(_ animated: Bool) { self.navigationController?.setNavigationBarHidden(true, animated: true) …
kishor soneji
  • 795
  • 1
  • 9
  • 16
8
votes
3 answers

Convert SwiftUI Color to UIColor

I want to convert SwiftUI view Color to UIKit UIcolor component. I have tried several ways and also refer the StackOverflow already given answers, But they did not work. It was also mentioned by some users in those posts. I have gone through the…
8
votes
5 answers

SwiftUI how to set image for NavigationBar titleView like in UIKit?

I want to set an image in the titleView of NavigationBar in SwiftUI, as we do in UIKit navigationItem.titleView = UIImageView(image: UIImage(named: "logo")) this is how we do it in UIKit. anyone know how to do it?
Zeeshan Ahmed
  • 834
  • 8
  • 13
8
votes
1 answer

Custom URL Scheme not working on Swift 5, Xcode 11

I've added a custom URL scheme to my Xcode project (I'm using SwiftUI). In the AppDelagate file I've added: func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { …
39fredy
  • 1,923
  • 2
  • 21
  • 40
8
votes
2 answers

Reload UITabBarController on demand

I have the following TabBarController with 2 items. It is showing correctly. I'm calling the setupItems() function from another controller when something changes its value. The function is called correctly, the problem is that the…
fabdurso
  • 2,366
  • 5
  • 29
  • 55
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…
user6879675
8
votes
1 answer

Xcode 10.2 (and 10.2.1) is crashing the entire machine when converting from Swift 4 to Swift 5

I have a Mac application project that builds and runs in XCode 10.2.1 using Swift 4. When I try to convert it to Swift 5, the process starts, and then at about step 32 (of about 158), the machine locks up to the point where it either reboots, or I…
8
votes
1 answer

Warning : Unexpected version number in 'available' attribute for non-specific platform '*'

I have this snippet code : @available(*, deprecated:3.0, message:"Use activate().") public func install() { self.activate() } And since i've upgraded to swift5 and xcode 10.2 i get below warning : Unexpected version number in 'available'…
Mohsen Fard
  • 597
  • 9
  • 22
8
votes
2 answers

Convert from Swift 3.x to 5

When I opened my project in Xcode 10.2, I got this message: Unsupported Swift Version …Use Xcode 10.1 to migrate the code to Swift 4. Where can I still find Xcode 10.1? So the process is to have 2 versions of Xcode, first migrate to Swift 4 then…
Lim Thye Chean
  • 8,704
  • 9
  • 49
  • 88