Post

Replies

Boosts

Views

Activity

Xcode build error about "cycle" that doesn't exist?
My project builds after a clean, but then fails to build. I can't understand these error messages. I have a macOS app target ("MyArchives") and a library target ("HelpPG") in the project. The app uses the library. Logically, there is no cycle. The library is an attempt to wrap PostgreSQL's libpq with some Swift stuff. It works when it runs after the clean build. I don't know what it's talking about with "headers before sources". That is already the case for the library target. There are no headers in the app target (which is all Swift). For readability, strings were substituted: [DEBUG] = /Users/me/Library/Developer/Xcode/DerivedData/MyArchives-flyvnqgqeolefjeztyopfnoaqmaj/Build/Products/Debug [UUID1] = bb030422ec80ba11076c24bcbd7fcd674d61e6313e2915ec58f3544977cb99a4 [UUID2] = bb030422ec80ba11076c24bcbd7fcd67db6f662ae7c65be0e231d735b4905dc3 Showing All Messages Cycle in dependencies between targets 'MyArchives' and 'HelpPG'; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources. Cycle path: MyArchives → HelpPG → MyArchives Cycle details: → Target 'MyArchives' has copy command from '[DEBUG]/libHelpPG.dylib' to '[DEBUG]/MyArchives.app/Contents/Frameworks/libHelpPG.dylib' → Target 'HelpPG' has link command with output '[DEBUG]/libHelpPG.dylib' ○ Target 'HelpPG' has copy command from '/usr/local/pgsql/lib/libpq.5.13.dylib' to '[DEBUG]/libpq.5.13.dylib' ○ Target 'HelpPG' has link command with output '[DEBUG]/libHelpPG.dylib' Raw dependency cycle trace: target: -> node: <all> -> command: <all> -> node: [DEBUG]/MyArchives.app/Contents/Frameworks/libHelpPG.dylib -> command: target-MyArchives-[UUID1]-:Debug:PBXCp [DEBUG]/libHelpPG.dylib [DEBUG]/MyArchives.app/Contents/Frameworks/libHelpPG.dylib -> node: [DEBUG]/libHelpPG.dylib/ -> directoryTreeSignature: ~ -> directoryContents: [DEBUG]/libHelpPG.dylib -> node: [DEBUG]/libHelpPG.dylib -> CYCLE POINT -> command: target-HelpPG-[UUID2]-:Debug:Ld [DEBUG]/libHelpPG.dylib normal -> node: [DEBUG]/libpq.5.13.dylib -> command: target-HelpPG-[UUID2]-:Debug:PBXCp /usr/local/pgsql/lib/libpq.5.13.dylib [DEBUG]/libpq.5.13.dylib -> node: <target-HelpPG-[UUID2]--phase1-compile-sources> -> command: Gate target-HelpPG-[UUID2]--phase1-compile-sources -> node: <Linked Binary [DEBUG]/libHelpPG.dylib> -> command: target-HelpPG-[UUID2]-:Debug:Ld [DEBUG]/libHelpPG.dylib normal
1
0
2.8k
Jan ’22
Full Disk Access, Run and Debug from Xcode?
I'm working on a macOS app that I want to give "Full Disk Access". When I run from Xcode, I get "permission denied" errors when reading a file in my home directory. What can I do so that I can run and debug from Xcode? I dragged the binary from the derived data folder to the System Preferences list for Full Disk Access, but that seems to do nothing.
5
0
2.9k
Dec ’21
Flush Metal rendering when program is paused in LLDB?
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?
1
0
900
Nov ’21
SwiftUI Text inside Text interpolation bug?
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)     } }
1
0
779
Nov ’21
Disable device rotation animation in SwiftUI?
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?
0
4
880
Oct ’21
TextField is mutating its model when not editing?
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 ...
0
0
371
Oct ’21
MagnificationGesture needs location?
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.
0
1
506
Oct ’21
StoreKit AppStore.sync throws userCancelled when there is no network
I have a button to restore purchases in my app. It calls AppStore.sync() as suggested by sample code. I'm testing in the sandbox, I put my device in airplane mode, and it throws StoreKitError.userCancelled. That's odd. Anyone else see this? I'd like to show an error alert popup to the user here, but I can't differentiate between this an a real userCancelled.
1
1
1.5k
Oct ’21
UIDocument no longer saving, error in URLByAppendingPathExtension
I've been working on an iOS app with UIDocuments. They were saving fine. Now all of a sudden, after unrelated changes, nothing will save. Here is the error printed in Xcode console: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL URLByAppendingPathExtension:]: component, components, or pathExtension cannot be nil.' log.debug("save to:\(self.document.fileURL)") document.save(to: document.fileURL, for: .forOverwriting) { success in ... } The log message there prints a valid URL.
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
1.1k
Oct ’21
SwiftUI sheet size control on iPad
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:
1
0
585
Sep ’21
Are Button actions on the MainActor?
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.
4
2
2.8k
Sep ’21