Post

Replies

Boosts

Views

Activity

App Sandbox Xcode launch argument file access
I want to be able to access a writable file directly in my Xcode project when I am under Xcode, but access to the bundled app version (as read-only) when running a normal version. The solution is easy, I provide "-EditBootstrapFile $(PROJECT_DIR)/SomePath" as launch argument in my Xcode Run scheme, then access the file. While executing, if I don't find "-EditBootstrapFile", I use the Bundle.main.url version as read-only. However, Sandbox interferes with my best intentions. I don't seem to find a way to allow the sandbox system to access that particular file. Since it's a bootstrapping file, it kinda beats the purpose to add up a new window and delay loading of the list of parameters, it's meant to be always present. So far, the only workaround I found is adding com.apple.security.temporary-exception.files.home-relative-path.read-write with /Developer/myproduct/SomePath in the entitlements, which is dumb, and mean I need to have two different entitlements for my code (one for xcode debugging and one for archiving) and the value is now hard-coded. Anyone has experience with this? I'm sure there's something easy I am missing, but for now, I lost a few hours and could still not figure it out.
1
0
1.3k
Feb ’23
Manage hit test mask in SwiftUI for an Image with transparency
Question says it all. I want the transparent pixels to pass through the taps / clicks / gestures, while the opaque pixels catches them. Obviously be able to control the behaviour would be even better, so I could ignore slightly translucent pixels too. Pre-processing is not possible, user images, so it's not easy. So far, the best I thought was to get a global gesture recognizer, and try to figure out where in my complex hierarchy this tap falls, and see if the image is underneath. But that seems overly complicated for something so simple and basic, really.
4
1
1.3k
Oct ’21
Rendering Surface Bounds determination
Good day, simple question. In TextKit2, there seems to be a Rendering Surface Bounds property. We currently have a text.boundingRect(with...) function call to determine some bounding properties, and this is the accepted proposal for most bounding retrieval, but I am not sure the operation is actually the Rendering Surface Bounds of a provided text, as described in the video. So ... let say I have such a text, and I want to get that fully enclosing bounds, what would be my best bet (cross-platform)
0
0
763
Jul ’21
SwiftUI iOS 14 keyboard issues in orientation changes
Consider the following sample code swift import SwiftUI struct ContentView: View {     @State var text = ""     @State var portrait = true     func updateInterfaceOrientation() {         guard let currentWindowScene = UIApplication.shared.connectedScenes.first(                 where: { $0.activationState == .foregroundActive }) as? UIWindowScene else {             return         }         self.portrait = currentWindowScene.interfaceOrientation.isPortrait     }     var body: some View {         ZStack {             if portrait {                 VStack {                     Spacer()                     TextField("", text: $text)                         .background(Color.gray)                 }             } else {                 VStack {                     Spacer()                     TextField("", text: $text)                         .background(Color.gray)                 }             }         }         .onAppear(perform: updateInterfaceOrientation)         .onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in             updateInterfaceOrientation()         }     } } Code is pretty straightforward and is the proposed way for SwiftUI's dynamic interfaces. IE: you double down on your elements, and the interface gets switched from one to the other. Now this piece of code, compared to the one without the if portrait has multiple issues because of the keyboard. When the portrait vs landscape gets changed, you lose the on-screen keyboard. I can kind-of live with that. iOS 14: When you have a on-screen keyboard in portrait mode, and you move to landscape mode, the zone stays higher on screen, as if the keyboard was actually there, but it's not. If you move back to portrait mode, the safe zone becomes 3/4 of the screen. I cannot live with that! Any clues? Happens with latest official and latest beta (.2)
2
0
1.8k
Feb ’21
macCatalyst TapGesture(count: 2) on a UIViewRepresentable's UIImageView
This is awkward. So I have my app that I have shipped on iOS, that works properly there. I have a gesture recognizer on the double-tap .gesture(TapGesture(count: 2)). This is on top of an image, that needs to be in UIImageView() through an UIViewRepresentable (because SVG and Image will not scale it properly, using the prerendered version instead). Now, if I put a .gesture(TapGesture()) instead, it works well. If I put a DragGesture(), it gets picked up immediately. But I cannot have the system detect the double-tap to save my life. I tried going inside the UIViewRepresentable, adding a #selector, but it will not get it. I tried overriding the touchesEnded globally, and it will not work either. I also tried sequencing TapGesture() to TapGesture(count:2) and it (incredibly) sometimes works, but something will make it stop working, so it's not reliable. It might be because of my scene too, it's really complex, something might interfere, but I have not found a way to debug the scene to know where the events are being sent off, know what interferes with what. And remember, it works perfectly on iOS, and it also works well with a normal SwiftUI Image. contentShape doesn't seem to have a result with that issue either. And again, putting a drag or a single tap works perfectly. It's just the double-tap that seems to fail me. Fixing it is something, but I'm also very curious on the way to debug such issues. Thank you!
0
0
733
Feb ’21
SwiftUI: Rename DocumentGroup files
Simple question: How do I set the name for a new file. Every document is written as "Untitled" on top of the page (Untitled 39 for example), and every document is saved as Untitled. This is a very sub-par experience. I follow the same example than Pages, and the first page they have is actually setting up the kind of document the person wishes to have from models, and it uses this title as document title (Empty Book model would lead to Empty Book 39 on the 39th empty book) Even better, the document title (Untitled) is written on top of the page, but I don't know of a way to actually interact with that name and having a tap that would rename it to something else. If I want to do some of these, what is the best way?
1
0
1.4k
Nov ’20
AirPrint paper format on iOS without accessing to Print dialog
I am looking for help on a proper IxD / UX on selecting a paper size, as well as .photo vs .general in the UIPrintInfo.outputType . My product requires to precisely know the paper format as output for the printer (including borders). On macOS, it's easy: you've got the usual Page Format, and you can poll the printer to retrieve the current format. On iOS, I don't have that luxury: the first time I get any mention of a current paper format is on the Print page, and then, it's too late to show up any User Interface. Even worse, there are only very broad guidelines on page format. Photo sometimes provides a 4x6, and General sometimes provides an A4 or Letter, but not always. So I try to figure out through the country, preparing A4 in most countries, and Letter in places where it's not available, which is not always the case. And end users are usually at a loss on their page formats (trying to reduce useless user interactions and questions). I know it's currently not feasible on the provided SDK, as everything needed is private. So my first bet is providing an adequate User Experience. But again, I cannot provide a pop-up on top the Print pop-up, I have yet to find a way to provide a shown tooltip when this is on. I could show a pop-up before saying the format could change, but it's really *****. And I have yet to figure out what to propose on the .photo settings for some initial paper format. (Supplemental question: I am happy to use one of my official tech support question, but is Apple answering interaction design questions through that channel too? I doubt they would provide me private SDK access merely by asking - any guidance on how to ask and get answered by the proper channels) Thank you!
1
0
1.4k
Sep ’20
SKStoreReviewController.requestReview(in:) and SwiftUI's Scene
In the latest iOS, the keyWindow automatic version of SKStoreReviewController.requestReview() got deprecated in favour of a new SKStoreReviewController.requestReview(in windowScene: UIWindowScene) version. Then, in the latest SwiftUI, the UIWindowScene got removed in favour of a new SwiftUI some Scene family. How do I efficiently tie the two together in a View without resorting to the key UIWindow?
2
0
3.4k
Jun ’20
Missing PDFKit on macOS (Xcode 12.0 beta (12A6159))
Good Tuesday morning, I hope everyone is having a blast in WWDC20 Online so far. Downloaded latest Xcode 12.0, tried compiling my software. Everything seems peachy, but importing PDFKit on macOS specifically seems to break. In documentation, there is no mention of removal, so I assume it's an omission or something that changed? Cheers Michel #if os(macOS) import PDFKit ... No such module 'PDFKit'
3
0
1.4k
Jun ’20