Skip to main content
The 2024 Developer Survey results are live! See the results

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.

swift
0 votes
0 answers
4 views

When i choose 3rd date the date range won't be nil in swift

i use AirBnb's horizon calendar and the issue is when i click on a date out of range i cant make the selectedDateRange nil. In this date picking logic what am i missing? .days { day in DayView(...
Ali Düşkün's user avatar
0 votes
0 answers
11 views

How to manage global state in SwiftUI and persist it

Continuing learning SwiftUI (which is so much fun) I'm doubting the way I'm managing (and storing) global state in my app and storing it. There are two categories of data that I need to manage. The ...
Pieter's user avatar
  • 133
0 votes
0 answers
7 views

StoreKit 2 Xcode Manage Transactions - subscription purchased but "unfinished"?

I am using SubscriptionStoreView in conjunction with the modifiers .onInAppPurchaseCompletion, .subscriptionStatusTask, and .manageSubscriptionSheet to allow my users to choose from either a monthly ...
KatM's user avatar
  • 95
0 votes
0 answers
8 views

How to force releasing memory

I’m trying to iterate over a large file tree reading URL’s and creating hash values, but there’s a memory leak I can’t fix. The consumed memory is growing until the app stopp working. For testing ...
MatFetsch's user avatar
0 votes
1 answer
18 views

Is it safe to call an optional closure without [weak self]?

I have two classes, class A and class B. In class A I have declared an optional closure and from class B I am calling that closure. In class B, you can see in callTapA function I am calling the ...
M A Russel's user avatar
  • 1,557
0 votes
0 answers
12 views

What is the proper way to refactor a class from @ObservableObject to @Observable?

I would like to refactor the following code using @Observable instead of @ObservableObject. import Foundation import FirebaseAuth enum AuthenticationState { case unauthenticated case ...
LeEuler's user avatar
  • 41
0 votes
0 answers
9 views

Autofill suggestions not showing up for QR-based verification code

I am trying to integrate autofill for a verification code in one of my iOS projects. I have added an apple-app-site-association file to my domain. It was integrated successfully, as now the iOS ...
deaddroid's user avatar
  • 430
0 votes
0 answers
9 views

Limitations about Indexed Items for Spotlight with CSSearchableIndex and Performance?

Is there a limit for number of items (CSSearchableItem) in Core Spotlight CSSearchableIndex in iOS 9? According to this topic, the number of indexes I can add is 32767. Won't there be performance ...
Hakan Or's user avatar
0 votes
0 answers
29 views

An iOS application crashed or was closed, how do know which screen was last viewed by the user?

An iOS application crashed or was closed by the user or closed because the device has no battery, how I retrieve the information for which screen was last viewed by the user? I want to save this ...
user26383060's user avatar
1 vote
0 answers
12 views

Issue with Dequeuing Custom Cells in Main Storyboard

I'm encountering an NSInternalInconsistencyException when trying to dequeue custom cells designed in XIB files in my main storyboard. The error message is: unable to dequeue a cell with identifier ...
bumblebee's user avatar
-1 votes
0 answers
16 views

How should SwiftUI accessibiltyActions be announced in VoiceOver?

I'm trying to add accessibilityActions to specific views in an app I'm working on for a client. I'm using the accessibilityAction(named:) viewModifier. I can't share the client code, but it's ...
Duncan C's user avatar
  • 131k
0 votes
0 answers
17 views

OSLog sometimes shows error instead of including string

Logger().fault("Example: \(myStr, privacy: .public)") Why do I get the following instead of the contents of myStr sometimes? myStr looks fine in the debugger and not like this. Example: <...
John's user avatar
  • 1,264
1 vote
1 answer
29 views

How can I identify and delete dead code in Xcode Swift

Is there a way to get Xcode to show a warning/error for unused functions and properties? I have some dead dummy code left over from refactoring but no way to easily identify and delete it. I'm in a ...
etayluz's user avatar
  • 16.3k
-1 votes
0 answers
12 views

I want to create a feature on my ipa which allows people to go onto the files of the ipa and import their own .json file which appears in the app

I don't know how to do this I have not tried anything yet, I don't even know where to start to be honest I am new to coding and was curious to see how this would work, if someone can put me in the ...
Trendy Trooper's user avatar
0 votes
0 answers
39 views

View in infinite creation loop

In my app, the navigation should be ArmyListView -> ArmyListDetailsView -> IncludedUnitScreenView My ArmyListView screen creates a NavigationStack and moving on to the ArmyListDetailsView works ...
Doug Idle's user avatar
0 votes
0 answers
10 views

Keyboard Extension Input Field Not Working

I've been working on a custom keyboard extension and encountering an issue where I can't input text into the Custom TextField. Even when the TextField is selected (indicator is on), the input still ...
Muhammad Bilal's user avatar
0 votes
1 answer
24 views

Get the bounds of overflowing objects to shrink to parent view

I'm making a representation of the unit circle and I have the point labels arranged in a circle. I know the origin of the labels are at the center, so they overflow the parent. Whats the best way to ...
Ashbury's user avatar
  • 2,335
0 votes
0 answers
14 views

After adding Notification Extension, my apple pay and push notifications for fastlane stopped working

I am using fastlane to create and submit an application to testflight. Everything worked until I added Notification Content Extension and Notification Service Extension. Now apple pay and push ...
mike's user avatar
  • 1
0 votes
0 answers
11 views

Live Activity not workin on Simulator

Live Activity isn't working on the iOS 17.5 Simulator but works on a physical device. When I first close the app, it updates once, but then nothing updates anymore. Supports Live Activities - YES ...
Ömer faruk Bozbulut's user avatar
0 votes
0 answers
12 views

CMAC with Swift OpenSSL 3 fails at init

I'm trying to compute a CMAC using OpenSSL 3 EVP_MAC APIs in Swift, and I am stuck at the EVP_MAC_init call, which always fails. I've tried many different combinations, without success. If anyone ...
Thomas Debouverie's user avatar
0 votes
2 answers
53 views

Swift not using initialiser when creating a view

I have a specific SwiftUI View that I am using to add and edit variables. When I add the variable, I call the view using this: Button(action: { showingDeviceManager.toggle() }, label: { Text(&...
Echo31416's user avatar
-1 votes
1 answer
28 views

Gradient layer on UiView

I am trying to provide gradient layer to the View on created XIB. I have to give gradient colors with combination of 5 colors. But unfortunately gradient is not working. These are colors array:- let ...
Akash Singh's user avatar
-2 votes
0 answers
24 views

SwiftUI modifier and view parameter [closed]

Is they any simple way to find a current Modifiers for a view . Working on multiple framework often is not easy to remember every Modifiers for a view In flutter all view modifier will be as parameter ...
PRATHIV's user avatar
  • 458
1 vote
1 answer
24 views

How to change UIAlertAction's image position?

I want to create a popover menu with UIAlertController which includes customize action items, user can define style like font-size , background-color, alignment and Icon Position (Leading / Trailing), ...
William Wang's user avatar
0 votes
0 answers
39 views

Main thread being blocked fetching from Firebase

Every time the posts are fetched from cache or not from cache, the app freezes and main thread seems to be blocked. What is causing it to be blocked in this code? I noticed it happens when a lot of ...
CobraCodes's user avatar
1 vote
1 answer
21 views

SwiftUI Xcode project - Can I change the struct name in the automatically generated file whose name is the app's name?

Suppose I create a new Xcode project of SwiftUI with app name "ExampleApp", then Xcode automatically generates a file ExampleAppApp.swift that contains the following code: @main struct ...
HelloVictor2000's user avatar
0 votes
1 answer
25 views

Bug in the implementation of system, dark and light mode where system theme isn't getting applied to the sheet

I am implementing a picker view which has 3 options: system, light and dark mode. Whenever an option is selected, it gets persisted to whole app by the use of @AppStorage. Light mode and dark mode ...
Rajbeer Singh's user avatar
0 votes
0 answers
18 views

Changing the background color of .searchable search bar is not setting it to normal black color

I have a search bar set up using the .searchable modifier on a SwiftUI View, and I would like to set the background color of the bar text field to be Color.black. I've attempted to change the ...
Matias Carulli's user avatar
0 votes
1 answer
30 views

Swift – Authenticate and simultaneously fetch user Id from Firebase

Very new to Swift and just following some tutorials I have a loginViewViewModel with a function to login a user. However, I also want to grab the uid from Firebase after .signIn and print to the ...
Samuel's user avatar
  • 5,871
0 votes
1 answer
31 views

Button only working around the button and not on the actual button

My Add assignment button only works when I click the red around and not the button that I created. I'm new and was wondering how to fix this.Photo of issue ZStack { Spacer() Button(action: { ...
Immanuel Vafaee's user avatar
0 votes
0 answers
8 views

SCNView merging two SCNNode

I'm working with Apple's RoomPlan and I'm struggling to load all the nodes from the CapturedStructure into SCNNode. I was able to browse through the floors, doors, windows, walls and object and render ...
Renan Camaforte's user avatar
0 votes
0 answers
18 views

iOS 17 MapKit .standard doesn't allow for a globe view when zoomed out

I'm working on setting up a very basic mapview with MapKit for my iPhone on iOS 17. I noticed that the Apple maps app doesn't have this issue but I really couldn't find much about this topic other ...
Zach042's user avatar
  • 21
0 votes
1 answer
24 views

Easing functions for using CADisplayLink

I need to manually animate something frame by frame in SwiftUI using CADisplayLink, which provides me frame to frame updates. For animating a value from a to b in a linear fashion, the implementation ...
bli00's user avatar
  • 2,541
0 votes
1 answer
20 views

How can I make my app appear higher than all other apps in Spotlight search results?

I’m working on an iOS application and would like to improve its visibility in Spotlight search results. Specifically, I want my app’s content to appear higher in the search results compared to other ...
Hakan Or's user avatar
-1 votes
0 answers
32 views

How can I clear a Combine debounce when a trigger value is found? [closed]

How can I setup a Combine pipeline that will debounce all values except for a trigger value which will publish immediately and flush/clear any pending value in the debounce? For a simple example case… ...
DanubePM's user avatar
  • 1,713
-1 votes
0 answers
36 views

How to move between view controllers with using custom navigation controller? [closed]

I have a custom navigation controller. I want to go to next controller. And show custom back button. I use this code to do it: func collectionView(_ collectionView: UICollectionView, didSelectItemAt ...
user's user avatar
  • 27
-1 votes
1 answer
58 views

How to use a function outside of the class?

I want to use this code: var buttonNumber = 0 func settings() { CNavigationViewController().contextMenu() } class CNavigationViewController: UINavigationController { ... @objc func ...
user's user avatar
  • 27
1 vote
1 answer
29 views

How can I mock an Objective-C class from Swift code for unit testing?

I'm trying to unit test a Swift class that depends on an Objective-C class. Call these SwiftClass and ObjcClass. I created a protocol that contains the methods/properties of ObjcClass that SwiftClass ...
Cassiterite's user avatar
0 votes
2 answers
49 views

Parent view ignore safe area but child view respect safe area

I am building a custom full screen cover that can be dragged down with a gesture like the podcast app. For the transition modifier with edge as bottom, it uses the bottom edge of the parent view thus ...
SwiftUIEnthusiast's user avatar
0 votes
1 answer
59 views

Managing ViewModels

This is more of an architectural question. I am working on a personal project using the Rick and Morty API, following this design, building with Swift and SwiftUI using the MVVM pattern. I have ...
Saladel's user avatar
  • 53
-2 votes
0 answers
38 views

How to integrate SwiftBullet SDK in a Swift project using Xcode?

I am new to Swift and Xcode, and I'm currently trying to integrate the SwiftBullet SDK into my SwiftUI project. I have followed the documentation, but I haven't been able to achieve the desired ...
thantzin win's user avatar
-3 votes
0 answers
20 views

How can I create a Numbers spreadsheet programmatically using Swift? [closed]

I want to have ability for my app to export data so user can print it. Data represented as list of words. I am thought about .xlsx format but didn't found easy way to do it. Is any API or Lib or any ...
Danil's user avatar
  • 63
0 votes
1 answer
55 views

How can I make my method async when it calls a library method requiring a completion?

In my app I'm using a third party library, AppGuard, to log users in. To do so the library has a method that takes a completion. Recently I got the suggestion to convert it to async/await as actors ...
Pieter's user avatar
  • 133
-1 votes
0 answers
23 views

How to call "AutoFill Password" dialog like click password button in iOS system keyboard?

I want call "AutoFill Password" dialog like click password button in iOS system keyboard. Is Any iOS API can do that? I've try using ASAuthorizationPasswordRequest and ...
Shilai Zhang's user avatar
0 votes
1 answer
37 views

iOS Notification is permanently denied - can't find in settings for manual enabling

I implemented push notification in iOS and android, using APN Apple Push notification and firebase respectively. In iOS first request for notification is from native side (appDelegate/swift code) and ...
Inquisitive Owl's user avatar
0 votes
0 answers
36 views

App crashing when task switches to another app and goes to background when a task is ongoing

I have a view that is set to disappear after 5 seconds and it's working okay normally aside from this scenario: user does the action that makes the view show user immediately switch to another app ...
smekers's user avatar
  • 13
0 votes
0 answers
15 views

Lagging Video Feed Using VNGeneratePersonSegmentationRequest in macOS Camera Extension App

I'm developing a macOS application using Swift and a camera extension. I'm utilizing the Vision framework's VNGeneratePersonSegmentationRequest to apply a background blur effect. However, I'm ...
Yogeshwar Shelke's user avatar
0 votes
0 answers
39 views

Custom Scroll View Indicator does not animate correctly

I created a custom scrollview indicator that can be dragged but it doesn't work completely right and it's not smooth. It has a few problems: Scroll End does not fire when the scroll view stops so the ...
Ahmed Zaidan's user avatar
1 vote
0 answers
26 views

Swift faster way to retrieve exif data from PHAsset

I'm working on a photos app on iOS, where I have to extract the camera information of user's photos for displaying. The problem I am facing is that the process turns out to be extremely slow and ...
Mev's user avatar
  • 1,583
1 vote
1 answer
49 views

Update values in a dictionary based on changes made to another dictionary

I would like to know if there is a way to automatically update the value in a dictionary based on changes made to values in another dictionary. I have 2 dictionaries as follows: enum ...
Bob's user avatar
  • 192

15 30 50 per page