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
7
votes
5 answers

Changing Search Bar placeholder text colour in iOS 13

I'm trying to set colour for placeholder text inside UISearchbar. Right now I've following code. It doesn't set white colour to placeholder text on iOS 13. It works on iOS 12. It seems something is either broken or support has been removed in iOS…
Raymond
  • 1,108
  • 13
  • 32
7
votes
1 answer

same class name in different modules

I need to use two classes with the same name in swift 5. For this, I have created those two classes in two different modules, but I am confused on how to use both the classes in an UIViewController one of my class is Person which is in models >…
Dhanu K
  • 11,288
  • 6
  • 24
  • 38
7
votes
1 answer

Dynamic links / universal links not working in cold start

I use firebase dynamic links. They work perfectly fine when the app is in background and I use the application continue userActivity function. However if I click on a dynamic link and cold start the application (not running in background) then not…
7
votes
2 answers

Xcode11 Archive fails: no such file or directory Objects-normal/arm64/UniversalSDK.SwiftFileList

I am trying to build a universal framework from existing source code in Xcode11. When I Archive, it fails with following error: /:1:1: no such file or directory:…
Bharat Biswal
  • 1,755
  • 2
  • 15
  • 23
7
votes
2 answers

Swift 5 & iOS 13 UISearchController wrong presenting and dismissing behaviour

While i was updating my project to iOS 13 i faced with unusual issue. I have logic for showing and handling some UISearchController actions (code below), all parts were working perfectly in iOS 11 & 12. My task was to add search button at navigation…
7
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
  • 8,132
  • 4
  • 50
  • 71
7
votes
0 answers

Swift: Quick/Nimble running async test shows error: 'InvalidNimbleAPIUsage', reason: 'expect(...).toEventually(...) can only run on the main thread.'

I'm implementing a test case using Quick/Nimble making network request (URLRequest) but I'm getting this error: *** Terminating app due to uncaught exception 'InvalidNimbleAPIUsage', reason: 'expect(...).toEventually(...) can only run on the main…
user2924482
  • 8,380
  • 23
  • 89
  • 173
7
votes
2 answers

Skeleton Example for Swift Combine Publisher-Subscriber

As I port some Objective-C code to Swift, I'm trying to better understand the new Combine framework and how I can use it to re-create a common design pattern. In this case, the design pattern is a single object (Manager, Service, etc) that any…
kennyc
  • 5,490
  • 5
  • 34
  • 57
7
votes
1 answer

How to fix 'outlined consume of Model?' runtime crash on Swift 5

I just upgraded one of my apps to Swift 5, I didn't change so much at all and there didn't seem to be any problems, so I just released it in production (fortunately in phased release). After 1 days I started to see a very strange crash on…
iDevid
  • 507
  • 3
  • 13
6
votes
0 answers

How can I get the install state of Safari iOS extension?

I'd like to know the install state of my iOS safari extension in the associated swift app. Is there any way to get this? SFSafariExtensionManager and getStateOfSafariExtension here only seems valid on macOS safari extensions. Is there any equivalent…
tob88
  • 2,151
  • 8
  • 30
  • 33
6
votes
1 answer

Multipeer Connectivity - Get file transfer(Internet) speed and File Size in Swift 5

I am transferring photo peer to peer. All things works fine but I am not able to get the photo(file) transfer speed i.g internet speed. Like MB the file is transferred. Second I want to fetch the size of that file. We are passing photo in data…
Yogesh Patel
  • 1,893
  • 1
  • 20
  • 55
6
votes
1 answer

How to run multiple API call simultaneously using async/await in swift?

As per the new Structured Concurrency in Swift, we can await a API call which is done in an async context, But I want to make multiple API calls simultaneously, for example, currently If add the API calls one after another, profileData = await…
Let's_Create
  • 2,963
  • 3
  • 14
  • 33
6
votes
2 answers

swift async function is being run on the main thread in some cases when run from task

In this case the async function reads a file and returns the parsed contents. In my view I want to load the contents off of the main thread, and then update the view once complete. I've used this pattern in various places and noticed that in some…
Avba
  • 14,822
  • 20
  • 92
  • 192
6
votes
1 answer

Swift async/await in for loop

I am scratching my head on new async/await pattern in Swift 5.5 announced in WWDC 2021 and there seems to be lot of learning involved and not as easy to grasp as is pretended to be. I just saw this for loop for instance in WWDC video: for await…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
6
votes
1 answer

TaskGroup `async` vs. `spawn`

Does anyone know, in the new Swift async/await stuff, is there any difference between TaskGroup async and spawn, or are they pure synonyms? (If they are synonyms, I rather like spawn better. async looks like we're opening an async block, and that's…
matt
  • 515,959
  • 87
  • 875
  • 1,141