Post

Replies

Boosts

Views

Activity

SwiftUI against SwiftData is too fragile and error prone
The hardest part of SwiftUI programming is to correctly define the layers of references that you need as your app grows features. When you add Swift data to the mix, it hard to get much of anything correct. I have an application that interacts with the outside world via BLE and LocationManager. I need to preserve used BLE devices and then store their current state in a static Monitor type class structure. This monitor though, needs to have access to some SwiftData elements, and it is not clear from the documentation whether it's preferred to create multiple ModelContainer instances, when they might share a particular types management. This doesn't feel very safe, so it would then make more sense to have a ModelContainer stuck inside of some other static Monitor object that everyone would use to get the single ModelContainer that should be used. All of the context specific stacking of references in SwiftUI creates huge dependency chains, and it make the build of my application, currently to take 10s of minutes sometimes, when I have changes in flux and the compiler cannot make heads or tails out of broken references. We really need to find a way to get the compiler fixed so that as a Recursive Decent parser, it has an easier time finding a terminal state instead of crawling up and down the stack of references looking for a place that it can reach a terminal state. Not using ';' on every statement is a big part of the problem I feel...
1
0
837
Dec ’23
Location Access While Using not available in Securities for app
I have a new app that I am starting using the Map() component in iOS17. That struct, creates a class which is a CLLocationManagerDelegate, and instantiates a CLLocationManager. In the Target's Info settings, I have Privacy - Location Always and When In Use Usage Description Privacy - Location Always Usage Description Privacy - Location Usage Description all three set. I have another Map app with these set which doesn't have this problem, so I am confused about why, in Privacy & Security->Location Services, the App only shows two selections for Location Services. It shows only "Never" and "When I Share" selections with "When I Share" selected. The location manager reports error: The operation couldn’t be completed. (kCLErrorDomain error 1.) after I get the CLAuthorizationStatus(rawValue: 0) auth=CLAccuracyAuthorization(rawValue: 0) value in public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) status change in this callback for the delegate and then call: manager.requestAlwaysAuthorization() manager.startUpdatingLocation() What am I missing here?
0
0
497
Oct ’23
Marker with UIImage from CGImage does not show image
I am trying to place a custom image into a Marker using the following code. Marker( coordinate: CLLocationCoordinate2D( latitude: obj.loc.coordinate.latitude, longitude: obj.loc.coordinate.longitude), label: { Label { Text(obj.name) } icon: { Image(uiImage:imageFor(obj.imgSet, idx: obj.img )) } } ) The image is created from images that are 16 pixels high and have various images that are 16 pixels wide. Thus we compute and offset and then extract an image 16x16 at that offset. The Marker appears, but has a square that is white with in color, and the Label text does not appear on the Marker. var s_imgs : [UIImage] = [ UIImage(named: "Symbols")!, UIImage(named: "Symbols2")! ] func imageFor(_ symSet: Int, idx : Int ) -> UIImage { let w : Double = 16 let cgimg = s_imgs[symSet] .cgImage! .cropping(to: CGRect( x: w*Double(idx), y: 0, width: w, height: w))! return UIImage(cgImage: cgimg) } What do I need to do in order to have custom images within the Marker? It would be awesome to just have a View there and have the Marker change diameter to accommodate whatever View I needed to construct. Ideally, I just need the image to work, but that image will have a wide range of colors across all the images and thus I need some flexibility to manage background coloring dynamically as well. .tint could mostly work, but I'd like to but a border on the image with some white space inside the boarder before the image starts.
0
0
374
Oct ’23
Effectively rewrite URL in WKWebView due to poor page implementation
I have a web app that I want to create an app for. This web app returns URLs with hardcoded IP addresses in the URLs as "http://ip-addr/path/to/link". I need to rewrite the URLs to just be "/path/to/link" as they should of been coded. How can I either respond to URL usage with a rewritten URL, or will I have to see the page loaded, and then scan the document and rewrite it? Code examples would be great. Currently, I see the following error when I click on one of these broken links: 2022-09-28 22:11:46.716274-0500 MyApp[64870:4826597] [Process] 0x7fef18012020 - [pageProxyID=6, webPageID=7, PID=64876] WebPageProxy::didFailProvisionalLoadForFrame: frameID=3, domain=NSURLErrorDomain, code=-1004, isMainFrame=1 I can't find a delegate method that is actually being called, so I really don't know how to at least see the load fail and try and get the URL, edit it, and then call the WKWebView to load the edited URL. The primary issue is that this web page can be accessed from an external location and the address in the URL works for that external environment. But, on the local network, where the IP address is different, it also needs to work, and thus the need for the rewrite.
0
0
859
Sep ’22
Why is it so hard to use ManagedObjectContext and deal with propagation?
I created a simple master detail view with coredata. When I try to start filling it in with my needed application code, I find that I can not get coredata to function and insert my entities. The error value is nearly empty and NSError cast doesn't provide any information for what is actually the problem. This is very counter intuitive to debug through. When will this part of the SwingUI system/bridging be fixed? I thought it might actually be possible to finally do a very dynamic app with lots of content changes in the views. But apparently this stuff is still extremely fragile and frustratingly progress proof.Any hints on what to examine? I've set all the fields. I've tried using .environment(....) in every place I can to try and pass the correct context into the views.
0
0
500
Mar ’20