Posts

Post not yet marked as solved
2 Replies
560 Views
I have developer documentation that contains links that are now dead. How can I find the post that this link used to refer to? https://forums.developer.apple.com/message/281700 I tried simply using the ID in the new URL format, but that didn't work. Eg: https://developer.apple.com/forums/thread/281700
Posted
by rnikander.
Last updated
.
Post marked as solved
12 Replies
4.2k Views
I have some code that used to run on my iPad Pro. Today I compiled it for iOS 13, with Xcode 11, and I get errors like this: validateComputeFunctionArguments:834: failed assertion `Compute Function(merge_layer): Shader uses texture(outTexture[1]) as read-write, but hardware does not support read-write texture of this pixel format.'The pixel format is showing as `MTLPixelFormatBGRA8Unorm`. That's what I expected.The debugger says the device has no support for writeable textures. (lldb) p device.readWriteTextureSupport (MTLReadWriteTextureTier) $R25 = tierNoneDid some devices lose support for texture writing in iOS 13?Rob
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
1 Replies
2.3k Views
I think they are, but I got myself into a situation with this error: // Inside a SwiftUI View struct... let cancelled: @MainActor () -> Void var body: some View { ... Button(action: self.cancelled) { Text("Cancel") } // Error here The compiler reports: Converting function value of type '@MainActor () -> Void' to '() -> Void' loses global actor 'MainActor' I originally put that attribute on the cancelled property, because in the passed-in closure, I was doing something that gave me an error about how I had to be on the MainActor.
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
10 Replies
3.5k Views
Hi, I want something like sandbox-exec, so I can run things that I don't trust, and restrict their ability to read or write files to only certain locations. Like most software devs I have to download and run lots of code from the internet and the danger of this really annoys me. Unfortunately sandbox-exec is marked as deprecated and the APIs in sandbox.h say "No longer supported". I notice there is some new stuff in the Apple docs about "hypervisors" and "virtualization". https://developer.apple.com/documentation/hypervisor https://developer.apple.com/documentation/virtualization Would these APIs allow me to start and control a virtual copy of my macOS, to serve like a sandbox? Are there other solutions that people use? As an example, say that I need to download and run a copy of memcached. It's a typical open source project – you unpack a source tgz, then run configure; make and get a binary. Now I want to run that without worrying that some hacker injected a piece of evil code to copy my files and send them somewhere. So I want to say "run this binary, while disallowing file reads and writes, except for directories X,Y,Z, and disallowing network connections, except for listening on port 1234."
Posted
by rnikander.
Last updated
.
Post marked as solved
1 Replies
648 Views
I watched a WWDC talk on LLDB, and they showed a nice trick of calling CATransaction.flush() from the debugger, to push changes to a UIView to the screen, even when the program was paused. Is there is a similar thing we can do with Metal? I'm using MTKView, but I can change to a lower level if that's required. The MTKView is paused, so I'm using setNeedsDisplay. As usual, I implement the draw delegate method to encode and commit a command buffer. If I do this from LLDB: metalView.setNeedsDisplay() CATransaction.flush() I can see that causes my draw function to run, but nothing shows up on screen. Is there something else we can do to flush those metal commands to the GPU and see them on screen while stepping through the program with the debugger?
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
0 Replies
298 Views
I'm using the Connect app on my iPad. I'm looking at an app that is barely used, and I see two written reviews. But in the App Store there is only one. Any ideas what could cause this? The review in question is reporting a possible bug, so I do wonder if this means the user retracted/deleted it.
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
1 Replies
567 Views
Why the does this display "Hello1" and not "HelloWorld"? Then if I put a space between them it works as expected. (macOS 12.0.1) struct ContentView: View {     var body: some View {         let t1 = Text("Hello").foregroundColor(.red)         let t2 = Text("World").foregroundColor(.blue)         Text("\(t1)\(t2)")             .padding()             .frame(width: 200)     } }
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
0 Replies
680 Views
I'm working on a drawing and painting program. When I turn my iPad, I detect the screen change and keep the drawing stable, while allowing the toolbars and things to rotate. But SwiftUI creates a disorienting animation of the main canvas anyway. Is there a way to shut that off?
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
0 Replies
297 Views
This minimal code demonstrates a problem I'm having. As you adjust the Slider (high precision numbers), the TextField sets the model, changing the number's precision to its format. But I only want it to use the 3-digit fraction for display, or if the user edits in the field. It shouldn't be mutating the model just because it's displaying the value, no? Is it a bug? It doesn't seem right to me. struct ContentView: View {     @State var number: Double = 0 // wrap binding to log the `set` calls     var textFieldBinding: Binding<Double> {         Binding { number } set: {             print("Setting from TextField: \($0)")             number = $0         }     }     var sliderBinding: Binding<Double> {         Binding { number } set: {             print("Setting from Slider: \($0)")             number = $0         }     }     var body: some View {         VStack {             TextField("Number", value: textFieldBinding, format: .number.precision(.fractionLength(3)))             Slider(value: sliderBinding, in: 0...5.0)         }.frame(maxWidth: 300)     } } When you drag the slider, you see stuff like: Setting from Slider: 1.0073260217905045 Setting from TextField: 1.007 ...
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
0 Replies
361 Views
I tried to replace UIKit's UIPinchGestureRecognizer with SwiftUI's MagnificationGesture, but it doesn't seem possible in my case. I use the location(in: UIView) function from the former, which allows me to zoom in on that point, specifically. It's a better experience when zooming in on an image. Can I get that info from the MaginificationGesture? In the example code I see only the CGFloat for the amount of magnification.
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
0 Replies
407 Views
I want to show a custom confirmation dialog on my iPad. It pops up looking utterly ridiculous because the size is way bigger than it needs - inches of padding on all sides. Is there still no way to control a sheet size on iPad? Example code: struct ContentView: View {     @State var showSheet = false     var body: some View {         Button("Show sheet") {             showSheet = true         }.sheet(isPresented: $showSheet) {             VStack(spacing: 0) {                 Text("Title")                 Divider()                 Text("Line 1")                 Text("Line 2. Blah blah blah blah.")                 Divider()                 HStack {                     Button("Cancel") { showSheet = false }                     Divider()                     Button("OK") { showSheet = false }                 }.fixedSize(horizontal: false, vertical: true)             }             .frame(minWidth: 0, minHeight: 0)             .fixedSize()         }     } } The result:
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
0 Replies
539 Views
Here's the entire app below. On iOS 15, it pops up blank. If you dismiss it and click "Share" again, then it looks right. Is this a bug, or is the code wrong? struct ContentView: View {     @State private var showShare = false     @State private var shareItems: [Any] = []     var body: some View {         VStack {             Text("Test ActivityViewController")             Button("Share") {                 share()             }.sheet(isPresented: $showShare) {                 print("dismissed")             } content: {                 ActivityViewController(activityItems: shareItems)             }         }     }     func share() {         shareItems = ["test"]         showShare = true     } } struct ActivityViewController: UIViewControllerRepresentable {     let activityItems: [Any]     func makeUIViewController(context: Context) -> UIActivityViewController {         let c = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)         return c     }     func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {} }
Posted
by rnikander.
Last updated
.
Post marked as solved
2 Replies
3.3k Views
Simple code like this gives an error. struct MyView: View {     @State private var test: Bool = false     var body: some View {           Text("Hello. \(test)") The error: Instance method 'appendInterpolation(_:formatter:)' requires that 'Bool' inherit from 'NSObject' What is going on?
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
0 Replies
355 Views
These are properties of Product. Both are type VerificationResult<Transaction>? and they seem very similar. What are some example situations where they would be different? It would be nice if the documentation discussed this.
Posted
by rnikander.
Last updated
.