975 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
2
answers
162
views
How can I migrate NotificationCenter code to Swift 6 concurrency?
I’m migrating a NotificationManager class to Swift 6. This class is a small utility wrapper around NotificationCenterand has a method that lets users register a notification that will triggerunless ...
-2
votes
1
answer
101
views
UndoManager with MainActor isolated func
How do I use UndoManager with MainActor isolated functions? In this simple example I get
"Call to main actor-isolated instance method 'undoAction' in a
synchronous nonisolated context; this is ...
-1
votes
1
answer
39
views
XMLElement has no accessible initializers on Linux
I am trying to generate an XML document using Swift on Linux. But the following code doesn't compile:
let rootElement = XMLElement(name: "feed")
rootElement.setAttributesWith(["xmlns&...
0
votes
1
answer
118
views
How can I retrieve the CPU usage of my Mac in the form of a percentage and put that into an updating variable?
I'm coding a Mac app in SwiftUI 6.0.3 and Xcode 16. My Mac is up to date with macOS Sequoia 15.3.1. I'm trying to have a menu bar item that updates at an interval with the percentage of the CPU that I ...
user avatar
user28615420
0
votes
0
answers
209
views
CMake unable to 'find' Foundation framework on macOS 15.1.1 (24B91)
When I try a build, this is the error I see:
-- Adding CPU backend variant ggml-cpu:
CMake Error at ggml/src/ggml-metal/CMakeLists.txt:1 (find_library):
Could not find FOUNDATION_LIBRARY using the ...
0
votes
0
answers
83
views
How can I transfer data between the application target and the UI test target?
I have an application that needs to be tested (UI). The application uses different feature configurations, and I'm looking for a convenient way to turn features on/off for proper testing. What are ...
-6
votes
1
answer
189
views
Is there Swift 6 number formatting in string interpolation without "import Foundation"?
I like being able to do this:
print( "\("YYYY") \(454.90008)" )
but I want to do this:
print( "\("YYYY") \(String(format: "%.3f", 454.90008))" )
...
-1
votes
1
answer
97
views
Rounding/truncating decimal places from floats with NumberFormatter (Ubuntu 22.04)
i need 2 digits after the comma consistently but there are certain floats that just wont be formatted correctly? (as seen below) are the tricks around this?
code:
import Foundation
let floatNumber: ...
1
vote
1
answer
112
views
CPU Usage not updating
I’ve written SwiftUI code that uses Combine to display CPU usage metrics such as User, System, Nice, and Idle values for each core on the system. The functionality works initially in the sense that ...
-1
votes
1
answer
71
views
Unbox Error for override property in Swift?
import Foundation
enum OperationError: Error {
case ioError(_ message: String)
var localizedDescription: String {
switch self {
case .ioError(let message):
return ...
1
vote
1
answer
163
views
How to determine the continent name by a country code in Swift
I have an ISO two-letter country code (e.g., "US") and need to determine its continent's name.
I know about the continent property of Locale.Region, which is also a Locale.Region instance, ...
0
votes
1
answer
70
views
Exclusion of a directory from backup : NSURLIsExcludedFromBackupKey does not always stick even though setResourceValue has reported success
I want to exclude a directory in documents storage class from backup.
Setting exclusion attribute like so
+ (BOOL)kit_addSkipBackupAttributeForItemAtURL:(NSURL *)url
{
if (![[NSFileManager ...
1
vote
0
answers
69
views
exclude files from iCloud backup
I have a bug on my hands where icons, etc are being backed up to iCloud backup.
My first knee jerk reaction was that it's in the documents directory class but they are properly stowed in the ...
0
votes
2
answers
56
views
How to display "3 of 10 files" using localizedAdditionalDescription of NSProgress
I would like to utilize NSProgress localizedAdditionalDescription but I cannot figure out the combination to get it to format file count. Either i am not getting any suffix or I get bytes.
progress....
0
votes
1
answer
71
views
Error: Unnamed type used 'BOOL' in iOS project XCode
I am having project in XCode version: 15.4 using Swift for iOS development -> uiKit.
I have added the c++ class to my project.
MyStaticClass.h:
#ifndef MYSTATICCLASS_H
#define MYSTATICCLASS_H
...