Post

Replies

Boosts

Views

Activity

Reply to Compile for different macOS versions
Sorry about the poorly formatted comment. I guess you can't include code blocks in comments, and I can't find a way to delete my comment, so here it is again, in a more readable format. Thank you for your speedy reply, but I must still be missing something. I created a simple macOS app and modified the ContenView struct. struct ContentView: View {     var text: String {         if #available(macOS 12, *) {             return "Hello, world! OSX12"         } else {             return "Hello, world! OSX11"         }     }     var body: some View {         Text(text)             .padding()     } } ` But no matter how I set the macOS Deployment Target in the project or deployment target in the target, it always displays Hello, world OSX 12 when I run it. Thanks
Nov ’21
Reply to 403 Error with URLSession.downloadTask (SwiftUI)
More information: I copied the download code from this program and created a new program. It is able to download the file (getting an HTTP status code of 200). So I now think there is something cached in the original program that is causing it to be blocked. If this were a browser, I would clear the caches/cookies/etc. How can I do that with URLSession? I deleted the CACHES folder under the Library/Containers. I even deleted the entire sandbox under Library/Containers (the program rebuilt it). Still getting the 403 error.
Nov ’21
Reply to What is the replacement for OSAtomicCompareAndSwap32Barrier?
In this case, I found an answer. My C++ is rusty, but this works. The purpose of the call was to increment a pointer (mTimeBoundsQueuePtr) in a thread-safe manner. In CARingBuffer.h, at the top of the file, I added #include <atomic> and changed the declaration of mTimeBoundsQueuePtr at the bottom from UInt32 mTimeBoundsQueuePtr; to std::atomic<UInt32> mTimeBoundsQueuePtr; Then in CARingBuffer.cpp, I changed the last line of CARingBuffer::SetTimeBounds from CAAtomicCompareAndSwap32Barrier(mTimeBoundsQueuePtr, mTimeBoundsQueuePtr + 1, (SInt32*)&mTimeBoundsQueuePtr); to mTimeBoundsQueuePtr++;
Apr ’22
Reply to What is causing this error?
I am also seeing the CoreVideo messages reported in the other thread, but I suppress them by adding -cv_note 0 to the startup parameters. The issue is that this is creating a purple warning triangle in Xcode near the right side of the Xcode window. The warning has < and > indicators to view the previous and next issue. If I click either of those indicators, Xcode crashes. The error log indicates that Xcode is accessing an empty list. If I remove the call to Map() and re-run, the purple warning at the right side goes away, but one shows up to the right of the Scheme/Title bar at the top of the Xcode window. If I hover over that, the tip is Show Runtime Issues. If I click it it brings up the runtime issues navigator which is empty. I would like to know what's different about your setup that you are not getting the error message, or what's wrong with my setup. This is just a code snippet that reproduces the error for me. As to whether it runs correctly or not, that's not the issue. I don't like ignoring log noise in the output window, but if I have to start ignoring runtime issues in the issues navigator, that really reduces the usefulness of the issues navigator. I recompiled an MapKit app that I wrote a few months ago. It does not show this issue. The app was developed with a previous version of Xcode, but I just compiled it with the current version. No purple error issues.
Apr ’22
Reply to What is causing this error?
I figured it out. The warning is correct, the examples in Apple's documentation are incorrect. The following is from the DH entry for Map: struct AppleParkMap: View { @State private var region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 37.334_900, longitude: -122.009_020), latitudinalMeters: 750, longitudinalMeters: 750 ) var body: some View { Map(coordinateRegion: $region) } } This code is very similar to what I originally posted. It generates the same error. The issue is that the region object passed as a binding to the Map() constructor is part of the view's state. The Map object is modifying the binding as it is updating the view which is trying to update the view's state. The fix that works is to have the region be part of a ViewModel. class VM: NSObject, ObservableObject { @Published var region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 37.334_900, longitude: -122.009_020), latitudinalMeters: 750, longitudinalMeters: 750 ) } struct ContentView: View { @State private var vm = VM() var body: some View { Map(coordinateRegion: $vm.region) } } This code works without the issue.
Apr ’22
Reply to How to keep a Settings scene from slowing a Mac app?
Okay, this makes no sense, or I am obviously missing something in my understanding of SwiftUI. If I declare my Settings scene as: Settings { FCCDatabaseSettings(fccData: fccData) } Where FCCDatabaseSettings is a view and fccData is an @StateObject, the map does not drag smoothly. If, OTOH, I declare it as: Settings { SettingsWrapper(fccData: fccData) } Where SettingsWrapper is a view that simply calls FCCDatabaseSettings struct SettingsWrapper: View { @ObservedObject var fccData: FCCData var body: some View { FCCDatabaseSettings(fccData: fccData) } } The map drags smoothly. What is going on?
May ’22