Post

Replies

Boosts

Views

Activity

Mixing in-memory and persistent SwiftData containers in a Document-based App?
Hello, I'm trying to work on an iPadOS and macOS app that will rely on the document-based system to create some kind of orientation task to follow. Let say task1.myfile will be a check point regulation from NYC to SF and task2.myfile will be a visit as many key location as you can in SF. The file represent the specific landmark location and rules of the game. And once open, I will be able to read KML/GPS file to evaluate their score based with the current task. But opened GPS files does not have to be stored in the task file itself, it stay alongside. I wanted to use that scenario to experiment with SwiftData (I'm a long time CoreData user, I even wrote my own WebDAV based persistent store back in the day), and so, mix both on file and in memory persistent store, with distribution based on object class. With CoreData it would have been possible, but I do not see how to achieve that with SwiftData and DocumentGroup integration. Any idea how to do that?
1
0
84
2w
SwiftUI and MapKit on macOS, issue of screen to location conversion with toolbar
Hello I'm working on a SwiftUI map app and I'm having some issue with coordinates management. Here is the full explanation: My goal Having a Map view on a macOS app created with SwiftUI, which needs both a toolbar and a no status bar, I wants to be able to clic on the map to add an annotation at a user's chosen location. My issue The sample code I use works if I have no toolbar and status bar. When I have them, there is an offset in coordinates that I don't understand how to solve. Sample code Here is a code with the issue, if you run it you will see mis placed X marker. So, how can I fix the following sample code to have accurate management of the mouse location when adding an annotation in that context? import SwiftUI import MapKit struct MyPoint: Identifiable { var id = UUID() var name: String var location: CLLocationCoordinate2D } struct ContentView: View { @State var points: [MyPoint] = [MyPoint]() @State var status: String = "" var body: some View { VStack(spacing:0){ MapReader { mapReader in Map { ForEach(points) { point in Annotation(point.name, coordinate: point.location) { Text("╳") .font(.largeTitle) .bold(true) .foregroundStyle(.red) } } } .mapControlVisibility(.visible) .mapStyle(.imagery) .mapControls({ MapCompass() MapUserLocationButton() MapScaleView() }) .onContinuousHover(coordinateSpace: .local, perform: { phase in switch phase { case .active(let cGPoint): if let coordinates = mapReader.convert(cGPoint, from: .local) { status = "screen \(cGPoint.x), \(cGPoint.y) - loc \(coordinates.latitude), \(coordinates.longitude)" } else { status = "" } case .ended: status = "" } }) .onTapGesture(coordinateSpace: .local, perform: { screenCoord in if let location = mapReader.convert(screenCoord, from: .local) { points.append(.init(name: "screen click: \(screenCoord.x), \(screenCoord.y)\nloc \(location.latitude), \(location.longitude)", location: location)) } }) .toolbar { Text("A toolbar is needed") } } Text(status) .frame(maxWidth: .infinity) .background(.red) .foregroundColor(.white) } } }
0
0
523
Nov ’23
Run third part apps with argument from macOS sandbox
Hello I'm trying to make one of our internal app compliant with App Store rules for public release. The app is a custom Firefox launcher, that will be used to easily manage Firefox profile. Which mean part of the code will start Firefox with specifics args. And that's the part that does not fit well in the sandbox. What's the correct way to refactor the following code to be sandbox compatible?      let command = Process()     command.executableURL = URL(fileURLWithPath: "/usr/bin/open")     command.arguments = ["-n", "-a", "/Applications/Firefox.app", "--args", "--no-remote", "-P", name]     try? command.run() Right now with this code, Firefox open, but behave improperly, like if it was started from my own sandbox and could not load the selected profile. If I switch to NSWorkspace, the behavior is the same.
1
0
793
Dec ’21