Questions tagged [swift]

Swift is a general-purpose programming language developed by Apple Inc first released in 2014 for its platforms and Linux. Swift is open-source. Use the tag only for questions about language features, or requiring code in Swift. Use the tags [ios], [ipados], [macos], [watch-os], [tvos], [swiftui], [cocoa-touch], and [cocoa] for (language-agnostic) questions about the platforms or frameworks.

314,981 questions
0votes
0answers
5views

How do I add JSON parameters to Moya library?

I'm trying to add parameters to OpenWeather's Geocoding API But I couldn't find how to add a "&lat=40&lon=40" for example Here's my implementation, what should I do instead? enum ...
0votes
3answers
18views

Adding a view modifier inside .onChange

Is it possible to add a view modifier inside .onChange? Simplified example: content .onChange(of: publishedValue) { content.foregroundColor(.red) } I have a theme that when changed needs to ...
-1votes
0answers
12views

How can I update the function in the protocol without Xcode error?

I want to update the function as in the comment, but I used this function in many places, so how can I update this function without making any changes? protocol Fooable { func foo1() //-> foo1(...
0votes
0answers
10views

Where is Swift Package Manager cache located (Swift 5.7)?

After retagging a git commit I'm no longer able to fetch the package, because SP Manager uses some cache which I can't find and clean. Getting error: Revision 30c16cab9c718416fee2191ff2ac0b6f91eeb511 ...
-1votes
0answers
19views

Swift - Handling special dynamic/random JSON keys [duplicate]

I know this has been asked multiple times, I've read all the similar questions but I can't wrap my head around it. My JSON structure looks like this; { "message": "Cart data ...
0votes
0answers
13views

How do I specify the headers directory for a objc target in Swift Package Manager's Package.swift?

I'm trying to convert a cocoapod project to a spm library. However, the swift target can't find this class in it's objc target dependency. Cannot find 'RMPhoneFormat' in scope The Resolve Packages ...
-2votes
2answers
34views

Downcast generic class

I've got a generic class based on some type, and a child class which specifies that type. However, the Swift compiler doesn't seem to be able to downcast the parent class with the correct type to the ...
0votes
1answer
32views

Swift : What is the equivalent of regions in Android Studio?

I'm used to code android applications, and I'm starting in Apple development. In Android studio, it's possible to surround a bloc of code within a region, like this : int a; float b;...
0votes
0answers
19views

Is it possible to use the beginBackgroundTask() API within SwiftUI lifecycle?

I need to run some code when the app is closed to remove the client from a game. To do this I'm wanting to execute a Google Cloud Function for the server to do the cleanup - the function works, I ...
0votes
2answers
42views

DateFormatter showing incorrect time

My requirement is to convert date string (in PHT) received from my API to another date string format. API Date String format: "MM/dd/yyyy HH:mma" eg. "06/28/2022 06:55PM" UI Date ...
0votes
2answers
19views

UIScrollView not showing inside UIStackView

I have one UIStackView that stacks vertically two horizontal UIStackViews. That worked just fine. But the first sub-UIStackView had too many elements so I decided to wrap it inside a scrollView. The ...
2votes
1answer
26views

App migrated to UIKit lifecycle doesn't call SceneDelegate

We migrated our app from the SwiftUI to the UIKit lifecycle and app containment, creating a standard AppDelegate, SceneDelegate, and updating the required info.plist properties. I didn't follow this ...
0votes
1answer
21views

Is there penalty in using too many EnvironmentObject?

I'm writing a keyboard extension which resources are more limited. I am trying to pick a code structure and need some help. The project will have multiple classes or struct to encapsulate a fair ...
0votes
0answers
22views

Unable to pass down returned value from now view to another

I have a view that returns a value called 'idd' in the form of a string: enter image description here Now I have a view called ListView where there is a navigationLink that essentially needs that ...
0votes
0answers
14views

Flutter iOS native navigation

I currently have the problem that I don't know how to give native a screen in iOS a callback function and a string. It is currently implemented as follows: import UIKit import Flutter import ...

153050per page