Post

Replies

Boosts

Views

Activity

macOS 15 + Xcode 16 Beta 4 Problem with .task {} and async function
Hi everyone, when I was doing some testing on macOS 15 + Xcode 16 Beta 4 I noticed that my app's performance took a significant hit. A simple task that previously was completed within 15 seconds or less now took about a minute to complete. I came to the conclusion that the only plausible cause could be the way .task {} and asynchronous functions are handled. Starting several .task{} and calling async functions from within using macOS 14.5 and Xcode 15.4 results in following log output: task1 started task3 started task2 started task4 started --> task2 ended --> task3 ended --> task4 ended --> task1 ended` Running the same code on macOS 15.0 + Xcode 16 Beta 4 will result in the following log output: task1 started --> task1 ended task2 started --> task2 ended task3 started --> task3 ended task4 started --> task4 ended In the first example the code is executed in 'parallel'. All tasks are started and doing there respective work. In second example a task is started and we are waiting for it to complete before the other tasks are started. I could start to rewrite my code to get the results I desire, however I'm wondering if this is a bug in regards to macOS 15 + Xcode 16 Beta 4 and the way .task {} and asynchronous functions are handled. The output is quite different after all. What's your take on this? If you want to try it out for yourself you can use the following sample code: import SwiftUI struct ContentView: View { func func1() async -> Int { print("task1 started") var myInt: Int = 0 while myInt < 999999999 { myInt += 1 } print(" --> task1 ended") return 1 } func func2() async -> Int { print("task2 started") var myInt: Int = 0 while myInt < 999999 { myInt += 1 } print(" --> task2 ended") return 2 } func func3() async -> Int { print("task3 started") var myInt: Int = 0 while myInt < 999999 { myInt += 1 } print(" --> task3 ended") return 3 } func func4() async -> Int { print("task4 started") var myInt: Int = 0 while myInt < 999999999 { myInt += 1 } print(" --> task4 ended") return 4 } var body: some View { VStack { Text("Hello, world!") } .task { await func1() } .task { await func2() } .task { await func3() } .task { await func4() } } } #Preview { ContentView() }
1
0
582
Jul ’24
Xcode 16 Beta, macOS 15 Beta - Lists look different?!
Hi, I was testing my project running on macOS 15 Beta and Xcode 16 Beta and noticed that lists look slightly different. They generally look somewhat smaller, like the font size or spacing is now different. It's kinda hard to describe so I made screenshots depicting what the list looks like on macOS 14 + Xcode 15 and macOS 15 Beta + Xcode 16 Beta to show what I mean. Did you experience similar issues?
2
0
452
Jul ’24
Log Messages after upgrading to Xcode 15.3
Hello everyone, after upgrading to Xcode 15.3 I noticed several log messages that weren't present in my project before. Here are some examples: BOOL _NSPersistentUIDeleteItemAtFileURL(NSURL *const __strong) Failed to stat item: file:///Users/ ... savedState/restorecount.plist [SendServerMessage](com.apple.mobileasset.autoasset) ErrorHandler: Calling provided reply completion on connection error Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.mobileasset.autoasset was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.mobileasset.autoasset was invalidated: failed at lookup with error 159 - Sandbox restriction.} for connection <NSXPCConnection: 0x60000114ebc0> connection to service named com.apple.mobileasset.autoasset MA-auto{_failedLockContent} | failure reported by server | error:[NSCocoaErrorDomain:4099] I'm at a loss here. Can I treat these messages as log noise and safely ignore them or is there a way to fix them? Your help is greatly appreciated!
3
7
2.5k
Mar ’24
Swift - Correct syntax for "onChange" in Apple's sample code?
Hi everyone, I wanted to create a Table and make its rows sortable. For lack of better ideas how to do this I followed Apple's example here [https://developer.apple.com/documentation/swiftui/table) Here's the code in question: @State private var sortOrder = [KeyPathComparator(\Person.givenName)] var body: some View { Table(people, sortOrder: $sortOrder) { TableColumn("Given Name", value: \.givenName) TableColumn("Family Name", value: \.familyName) TableColumn("E-Mail address", value: \.emailAddress) } .onChange(of: sortOrder) { people.sort(using: $0) } } } To my amazement Xcode shows this message: 'onChange(of:perform:)' was deprecated in macOS 14.0: Use onChange with a two or zero parameter action closure instead. I find this message rather annoying. Do you have any ideas how to fix this?
1
0
967
Nov ’23
Xcode 15 refreshable list problem
Hi everyone, I'm having a problem with a refreshable list view in my App. This problem occurred just recently after making the switch to Xcode 15 + Sonoma + iOS 17 and did not occur with Xcode 14 + Ventura + iOS16. Let me show you what's bothering me. Look at this simple list. Now let's swipe down and reveal a file importer to choose a file and do some stuff (I edited the picture to hide the names of the files). This picture shows the file importer: After selecting a file this happens. See the that "progress indicator" thing? I think it's from the refreshable action, however it doesn't disappear. It will stay there indefinitely until you actual start swiping on the list. I'm pretty sure this "progress indicator" thing didn't stay there and disappeared when using Xcode 14 + Ventura + iOS16. Is it just me or does anybody have the same issue with Xcode 15 + Sonoma + iOS 17 ? Here is the code I used if you want to try it out for yourself. Here is the lContentView with the list: // // ContentView.swift // ProblemDebug // // Created by Olison on 29.09.23. // import SwiftUI struct ContentView: View { @State var fileImporterVisible: Bool = false var body: some View { List { Text("This is a refreshable list. Swipe down!") Text("Let's see what happens ...") } // REFRESHABLE .refreshable(action: { fileImporterVisible.toggle() }) // SHOW SHEET WHEN fileImporterVisible IS TOGGLED .sheet(isPresented: $fileImporterVisible, content: { ViewFileImporter(fileImporterVisible: $fileImporterVisible) }) } } #Preview { ContentView() } And here is the view with file importer: // // ViewFileImporter.swift // ProblemDebug // // Created by Olison on 29.09.23. // import SwiftUI struct ViewFileImporter: View { @Binding var fileImporterVisible: Bool var body: some View { ZStack { // DO SOMETHING ... } .fileImporter(isPresented: $fileImporterVisible, allowedContentTypes: [.plainText, .pdf], onCompletion: { result in switch result { case .success(let spxFileImporterURL): if spxFileImporterURL.startAccessingSecurityScopedResource() { print(spxFileImporterURL.absoluteString) } else { spxFileImporterURL.stopAccessingSecurityScopedResource() } case .failure(let spxFileImporterError): print(spxFileImporterError.localizedDescription) } }) } } #Preview { ViewFileImporter(fileImporterVisible: .constant(false)) }
1
0
881
Sep ’23
Xcode 15 CoreML Simulator Problem?
Hi everyone, I'm working on an app that uses a CoreML Model to make some predictions. The predicted values are visualized using a chart. It's working just fine when I'm running the app on an actual, physical device. However, it doesn't work in Simulator. To be more precise, it also used to work in Simulator using Xcode 14 + Ventura + iOS 16. After making the switch to Xcode 15 + Sonoma + iOS 17 yesterday the simulator doesn't show any results for my predictions. I also receive the following error messages: Operation not supported on this platform. MLModelAsset: load failed with error Error Domain=com.apple.CoreML Code=9 "Operation not supported on this platform." UserInfo={NSLocalizedDescription=Operation not supported on this platform.} Do you have any ideas how to fix this? Am I missing something that changed in iOS 17 or is this a bug?
1
2
756
Sep ’23