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
11
votes
2 answers

iOS Xcode 12.0 Swift 5 'AppDelegate' is annotated with @main and must provide a main static function of type () -> Void or () throws -> Void

In my Xcode 12.0 using Swift 5 and Catalina 10.15.5: When I tick Mac as deployable target (Apple Project Catalyst), and click Runs, it gives me an error showing: 'AppDelegate' is annotated with @main and must provide a main static function of type…
felixwcf
  • 2,078
  • 1
  • 28
  • 45
11
votes
3 answers

ERROR SocketEnginePolling: Error during long poll request

let manager = SocketManager(socketURL: URL(string: "Some url")!, config: [.log(true), .compress]) var socket:SocketIOClient! var name: String? var resetAck: SocketAckEmitter? override func viewDidLoad() { super.viewDidLoad() socket =…
Shankar Thorve
  • 131
  • 2
  • 6
11
votes
3 answers

App crash , Xcode11.4, iOS 10.3.3 10.3.4, iPhone 5c /5 iPad4 (armv7s)

Our app crash on os 10.3.3 10.3.4, iPhone 5c /5 iPad4 (armv7s 32) compiled by Xcode 11.4, swift optimization on. We find the PC register point to a hole address without virtual address and no stack information. If we close swift optimization, it…
Victor Choy
  • 4,006
  • 28
  • 35
11
votes
3 answers

Xcode 11: cannot instantiate view controller from storyboard with identifier

I'm using Xcode 11.1 and my deployment target is iOS 10.0 I can't instantiate a view controller like before. Here is the code in func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: …
Suh Fangmbeng
  • 573
  • 4
  • 16
11
votes
2 answers

Firebase Cocoa Pods Error After Swift 5 Update

I am currently using Xcode Version 10.2 beta 4 and have updated the project to Swift 5. Upon doing this I have run into a ton of errors relating to my Firebase Pods. I have deintegrated the pods and installed again and even tried pod update. I…
Ron
  • 161
  • 1
  • 8
10
votes
1 answer

Creating line chart with multiple lines

Looking over Apple Documentation I found a straightforward way of doing this provided your dataset is structured correctly (mine is not). I've been working with a CSV file containing rows structured as below: PM2.5 data, PM10 data, DateTime PM2.5…
John Harrington
  • 1,314
  • 12
  • 36
10
votes
4 answers

Self sizing collection view enters a recursive loop in iOS 15

I have a self sizing collection view and when I call super.layoutSubviews my app crashes since the collection view enters a recursive update loop. This was working fine in iOS 14 and below. But observed it in iOS 15 onwards. class…
Deepa Bhat
  • 174
  • 1
  • 10
10
votes
1 answer

Swift 5.5 Concurrency: creating a task with custom error type

I need to use my own custom error enum in tasks that I create: enum MyError: Error { case someError } var myTask: Task = Task { () throws -> MyModel in // in case of an error: // throw .someError …
JAHelia
  • 6,934
  • 17
  • 74
  • 134
10
votes
2 answers

SwiftUI Nested ForEach causes Fatal error: each layout item may only occur once

I'm trying to create a LazyVGrid view to display the contents of objects in an array using nested ForEach statements. The code is causing an app crash with the message "Fatal error: each layout item may only occur once". Each object contains an…
tommy
  • 277
  • 2
  • 8
10
votes
2 answers

Pass state/binding to UIViewRepresentable

What is the correct way to pass a state variable to my custom text field? I was hoping to avoid other approaches/observables. Shouldn't this work? I have recreated the problem below in an example project. import SwiftUI struct ParentView: View { …
Bryan Potts
  • 901
  • 1
  • 7
  • 20
10
votes
4 answers

Error installing cocoapods "sudo gem install cocoapods" MacOs Catalina

I am trying to install cocoapods in my mac system but Unfortunately not able to install due to below error. I have already used below commands. sudo gem install -n /usr/local/bin cocoapods --pre export GEM_HOME=~/.gems export…
Nikunj5294
  • 391
  • 3
  • 14
10
votes
1 answer

How to play audio using AVAudioPlayer in SwiftUI project

Audio is not playing using this approach. The play() function is executing without any error. Please help var audioPlayer = AVAudioPlayer() let path = Bundle.main.path(forResource: "a", ofType: "mp3") @State var isPlaying : Bool = false var body:…
deepak joshi
  • 125
  • 1
  • 9
10
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
  • 993
  • 1
  • 7
  • 9
10
votes
7 answers

SwiftUI WKWebView detect url changing

I'm a swift learner. I work with SwiftUI which is a struct, I have to implement a WKWebView and in that, a url is changing dynamically. I have to catch these changing urls, but solutions I have tried are not working. For example:…
10
votes
1 answer

Swift thinks I'm subclassing NSSet wrongly but I'm not subclassing it at all

I'm getting a bizarre error message from the Swift compiler: :0: error: 'required' initializer 'init(arrayLiteral:)' must be provided by subclass of 'NSSet' Foundation.NSSet:2:33: note: 'required' initializer is declared in superclass here …
uliwitness
  • 8,532
  • 36
  • 58