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
333,573
questions
0
votes
0
answers
8
views
Cleaning navigation path
I'm developing an app in SwiftUI. In the Onboarding/Login/Signup navigation I append and subtract items from the navigation path array in order to navigate.
Once the user has logged in and has access ...
0
votes
0
answers
13
views
ForEach Statefullness Issue
In the following code, I am trying to build an exercise plan builder. Some aspects are still missing, but I've gotten to an unfortunate point where my state no longer works, likely down at the ...
0
votes
0
answers
5
views
Text in PDF appears to be overlapping when displayed in QLPreviewController
I have an iOS SwiftUI based application that uses the QLPreviewController to display a PDF document.
The user then goes on to fill some data in this document and then I upload this document to a ...
0
votes
0
answers
15
views
How to add a trend line to a line chart?
How can I create this desired chart using Apple's SwiftUI Charts?
Desired Chart (mockup) - The stepped line graph with data points is in blue and the trend line is in red:
A trend line needs to be ...
-1
votes
1
answer
15
views
How to programmatically get the html source code of a webkit application both for android and the iphone?
I'd like to use JavaScript for both android and the iPhone to display the HTML source code of the webkit application.
0
votes
0
answers
8
views
Using Apple's AsyncDNSResolver() and I need to change options servers and timeoutMillis. CAresDNSResolver.Options does not init
I am using Apple's AsyncDNSResolver (GitHub link) and would like to specify CAresDNSResolver.Options (timeout (2) and name servers (3) to query) when creating the AsyncDNSResolver(options:) (1) The ...
0
votes
1
answer
19
views
HStack Center alignment while keeping a VStack leading alignment
I am wanting to display three items across a screen equally. I am trying to make them all centered while having a leading alignment so when there is less than three they still maintain the same look. ...
-1
votes
0
answers
10
views
Flutter IOS app running issue in Emulator
I have Flutter Android and IOS app. The Android app runs fine. When I run the IOS app in the Emulator, I am getting the following errors.
Error (Xcode): Undefined symbol: nominal type descriptor for ...
0
votes
0
answers
32
views
Trouble displaying results from API to application [closed]
The code should essentially allows users to input a username, fetch related statistics, and display them in the UI. Data from the terminal indicates that the API is being retrieved successfully by ...
-1
votes
0
answers
24
views
UIbutton not responding consistently to touch event
I placed my UI button inside stack view of storyboard. and I enabled user interaction to both stack view and button. My button width and height are 20,20. I am using this UIbutton for checkbox ...
-1
votes
1
answer
19
views
Value of type 'GIDSignIn' has no member 'clientID'
enter image description here
I'm trying to set my client ID for Google Sign-In by assigning it to 'GIDSignIn.sharedInstance.clientID = "YOUR_CLIENT_ID"', but I'm encountering an error ...
1
vote
1
answer
41
views
Codable: Decode a String into a custom type (ISO 8601 Date, no time components)
Consider the following type:
public struct DocumentDate: Codable {
/// Year component of the date, Integer with no limitation on the range.
public let year: Int
/// Month component of the ...
1
vote
1
answer
48
views
Dangling pointer in concurrent read/write access to array
I am trying to understand what't wrong in my approach of access to array. In my app I got several not reproducible crashes with EXC_BAD_ACCESS KERN_INVALID_ADDRESS (some not 0 address). I suggested ...
0
votes
0
answers
15
views
Share Realm Data between iOS and WatchOS
i want to set the same filePath of the realm to save the data from my watchOS app and the mobile app . but i have tried but the same filePath not set.
i am using this code for set the same filePath of ...
-4
votes
0
answers
14
views
How can I make any MP3 audio file play when shared from my iOS app on WhatsApp? [closed]
Currently, when I share the audio file from my app to Skype, it becomes a downloadable file, but when I share it from Skype to WhatsApp, it becomes a playable audio file.
Is there a way to share an ...
0
votes
1
answer
29
views
how to work with initializers inside UIView?
Good afternoon everyone.
Guys, tell me how it is possible to initialize a custom parameter in view?
I want to pass the variable currentMenuItem inside the SampleSkinsCollectionView class.
I just can’t ...
0
votes
0
answers
22
views
SwiftUI onDrag - no feedback when drag ends
I've been exploring SwiftUI's onDrag modifier and got a little stumped by the fact that there doesn't seem to be any feedback when it ends. Some people suggested wiring and action to the ...
0
votes
1
answer
33
views
Is it required to define NSPrivacyCollectedDataType?
I got warning from apple when uploading my build
ITMS-91053: Missing API declaration - Your app’s code in the “Runner” file references one or more APIs that require reasons, including the following ...
0
votes
0
answers
31
views
SwiftUI debugging hangs with instruments
I have a little freeze for a a bit more than 1 second in my app (mac OS application) written in Swift / SwiftUI.
I tried to understand what is causing this problem.
Here is a screenshot of the ...
-3
votes
0
answers
22
views
New version of Google Maps SDK for iOS available: 8.5.0.0
I am using Google Map iOS SDK in swift package manager. Recently it stopped working, while checking I found this in the log
**Google Maps SDK for iOS version: 8.4.0.0
New version of Google Maps SDK ...
0
votes
1
answer
43
views
How does the operator "Pointwise Logical Not"(.!) work in Swift?
I learn Swift and use Swift operators (https://developer.apple.com/documentation/swift/operator-declarations) and saw the operator "Pointwise Logical Not"(.!). I started Googling and came ...
-1
votes
0
answers
24
views
SVG Color Change Using Color Palette Group from Array in iOS Swift [closed]
I am trying to achieve this functionality. Any advice on how I can achieve this?
I have find this functionality in some other app and I want to do same in my app.
Basically I want to have an array of ...
-1
votes
0
answers
18
views
SecAddSharedWebCredential does not open iCloud-keychain
If I use SecAddSharedWebCredential in the simulator to save a new pair of credentials, the save-to-keychain-alert opens correctly. But if I do it on the real device, it does not. I get the error ...
0
votes
0
answers
19
views
SwiftUI View Alignment Issue on Device Orientation Change and App Background to Foreground Transition
I'm encountering an issue with SwiftUI view alignment when the device orientation changes or when the app transitions from the background to the foreground. Despite my efforts, the views(Tabbar) seem ...
0
votes
1
answer
22
views
Swift SF Symbol Background Color
I want to set the background image of the "atom" symbol to white with opacity and put the in the centre of the circle.
Currently I have two separate snippets of code and can't workout how to ...
-1
votes
0
answers
44
views
Swift UI scrollable tab view
Since a tab view cannot be put inside a scroll view I am trying to use the new iOS 17 methods to make a custom tab using scroll views. In my code below If you comment out the first VStack that is ...
-2
votes
0
answers
16
views
Xcode Build Error: Could not build Objective-C module 'Firebase' and 'FirebaseDatabase'
I'm encountering an issue while trying to build my project in Xcode. Specifically, I'm getting the following error messages:
Could not build Objective-C module 'Firebase'
Could not build module '...
-1
votes
0
answers
31
views
Swift - How to execute the code after receiving a local notification?
I'm developing an application that uses a local notification mechanism.
I would like to execute some code (generate new notifications, update the sticker on the application icon) immediately after ...
0
votes
0
answers
9
views
iOS 17.3.1-Avplayer showing black screen while playing on iOS 17.3.1 with low probability
Some users of our app get a black screen when playing mp4 files on their phones. The users are all running iOS 17.3.1 and cannot catch the error message when playing a black screen.
override init(...
1
vote
2
answers
39
views
Multiple Fetches to count records from Core Data
I just want to share that I have a Core Data app with the following:
Each of them is a button where user can press to filter out the data for example (left to right): All, Inbox, Archive, More, Good, ...
0
votes
1
answer
42
views
XML Parsing getting string inside brakets <something="How to get this string"> [duplicate]
Here is a sample of the XML data I am trying to parse. Im having trouble figuring out how to parse the data inside the "" that is nested within the brackets i.e <something="How to ...
3
votes
1
answer
72
views
View not updating despite data updating with ObservableObject and EnvironmentObject
I have a pretty basic app that I've put together. Below I've given literally all of my code.
First of all, here is my main App struct where I use MyViewModel as the single source of truth:
@main
...
1
vote
0
answers
56
views
How to set up a UIHostingController with transparent background used as a child VC to pass through tap events to UIViews underneath?
I am trying to use SwiftUI and UIHostingController to add an overlay view to my existing UIKit view. In my case, it's presenting a stack of small semi-opaque notification bubbles over a complex video ...
-5
votes
1
answer
34
views
How to show sign-in screen before main screen?
I’m making an iOS app in Xcode using Swift. I have my launch screen and this goes to the main storyboard after it’s loaded. I have made a signup/login page and would like this to appear after the ...
1
vote
0
answers
29
views
How to extract text from a PDF using the PDFParser library?
I am new to Swift and iOS. I am working on a project where I need to extract text from a PDF. I know about the PDFKit framework, however, I get memory issues because I want to loop through the pages.
...
0
votes
0
answers
14
views
Widgets not load data from cache in ios
I am using "home_widget" flutter package to add home widget option to my flutter application.
I saved data from my flutter code to cache by "shared_prefences".
this is my swift ...
0
votes
0
answers
16
views
Custom WebView With Loading Indicator - Infinite Reload Cycle
I created the below custom WebView for my app - the goal is to show a loading indicator until the content is loaded successfully.
Everything works fine when
// if isLoading {
// ...
0
votes
0
answers
37
views
SVG & PDF render performance
We were using SVGs in our iOS project for our assets, but it looks like it was making our app much more heavy and now we also found that is making our app slower (causing flickering when scrolling).
...
0
votes
0
answers
23
views
How to correctly use 'document.delete' to delete Firestore data?
I'm new to using Firestore with Swift but I am making progress.
I am currently working on the gym plan creation section, with me just finishing up the views where a user can create their own plan and ...
0
votes
1
answer
22
views
When using an iPad and you change the screen from compact to regular, how do you keep the current view from going to a default view?
// BottomNavigationBarView.swift
// TrexlerLibrary
//
// Created by Emanuel Luna on 2/3/24.
//
import SwiftUI
import UserNotifications
enum ActiveView: String, Hashable {
case home
case ...
-1
votes
0
answers
41
views
swift_release_dealloc () causes random and systematic crash on iOS 17.x [closed]
In my app, a crash occurs only on iOS 17.xx versions when I establish a BLE connection to a peripheral, scan wifi networks and connect to one of them via BLE.
First, the code establishes a BLE ...
0
votes
0
answers
19
views
Corner Radius on preview layer of ImageCameraView
I've been trying to add a corner radius to the preview image being displayed in my view but nothing seems to be working. I've provided the code below. I have already applied this on the live camera ...
0
votes
2
answers
36
views
Initializer for conditional binding must have Optional type, not '[Int]'
I'm trying to write a function to read a matrix from the console and then rotate it, but I encounter an error: Initializer for conditional binding must have Optional type, not '[Int]'
I tried to ...
-1
votes
0
answers
23
views
FamilyActivityPicker on IOS Simulator not populating apps
I'm looking to make an app using the ScreenTime API and the Managed Settings Framework. I'm experimenting with the FamilyActivityPicker, but when i open it from the simulator i see only categories ...
-4
votes
0
answers
22
views
Automatically format phone number in UITextField like iPhone Contacts app and set appropriate cursor position automatically when deleting characters [duplicate]
I have a UITextField that I want to designate as a phone number input. I want it to work exactly like adding a phone number in the Contacts app on iOS. Every solution I have found works great on the ...
-1
votes
0
answers
18
views
Can we register a call in CallKit but should not show CallKit Push notification/UI in foreground?
I need to display an alert when an incoming call is received while the app is in the foreground. I receive these incoming call notifications via a socket connection, and I display the alert when such ...
-1
votes
0
answers
16
views
Swift Webview: The SafeArea seems to be removed when directed to a file URL and back [closed]
I'm debugging an existing application written in Swift as a WebView.
If I enter via Main, I can see that there is a View under ViewController with a SafeArea. When I start the application and navigate ...
-1
votes
0
answers
13
views
iOS widget cache surviving app update and reinstall
I am currently facing an issue with localized strings for our apps widget. We store some strings that we access using Bundle.main.localizedString(forKey:value:table:). For some reason, when updating ...
0
votes
0
answers
11
views
How to open Passcode field in Swift XCTest UI with iOS 17.4
This code works when I run it in the iOS Simulator with iOS 17.0.1:
let passcodeInput = springboard.secureTextFields["Passcode field"]
_ = passcodeInput.waitForExistence(timeout: 10)
...
0
votes
0
answers
8
views
Remove toolbar item in Safari App Extension
I have a safari app extension that has a toolbar item which shows a popover when clicked. However, I want to remove the entire toolbar item for my extension. Is that possible? If so, how do I do it?
I ...