Posts

Post marked as solved
1 Replies
1.1k Views
It's a simple question. I'm just trying to understand how these things fit together. Core Text doesn't seem to get updated much, but maybe that's because it's low level and doesn't need it. I assume it's still the recommended way to do low-level text things not handled by TextKit. ?
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
I'd like to use the new localization screenshots and test plans feature to take screenshots in different languages, for the app store. I end up with images that are half one screen and half another, like it's some kind of timing issue. My test code is below. Is it missing something that would give it the right timing on the screenshots?I wrote a UI test and set "Localization Screenshots" to "On" in the test plan's settings. The UI test walks through a few screens and the resulting test report has a few image files attached labeled "Localization screenshot". Some images are are split so that the left side is one view controller and the right side is another, like it captured a push navigation transition. Another image has two overlaid screens, each half faded.I'm running in the simulator. My test code looks like: func testTakeScreenshots() { let app = XCUIApplication() app.launch() // At workouts page app.tables["workouts"].cells.element(boundBy: 0).tap() // At first workout app.navigationBars.buttons["edit"].tap() // At workout edit screen, click first exercise app.tables.cells.element(boundBy: 0).tap() ... }
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
1 Replies
2.4k Views
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
Posted
by rnikander.
Last updated
.
Post marked as solved
4 Replies
3.2k Views
I'm surprised this simple code still doesn't work on iOS 13.3 / Xcode 11.3. On my iPhone SE it's almost all off screen.It's just two pieces of text, side by side, and two pickers, side by side. Anyone know a workaround? struct ContentView: View { @State var choice: Int = 10 @State var choice2: Int = 10 var body: some View { return VStack { HStack { Text("Some text here") Spacer() Text("Foo baz") } HStack { Picker(selection: self.$choice, label: Text("C1")) { ForEach(0..&lt;10) { n in Text("\(n) a").tag(n) } } Picker(selection: self.$choice2, label: Text("C2")) { ForEach(0..&lt;10) { n in Text("\(n) b").tag(n) } } } } } }
Posted
by rnikander.
Last updated
.
Post marked as solved
2 Replies
878 Views
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.
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
1 Replies
939 Views
I can't debug my metal shaders anymore. The GPU button just says this: I have a lot of metal code so I'm not sure what triggered it. The "?" button does nothing. Any pointers on where to look? Are there certain APIs that do this?
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
5 Replies
7.5k Views
My app crashes and Xcode shows no stack trace. It just pops up some line of assembly language in __pthread_kill, and shows this in the console: [error] precondition failure: invalid value type for attribute: 230424 (saw PreferenceKeys, expected ViewList) AttributeGraph precondition failure: invalid value type for attribute: 230424 (saw PreferenceKeys, expected ViewList). Seems like a bug in SwiftUI. Any ideas? This is on macOS 11.
Posted
by rnikander.
Last updated
.
Post marked as solved
1 Replies
1.1k Views
I have a UIScrollView, and its subview inside needs to respond to some touchesMoved events without scrolling. I've got it mostly working, but with one sticking point that confuses the user: if I touch and quickly move my finger, then the UIScrollView takes the gesture as a scroll, and never calls the touchesBegan, touchesMoved, etc., of its subview. However, if I touch, then pause for a bit, then drag, then things work as intended: the subview gets touchesBegan, touchesMoved, etc., and things are handled without any scrolling. On my UIScrollView, I've set: delaysContentTouches = false canCancelContentTouches = true And I've overrode touchesShouldCancel(in view: UIView). But that does not get called in the case when I quickly drag my finger. Is there something else I need to do?
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
3 Replies
4.1k Views
I'm wondering how SwiftUI updates work in connection with ObservableObjects. If a SwiftUI View depends on an `ObservableObject`, the object's `objectWillChange` publisher fires, and SwiftUI learns about the change, before the change happens. At this point, SwiftUI can't re-render a View, right? Because the new properties aren't there yet. So what does SwiftUI do? Does it schedule the change for later? That doesn't make sense either - how can it know when the object will be ready to be used in a new rendering of the UI? ~ Rob
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
0 Replies
555 Views
Here's a simple demo. I run it on macOS 12.1, compiled with Xcode 13.2. struct ContentView: View {     var body: some View {         VStack {             Text("ee")             Text("eé") Text("e\u{E9}") // "e with acute"             Text("ee\u{301}") // "combining acute"         }.font(.custom("Avenir", fixedSize: 18))          .padding(20)     } } In the 4rd one, the "e" is rendered in the wrong size/font. Screenshot: Other fonts do not have the problem. For example, "Avenir Next" and "Helvetica". Is there a way (in code) to tell which fonts can handle combining chars? Is this a bug? I notice the same thing happens when I use Core Text to draw the strings at a low level. So it's not just SwiftUI. In TextEdit, if have Avenir font, type "option-e" + "e" I get a nice letter. Maybe TextEdit is doing what Xcode did in the second line, and using the "e with acute" unicode character.
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
1 Replies
626 Views
Does anyone use the new hierarchical data List (ie, OutlineGroup) with a model where the tree data changes? I'm on Big Sur beta. I have code like this: List([treeRoot], children: \.children) { item in ... Say the treeRoot (observed object) gets a new child. The view tries to re-render and fails: 2020-09-21 ... [General] NSOutlineView error inserting child indexes <_NSCachedIndexSet: 0x600000760000>[number of indexes: 1 (in 1 ranges), indexes: (3)] in parent 0x0 (which has 1 children).
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
0 Replies
405 Views
Hard to believe something this old doesn't work, but it appears so. I set the top to 10 and the bottom to 0, but it uses 10 for both. Am I doing something wrong, or is it a bug? sv.edgeInsets = .init(top: 10, left: 10, bottom: 0, right: 0) Screenshot: Full code example below. (This is the ViewController.swift file after creating a new Xcode project with "Interface" of "Storyboard". No other changes to the project template.) class ViewController: NSViewController {     override func viewDidLoad() {         super.viewDidLoad()         let sv = NSStackView()         sv.translatesAutoresizingMaskIntoConstraints = false         let v1 = ColoredBlock(.red, width: 20)         let v2 = ColoredBlock(.green, width: 20)         let v3 = ColoredBlock(.blue)         sv.addArrangedSubview(v1)         sv.addArrangedSubview(v2)         sv.addArrangedSubview(v3)         sv.spacing = 0         sv.edgeInsets = .init(top: 10, left: 10, bottom: 0, right: 0)         // sv.setContentHuggingPriority(.required, for: .vertical)         view.addSubview(sv)         pinToFourEdges(view, sv)     } } class ColoredBlock: NSView {     let intrinsicHeight: CGFloat     let intrinsicWidth: CGFloat     init(_ color: NSColor, width: CGFloat = NSView.noIntrinsicMetric, height: CGFloat = NSView.noIntrinsicMetric) {         intrinsicWidth = width         intrinsicHeight = height         super.init(frame: .zero)         self.wantsLayer = true         if let layer = self.layer {             layer.backgroundColor = color.cgColor         }     }     required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }     override var intrinsicContentSize: NSSize {         return NSSize(width: intrinsicWidth, height: intrinsicHeight)     } } public func pinToFourEdges(_ view1: NSView, _ view2: NSView) {     view1.topAnchor.constraint(equalTo: view2.topAnchor).isActive = true     view1.bottomAnchor.constraint(equalTo: view2.bottomAnchor).isActive = true     view1.leftAnchor.constraint(equalTo: view2.leftAnchor).isActive = true     view1.rightAnchor.constraint(equalTo: view2.rightAnchor).isActive = true }
Posted
by rnikander.
Last updated
.
Post marked as solved
3 Replies
4.9k Views
Hi,I'm trying to port this to Swift. https://developer.apple.com/documentation/metal/hello_triangleTo get it to run I had to add the following line to the renderer class. Any idea why it's not needed in the Objective-C version? pipelineStateDescriptor.depthAttachmentPixelFormat = metalView.depthStencilPixelFormatWithout it I get an error: -[MTLDebugRenderCommandEncoder validateFramebufferWithRenderPipelineState:]:1232: failed assertion `For depth attachment, the render pipeline's pixelFormat (MTLPixelFormatInvalid) does not match the framebuffer's pixelFormat (MTLPixelFormatDepth32Float).'Rob
Posted
by rnikander.
Last updated
.
Post not yet marked as solved
4 Replies
2.0k Views
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.
Posted
by rnikander.
Last updated
.
Post marked as solved
4 Replies
2.3k Views
You used to be able to put two wheel Pickers side-by-side in an HStack, if you used .frame(...) to set the width, along with .clipped(). Example code from previous question here: https://developer.apple.com/forums/thread/127028 HStack(spacing: 0) { Picker(selection: $choice1, label: Text("C1")) { ForEach(0..<10) { n in Text("\(n) a").tag(n) } } .pickerStyle(.wheel) .frame(minWidth: 0) .clipped() // repeat with second Picker } This is not working for me now in iOS 15. The views still appear side by side, but the touch area seems to overlap. When you try to adjust the first wheel, it spins the second one. I can move the first wheel, if I touch way over to the leading side of the screen. (I had to add the explicit Picker style. It seems like defaulting to .menu also started in iOS 15. ?)
Posted
by rnikander.
Last updated
.