Dive into the world of programming languages used for app development.

All subtopics
Posts under Programming Languages topic

Post

Replies

Boosts

Views

Activity

Bridging Header doesn't seem to include my Swift class
I think have done everything by the book. I added a small Swift file to my Objective-C project. This is code in the project, not in a framework, so I did not use the public keyword: import Foundation @objc TestClass: NSObject { @objc init(){} } Adding this file prompted creating a bridging header and it should have added TestClass into it. I added the import to the Objective-C .m file. This didn't produce an error so the file must be there: #import "SoftServePro-Bridging-Header.h" I made a property for an instance of the class in the .h file: @property(nonatomic,strong) TestClass *test; I cleaned the project and did one compile for the precompiler to populate the bridging header. I have set Defines Module to Yes in Build Settings -> Packaging. I added a line in the .m code to create a TestClass: self.test=[[TestClass alloc]init]; And for my trouble I get the error message Now, this looks to me like TestClass is not in my bridging header because if it were it should know exactly what TestClass is, not just consider it a forward declaration. I haven't figured out any way to look at the actual contents of the bridging header after precompile, so I don't know if TestClass is there or not. The ONLY thing that I have not followed is that the documentation I have read says to put the bridging header in the same folder as the .xcodeproj file, but Xcode put it in with all the source code files (one folder down) and who am I to argue with Xcode??
3
0
1.3k
Mar ’26
Data Disappeared
Hi, writing a database app for storing equipment details. Spent the day doing minor changes and tidying with many backups made, and always re-building to check its all working. Everything ok but then next build looses all data, what's the best thing to check to see if the data is still there, any help would be fantastic.
1
0
1.3k
Mar ’26
Apple Silicon calling printf
What is the proper way to pass arguments to printf with multiple variables using ARM64 Apple Silicon? Example: fOutputStr: .asciz "Element[%d] = %d\n" // formated output string for an output of: Element[4] = 9 This code (see below) works on Raspberry Pi 5, on my Mac Studio, I am getting this output, Element[9] = 1871655168 What do I need to do to use printf from an assembly language call with multiple variables? I am using the following code. ` .align 2 // memory alignment model for 64-bit ARMc #if defined(APPLE) .global _main // Provide program starting address to linker Mac OS _main: #else .global main // Raspian and Linux main: #endif // stack frame work setup START stp x29, x30, [sp, -16]! str x20, [sp, -16]! mov x29, sp // stack frame work setup END // setup printf call #if defined(APPLE) adrp x0, fOutputStr@PAGE add x0, x0, fOutputStr@PAGEOFF #else ldr x0, =fOutputStr #endif mov w1, #4 mov w2, #9 print_brk: #if defined(APPLE) stp X0, X1, [SP, #-16]! stp X2, X3, [SP, #-16]! bl _printf ldp X2, X3, [SP], #16 ldp X0, X1, [SP], #16 #else bl printf #endif done: // closing stack frame work ldr x20, [sp],16 ldp x29, x30, [sp],16 // exit mov w0, wzr ret .data .align 4 // intArrayPtr: .word 3,7,5,2,4,8 // word, each value is offset by 4 fOutputStr: .asciz "Element[%d] = %d\n" // formated output string
6
1
843
Mar ’26
Why is the Documentation full of Conundrums?
I'm trying to learn and focus on the task and your examples keep having hidden conundrums in them. Here is an example that got me snagged for hours last night going, Well what the F do they want me to name it? What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for... My friend said to me that this is a common thing you will have to do and they were right however... What are you asking me to do? Get stuck on the variable naming problem where I'm going... Yeah those are math terms from 20+ years ago and I have no idea how to classify those terms... Are you asking me that? No. So why is that in the problem. These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.
3
0
360
Mar ’26
Attached macro loses generated source file
I’m seeing what looks like a compiler / macro-expansion / build-pipeline issue. Environment: Xcode 26.4 RC (17E192, latest); I believe it is also reproducible on earlier versions. github source code I reduced this to a very small macOS/iOS app plus a local macro package. The app logic is trivial, but app exits immediately on launch with code 138 Important observations: If I inline everything into a single file, the problem disappears. I also see an error like this during investigation: The file path does not exist on the file system: /var/folders/.../swift-generated-sources/@__swiftmacro_18MacroFeedbackRepro20MountActivationState17PreservedRawValuefMm_.swift That makes me suspect this is not an application logic issue, but something in macro expansion / generated source handling / compiler pipeline.
2
0
1.9k
Mar ’26
On iPad with Swift Playgrounds: How to open chapter as a playground?
Note On a Mac with Xcode installed, or on an iPad with Swift Playgrounds, you can open this chapter as a playground. Playgrounds allow you to edit the code listings and see the results immediately. (Note in page 3) (I would like to open the chapter or book: Swift Programming Language in Swift Playground on iPad) https://books.apple.com/ve/book/the-swift-programming-language-swift-5-7-beta/id1002622538?l=en-GB Best regards
2
0
1.7k
3w
Undefined symbol
Is anyone have this problem on xcode 26 ? Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility50 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility51 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility56 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibilityConcurrency Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibilityDynamicReplacements
2
1
1.9k
2w
Error in running ROOT analysis software after the recent update of MacOs and Xcode
I am facing errors in running ROOT on my M4 Air below is the terminal output can you please help me akshatsharma@akshats-MacBook-Air ~ % root /Users/akshatsharma/Applications/ROOT_v6.36.06/etc/cling/std_darwin.modulemap:73:64: error: header '__type_traits/add_lvalue_reference.h' not found module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" } ^ input_line_1:1:10: note: submodule of top-level module 'std' implicitly imported here #include <new> ^ Warning in cling::IncrementalParser::CheckABICompatibility(): Failed to extract C++ standard library version. Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with _LIBCPP_ABI_VERSION '1' Extraction of runtime standard library version was: '' ------------------------------------------------------------------ | Welcome to ROOT 6.36.06 https://root.cern | | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers | | Built for macosxarm64 on Dec 27 2025, 07:23:39 | | From tags/6-36-06@6-36-06 | | With Apple clang version 17.0.0 (clang-1700.6.3.2) | | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' | ------------------------------------------------------------------ root [0] new TBrowser IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]! You are probably missing the definition of cling::runtime::gCling Maybe you need to load the corresponding shared library? root [1] .q akshatsharma@akshats-MacBook-Air ~ % xcode-select --install xcode-select: note: Command line tools are already installed. Use "Software Update" in System Settings or the softwareupdate command line interface to install updates akshatsharma@akshats-MacBook-Air ~ % xcode-select -p /Library/Developer/CommandLineTools akshatsharma@akshats-MacBook-Air ~ % sudo xcode-select --reset akshatsharma@akshats-MacBook-Air ~ % sudo xcodebuild -license accept xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance akshatsharma@akshats-MacBook-Air ~ % unset DYLD_LIBRARY_PATH unset LD_LIBRARY_PATH source /Users/akshatsharma/applications/ROOT_v6.36.06/bin/thisroot.sh root -l /Users/akshatsharma/Applications/ROOT_v6.36.06/etc/cling/std_darwin.modulemap:73:64: error: header '__type_traits/add_lvalue_reference.h' not found module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" } ^ input_line_1:1:10: note: submodule of top-level module 'std' implicitly imported here #include <new> ^ Warning in cling::IncrementalParser::CheckABICompatibility(): Failed to extract C++ standard library version. Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with _LIBCPP_ABI_VERSION '1' Extraction of runtime standard library version was: '' root [0] new TBrowser IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]! You are probably missing the definition of cling::runtime::gCling Maybe you need to load the corresponding shared library? root
1
0
664
1w
macOS main.swift and Main actor-isolated conformance cannot be used in nonisolated context
For a simple, resourceless cocoa apps I used to manually setup the application lifecycle (mimicking what's documented here: https://developer.apple.com/documentation/appkit/nsapplication), so my main.swift would look like: import Cocoa let delegate = SomeDelegate() _ = NSApplication.shared NSApp.delegate = delegate NSApp.run() This triggers a warning in Xcode 26.2: "Main actor-isolated conformance of SomeDelegate cannot be used in nonisolated context; this is an error in Swift 6 language mode". so what is the recommended way to refactor above so that it is Swift 6 compliant?
1
0
745
1w
String Catalogs auto-generated symbols located in Swift Packages with default Main Actor isolation don't compile with Xcode 26.4
Hello, I've already reported this issue via Feedback Assistant a month ago (FB22340897) but it's still open and I'd like to know whether I can expect something to be changed regarding it. Here are the details: It seems that Xcode 26.4 started specifying nonisolated for the resourceBundleDescription in the generated stringSymbols files for Swift packages: from: private let resourceBundleDescription = LocalizedStringResource.BundleDescription.atURL(resourceBundle.bundleURL) to: private nonisolated let resourceBundleDescription = LocalizedStringResource.BundleDescription.atURL(resourceBundle.bundleURL) This causes a compilation error: Main actor-isolated default value in a nonisolated context when the Package.swift for the Swift Package in which the string catalog is located specifies: swiftSettings: [.defaultIsolation(MainActor.self)] Since all tools (String Catalogs, Swift Packages and default actor isolation to be Main Actor) are recommended by Apple, I believe it should be possible to use all these together like before Xcode 26.4.
1
0
871
1w
Misleading error on ForEach
During refactoring of an app I made a typo which leads to a misleading error message in Xcode 26.4. I could reproduce it with a small sample code in Swift Playground. Is it a bug which should be reported? Details: I have an array containing two strings. Using a ForEach loop is fine: ForEach(appData.dataArray, id: \.self) { value in Text("\(value.subject)\t\(value.room)") } but with a typo in the Text line I got an error on the ForEach line: ForEach(appData.dataArray, id: \.self) { value in --> Cannot convert value of type '[MyArray]' to expected argument type 'Binding' Text("\(value.subject)\t\(value.subject.room)") } Complete sample code from Swift Playground (macOS 26): import SwiftUI class MyArray : Hashable, Equatable, Identifiable, ObservableObject, Codable { let id = UUID() @Published var subject: String @Published var room : String private enum CodingKeys : String, CodingKey { case subject case room } init(subject : String, room : String) { self.subject = subject self.room = room } func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(subject, forKey: .subject) try container.encode(room, forKey: .room) } required init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) subject = try container.decode(String.self, forKey: .subject) room = try container.decode(String.self, forKey: .room) } static func == (v1: MyArray, v2: MyArray) -> Bool { let result = v1.id == v2.id return result } func hash(into hasher: inout Hasher) { hasher.combine(id) } } public class AppData : ObservableObject { @Published var dataArray : [MyArray] = [] init() { dataArray.append(MyArray(subject: "Foo", room: "Bar")) dataArray.append(MyArray(subject: "Foo", room: "Batz")) } } struct ContentView: View { @EnvironmentObject var appData : AppData var body: some View { ForEach(appData.dataArray, id: \.self) { value in Text("\(value.subject)\t\(value.subject.room)") // to fix the error replace value.subject.room with value.room } } } @main struct MyApp: App { var appData = AppData() var body: some Scene { WindowGroup { ContentView() .environmentObject(appData) } } }
2
0
1.2k
1w
A Repeating timer in Swift 6
I'm using that repeating timer for processing information repeatedly: actor RepeatingTimer { private var task: Task<Void, Never>? private var isPaused = false func start(duration: Double, onTick: @escaping () -> Void) { task?.cancel() // Cancel any existing timer isPaused = false task = Task { while !Task.isCancelled { // Check if paused if !isPaused { onTick() } // Sleep for the interval try? await Task.sleep(for: .seconds(duration)) } } } func pause() { isPaused = true } func resume() { isPaused = false } func stop() { task?.cancel() task = nil } }` Yet when I call it from another actor with: await timer.start(duration: interval, onTick:{ self.process() }) I get: Sending 'self'-isolated value of non-Sendable type '() -> ()' to actor-isolated instance method 'start(duration:onTick:)' risks causing races in between 'self'-isolated and actor-isolated uses Is there some more stable option for managing repeating timers, or how to solve this error?
1
0
56
16h
iOS 18.6.2 issue with "let"
I am facing an issue in SwiftUI on iOS 18.6.2 where passing a value to a destination view during navigation is not working as expected. In my implementation, I pass a billerId as a constant (let) to the destination view (BillersItemView) using NavigationLink. This approach works correctly across all previous iOS versions. However, on iOS 18.6.2, the destination view does not receive the updated value properly. Before triggering navigation, the value is correctly updated in the ViewModel, but the destination view seems to receive an incorrect or stale value, which affects further API calls and UI rendering. This pattern of passing immutable (let) values is used throughout the app and has always worked reliably, so this behavior appears inconsistent and possibly related to changes in SwiftUI navigation handling in iOS 18.6.2. Could you please confirm if this is a known issue or if there are any recommended changes or workarounds to ensure correct data passing in this scenario? It can be very likely a SwiftUI navigation state timing issue that became more visible in iOS 18.x, especially with NavigationLink(isActive:) + external @ObservedObject updates. But i need to know why this is working in others. I have attached the relevant code for your reference. import SwiftUI struct CategoryBillersView: View { @ObservedObject var billPaymentsVM: BillPaymentsViewModel @State private var goToBillerItem = false var body: some View { NavigationView { VStack { NavigationLink(isActive: $goToBillerItem) { BillersItemView( billPaymentsVM: billPaymentsVM, billerId: billPaymentsVM.selectedBillerId ) } label: { EmptyView() } Button("Go to Biller") { billPaymentsVM.selectedBillerId = 123 goToBillerItem = true } } } } } struct BillersItemView: View { @ObservedObject var billPaymentsVM: BillPaymentsViewModel let billerId: Int var body: some View { Text("Biller ID: \(billerId)") .onAppear { billPaymentsVM.fetchBiller(billerId: billerId) } } } class BillPaymentsViewModel: ObservableObject { @Published var selectedBillerId: Int = 0 }
0
0
28
9h
Bridging Header doesn't seem to include my Swift class
I think have done everything by the book. I added a small Swift file to my Objective-C project. This is code in the project, not in a framework, so I did not use the public keyword: import Foundation @objc TestClass: NSObject { @objc init(){} } Adding this file prompted creating a bridging header and it should have added TestClass into it. I added the import to the Objective-C .m file. This didn't produce an error so the file must be there: #import "SoftServePro-Bridging-Header.h" I made a property for an instance of the class in the .h file: @property(nonatomic,strong) TestClass *test; I cleaned the project and did one compile for the precompiler to populate the bridging header. I have set Defines Module to Yes in Build Settings -> Packaging. I added a line in the .m code to create a TestClass: self.test=[[TestClass alloc]init]; And for my trouble I get the error message Now, this looks to me like TestClass is not in my bridging header because if it were it should know exactly what TestClass is, not just consider it a forward declaration. I haven't figured out any way to look at the actual contents of the bridging header after precompile, so I don't know if TestClass is there or not. The ONLY thing that I have not followed is that the documentation I have read says to put the bridging header in the same folder as the .xcodeproj file, but Xcode put it in with all the source code files (one folder down) and who am I to argue with Xcode??
Replies
3
Boosts
0
Views
1.3k
Activity
Mar ’26
Data Disappeared
Hi, writing a database app for storing equipment details. Spent the day doing minor changes and tidying with many backups made, and always re-building to check its all working. Everything ok but then next build looses all data, what's the best thing to check to see if the data is still there, any help would be fantastic.
Replies
1
Boosts
0
Views
1.3k
Activity
Mar ’26
Apple Silicon calling printf
What is the proper way to pass arguments to printf with multiple variables using ARM64 Apple Silicon? Example: fOutputStr: .asciz "Element[%d] = %d\n" // formated output string for an output of: Element[4] = 9 This code (see below) works on Raspberry Pi 5, on my Mac Studio, I am getting this output, Element[9] = 1871655168 What do I need to do to use printf from an assembly language call with multiple variables? I am using the following code. ` .align 2 // memory alignment model for 64-bit ARMc #if defined(APPLE) .global _main // Provide program starting address to linker Mac OS _main: #else .global main // Raspian and Linux main: #endif // stack frame work setup START stp x29, x30, [sp, -16]! str x20, [sp, -16]! mov x29, sp // stack frame work setup END // setup printf call #if defined(APPLE) adrp x0, fOutputStr@PAGE add x0, x0, fOutputStr@PAGEOFF #else ldr x0, =fOutputStr #endif mov w1, #4 mov w2, #9 print_brk: #if defined(APPLE) stp X0, X1, [SP, #-16]! stp X2, X3, [SP, #-16]! bl _printf ldp X2, X3, [SP], #16 ldp X0, X1, [SP], #16 #else bl printf #endif done: // closing stack frame work ldr x20, [sp],16 ldp x29, x30, [sp],16 // exit mov w0, wzr ret .data .align 4 // intArrayPtr: .word 3,7,5,2,4,8 // word, each value is offset by 4 fOutputStr: .asciz "Element[%d] = %d\n" // formated output string
Replies
6
Boosts
1
Views
843
Activity
Mar ’26
Why is the Documentation full of Conundrums?
I'm trying to learn and focus on the task and your examples keep having hidden conundrums in them. Here is an example that got me snagged for hours last night going, Well what the F do they want me to name it? What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for... My friend said to me that this is a common thing you will have to do and they were right however... What are you asking me to do? Get stuck on the variable naming problem where I'm going... Yeah those are math terms from 20+ years ago and I have no idea how to classify those terms... Are you asking me that? No. So why is that in the problem. These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.
Replies
3
Boosts
0
Views
360
Activity
Mar ’26
Attached macro loses generated source file
I’m seeing what looks like a compiler / macro-expansion / build-pipeline issue. Environment: Xcode 26.4 RC (17E192, latest); I believe it is also reproducible on earlier versions. github source code I reduced this to a very small macOS/iOS app plus a local macro package. The app logic is trivial, but app exits immediately on launch with code 138 Important observations: If I inline everything into a single file, the problem disappears. I also see an error like this during investigation: The file path does not exist on the file system: /var/folders/.../swift-generated-sources/@__swiftmacro_18MacroFeedbackRepro20MountActivationState17PreservedRawValuefMm_.swift That makes me suspect this is not an application logic issue, but something in macro expansion / generated source handling / compiler pipeline.
Replies
2
Boosts
0
Views
1.9k
Activity
Mar ’26
How works Experiment (Documentation) in Swift Playground?
Experiment Create a constant with an explicit type of Float and a value of 4. https://docs.swift.org/swift-book/documentation/the-swift-programming-language/guidedtour
Replies
3
Boosts
0
Views
2.2k
Activity
Mar ’26
On iPad with Swift Playgrounds: How to open chapter as a playground?
Note On a Mac with Xcode installed, or on an iPad with Swift Playgrounds, you can open this chapter as a playground. Playgrounds allow you to edit the code listings and see the results immediately. (Note in page 3) (I would like to open the chapter or book: Swift Programming Language in Swift Playground on iPad) https://books.apple.com/ve/book/the-swift-programming-language-swift-5-7-beta/id1002622538?l=en-GB Best regards
Replies
2
Boosts
0
Views
1.7k
Activity
3w
The Swift Programming Language Book
Does anyone know if there will be a Swift 6 version of "The Swift Programming Language" book and if so, when it will be released for Apple Books?
Replies
5
Boosts
0
Views
1.4k
Activity
3w
Undefined symbol
Is anyone have this problem on xcode 26 ? Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility50 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility51 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility56 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibilityConcurrency Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibilityDynamicReplacements
Replies
2
Boosts
1
Views
1.9k
Activity
2w
Error in running ROOT analysis software after the recent update of MacOs and Xcode
I am facing errors in running ROOT on my M4 Air below is the terminal output can you please help me akshatsharma@akshats-MacBook-Air ~ % root /Users/akshatsharma/Applications/ROOT_v6.36.06/etc/cling/std_darwin.modulemap:73:64: error: header '__type_traits/add_lvalue_reference.h' not found module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" } ^ input_line_1:1:10: note: submodule of top-level module 'std' implicitly imported here #include <new> ^ Warning in cling::IncrementalParser::CheckABICompatibility(): Failed to extract C++ standard library version. Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with _LIBCPP_ABI_VERSION '1' Extraction of runtime standard library version was: '' ------------------------------------------------------------------ | Welcome to ROOT 6.36.06 https://root.cern | | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers | | Built for macosxarm64 on Dec 27 2025, 07:23:39 | | From tags/6-36-06@6-36-06 | | With Apple clang version 17.0.0 (clang-1700.6.3.2) | | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' | ------------------------------------------------------------------ root [0] new TBrowser IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]! You are probably missing the definition of cling::runtime::gCling Maybe you need to load the corresponding shared library? root [1] .q akshatsharma@akshats-MacBook-Air ~ % xcode-select --install xcode-select: note: Command line tools are already installed. Use "Software Update" in System Settings or the softwareupdate command line interface to install updates akshatsharma@akshats-MacBook-Air ~ % xcode-select -p /Library/Developer/CommandLineTools akshatsharma@akshats-MacBook-Air ~ % sudo xcode-select --reset akshatsharma@akshats-MacBook-Air ~ % sudo xcodebuild -license accept xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance akshatsharma@akshats-MacBook-Air ~ % unset DYLD_LIBRARY_PATH unset LD_LIBRARY_PATH source /Users/akshatsharma/applications/ROOT_v6.36.06/bin/thisroot.sh root -l /Users/akshatsharma/Applications/ROOT_v6.36.06/etc/cling/std_darwin.modulemap:73:64: error: header '__type_traits/add_lvalue_reference.h' not found module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" } ^ input_line_1:1:10: note: submodule of top-level module 'std' implicitly imported here #include <new> ^ Warning in cling::IncrementalParser::CheckABICompatibility(): Failed to extract C++ standard library version. Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with _LIBCPP_ABI_VERSION '1' Extraction of runtime standard library version was: '' root [0] new TBrowser IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]! You are probably missing the definition of cling::runtime::gCling Maybe you need to load the corresponding shared library? root
Replies
1
Boosts
0
Views
664
Activity
1w
macOS main.swift and Main actor-isolated conformance cannot be used in nonisolated context
For a simple, resourceless cocoa apps I used to manually setup the application lifecycle (mimicking what's documented here: https://developer.apple.com/documentation/appkit/nsapplication), so my main.swift would look like: import Cocoa let delegate = SomeDelegate() _ = NSApplication.shared NSApp.delegate = delegate NSApp.run() This triggers a warning in Xcode 26.2: "Main actor-isolated conformance of SomeDelegate cannot be used in nonisolated context; this is an error in Swift 6 language mode". so what is the recommended way to refactor above so that it is Swift 6 compliant?
Replies
1
Boosts
0
Views
745
Activity
1w
Add a DancingCreatures view
I'm almost having a heart attack with this "a DancingCreatures view" issue. I must be really dumb I've tried everything and the question just won't move forward. Someone, for the love of God, explain to me what it would be.
Replies
0
Boosts
0
Views
868
Activity
1w
String Catalogs auto-generated symbols located in Swift Packages with default Main Actor isolation don't compile with Xcode 26.4
Hello, I've already reported this issue via Feedback Assistant a month ago (FB22340897) but it's still open and I'd like to know whether I can expect something to be changed regarding it. Here are the details: It seems that Xcode 26.4 started specifying nonisolated for the resourceBundleDescription in the generated stringSymbols files for Swift packages: from: private let resourceBundleDescription = LocalizedStringResource.BundleDescription.atURL(resourceBundle.bundleURL) to: private nonisolated let resourceBundleDescription = LocalizedStringResource.BundleDescription.atURL(resourceBundle.bundleURL) This causes a compilation error: Main actor-isolated default value in a nonisolated context when the Package.swift for the Swift Package in which the string catalog is located specifies: swiftSettings: [.defaultIsolation(MainActor.self)] Since all tools (String Catalogs, Swift Packages and default actor isolation to be Main Actor) are recommended by Apple, I believe it should be possible to use all these together like before Xcode 26.4.
Replies
1
Boosts
0
Views
871
Activity
1w
Misleading error on ForEach
During refactoring of an app I made a typo which leads to a misleading error message in Xcode 26.4. I could reproduce it with a small sample code in Swift Playground. Is it a bug which should be reported? Details: I have an array containing two strings. Using a ForEach loop is fine: ForEach(appData.dataArray, id: \.self) { value in Text("\(value.subject)\t\(value.room)") } but with a typo in the Text line I got an error on the ForEach line: ForEach(appData.dataArray, id: \.self) { value in --> Cannot convert value of type '[MyArray]' to expected argument type 'Binding' Text("\(value.subject)\t\(value.subject.room)") } Complete sample code from Swift Playground (macOS 26): import SwiftUI class MyArray : Hashable, Equatable, Identifiable, ObservableObject, Codable { let id = UUID() @Published var subject: String @Published var room : String private enum CodingKeys : String, CodingKey { case subject case room } init(subject : String, room : String) { self.subject = subject self.room = room } func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(subject, forKey: .subject) try container.encode(room, forKey: .room) } required init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) subject = try container.decode(String.self, forKey: .subject) room = try container.decode(String.self, forKey: .room) } static func == (v1: MyArray, v2: MyArray) -> Bool { let result = v1.id == v2.id return result } func hash(into hasher: inout Hasher) { hasher.combine(id) } } public class AppData : ObservableObject { @Published var dataArray : [MyArray] = [] init() { dataArray.append(MyArray(subject: "Foo", room: "Bar")) dataArray.append(MyArray(subject: "Foo", room: "Batz")) } } struct ContentView: View { @EnvironmentObject var appData : AppData var body: some View { ForEach(appData.dataArray, id: \.self) { value in Text("\(value.subject)\t\(value.subject.room)") // to fix the error replace value.subject.room with value.room } } } @main struct MyApp: App { var appData = AppData() var body: some Scene { WindowGroup { ContentView() .environmentObject(appData) } } }
Replies
2
Boosts
0
Views
1.2k
Activity
1w
A Repeating timer in Swift 6
I'm using that repeating timer for processing information repeatedly: actor RepeatingTimer { private var task: Task<Void, Never>? private var isPaused = false func start(duration: Double, onTick: @escaping () -> Void) { task?.cancel() // Cancel any existing timer isPaused = false task = Task { while !Task.isCancelled { // Check if paused if !isPaused { onTick() } // Sleep for the interval try? await Task.sleep(for: .seconds(duration)) } } } func pause() { isPaused = true } func resume() { isPaused = false } func stop() { task?.cancel() task = nil } }` Yet when I call it from another actor with: await timer.start(duration: interval, onTick:{ self.process() }) I get: Sending 'self'-isolated value of non-Sendable type '() -> ()' to actor-isolated instance method 'start(duration:onTick:)' risks causing races in between 'self'-isolated and actor-isolated uses Is there some more stable option for managing repeating timers, or how to solve this error?
Replies
1
Boosts
0
Views
56
Activity
16h
iOS 18.6.2 issue with "let"
I am facing an issue in SwiftUI on iOS 18.6.2 where passing a value to a destination view during navigation is not working as expected. In my implementation, I pass a billerId as a constant (let) to the destination view (BillersItemView) using NavigationLink. This approach works correctly across all previous iOS versions. However, on iOS 18.6.2, the destination view does not receive the updated value properly. Before triggering navigation, the value is correctly updated in the ViewModel, but the destination view seems to receive an incorrect or stale value, which affects further API calls and UI rendering. This pattern of passing immutable (let) values is used throughout the app and has always worked reliably, so this behavior appears inconsistent and possibly related to changes in SwiftUI navigation handling in iOS 18.6.2. Could you please confirm if this is a known issue or if there are any recommended changes or workarounds to ensure correct data passing in this scenario? It can be very likely a SwiftUI navigation state timing issue that became more visible in iOS 18.x, especially with NavigationLink(isActive:) + external @ObservedObject updates. But i need to know why this is working in others. I have attached the relevant code for your reference. import SwiftUI struct CategoryBillersView: View { @ObservedObject var billPaymentsVM: BillPaymentsViewModel @State private var goToBillerItem = false var body: some View { NavigationView { VStack { NavigationLink(isActive: $goToBillerItem) { BillersItemView( billPaymentsVM: billPaymentsVM, billerId: billPaymentsVM.selectedBillerId ) } label: { EmptyView() } Button("Go to Biller") { billPaymentsVM.selectedBillerId = 123 goToBillerItem = true } } } } } struct BillersItemView: View { @ObservedObject var billPaymentsVM: BillPaymentsViewModel let billerId: Int var body: some View { Text("Biller ID: \(billerId)") .onAppear { billPaymentsVM.fetchBiller(billerId: billerId) } } } class BillPaymentsViewModel: ObservableObject { @Published var selectedBillerId: Int = 0 }
Replies
0
Boosts
0
Views
28
Activity
9h