Post

Replies

Boosts

Views

Activity

Trying to show sheet on first app launch
I would like to show a welcome sheet when my app first launches. Starting with a blank Xcode project, I've set up a WelcomeStoryboard how I want it. I can show it as a sheet using a button click, calling this in my ViewController: func showWelcome() { let welcomeStoryboard = NSStoryboard(name: "WelcomeStoryboard", bundle: nil) guard let welcomeViewController = (welcomeStoryboard.instantiateInitialController() as? NSWindowController)?.contentViewController else { return } self.presentAsSheet(welcomeViewController) } However, I am finding it hard to see where I can call that so it will show the sheet when the window first loads. Inside viewDidLoad is too soon, it seems: Assertion failure in -[NSViewControllerSheetTransition animatePresentationOfViewController:fromViewController:], NSViewControllerSheetTransition.m:33 Failed to set (contentViewController) user defined inspected property on (NSWindow): self.fromViewController.view.window should be valid! I noticed that if I wrap presentAsSheet inside DispatchQueue.main.async it works! But I don't understand why that would work, and am reluctant to trust it. I'm hoping someone can shed some light on this for me? It feels like a trivial requirement but I'm stuck on it!
3
0
1.1k
Apr ’22
Failed to resolve dependencies: incompatible tools version
I'm using Xcode 12.4 on Catalina (for testing purposes). My app uses some SPM packages (eg Blessed) which specify // swift-tools-version:5.5. Am I correct believing Xcode 12.4 can be made to compile these packages by downloading and installing a later Swift? This is what I've tried: downloaded and installed Swift 5.6.1 from https://www.swift.org/download/ selected the new Swift in Xcode > Toolchains > Swift 5.6.1 confirmed it in Xcode's preferences > Components > Toolchains attempted to resolve my package versions: Xcode File menu > Swift Packages > Resolve Package Versions Unfortunately this results in an error: "Failed to resolve dependencies" "because every version of Blessed contains incompatible tools version and root depends on Blessed 0.3.0..<1.0.0, version solving failed." I'm left wondering, is "Toolchain" something different than "Tools"? My Xcode's "Command Line Tools" is still "Xcode 12.4" (the only option).
0
0
1.7k
Apr ’22
Can I use NWConnection to monitor for server availability?
I want my app to react when it sees that a certain port is being listened to, and likewise when it stops being listened to. Specifically, another app will start a gdb server (at 127.0.0.1 on 9003) and I want mine to detect that. I don't really even care that it's a gdb server, just when the port is in use or not. I can do it right now using polling using a variation of this but that's not great for CPU wakes. I'm wondering if I can use an NWConnection (with no timeout) to monitor for these events (port in use, port no longer in use). If so, any pointers would be very gratefully received :) Even if just to say I'm barking up the wrong tree!
2
0
803
Jun ’22
Xcode 15 beta Command PhaseScriptExecution failed with a nonzero exit code
I have a Build Phase which runs a script. The script is a swift file, which I have simplified to illustrate the crash, like so: #!/usr/bin/env xcrun --sdk macosx swift import Foundation import CryptoKit var sha256 = SHA256() // Do other stuff... All the Xcode 15 betas fail to build my app, instead throwing the error: Command PhaseScriptExecution failed with a nonzero exit code. The logs: JIT session error: Symbols not found: [ _$s9CryptoKit6SHA256VMa, _$s9CryptoKit6SHA256VACycfC ] Failed to materialize symbols: { (main, { _$s20PropertyListModifier6sha2569CryptoKit6SHA256Vvp, _main, __swift_FORCE_LOAD_$_swiftDarwin_$_PropertyListModifier, __swift_FORCE_LOAD_$_swiftIOKit_$_PropertyListModifier, ___swift_project_value_buffer, __swift_FORCE_LOAD_$_swiftFoundation_$_PropertyListModifier, ___swift_allocate_value_buffer, __swift_FORCE_LOAD_$_swiftObjectiveC_$_PropertyListModifier, __swift_FORCE_LOAD_$_swiftXPC_$_PropertyListModifier, __swift_FORCE_LOAD_$_swiftCoreFoundation_$_PropertyListModifier, __swift_FORCE_LOAD_$_swiftDispatch_$_PropertyListModifier }) } Does anyone know of a work-around or solution, or does this just look like nothing more than a bug in the betas, which I should "wait out"? It's had the same problem right from beta 1 to the current beta 5 so it's starting to look like it won't be fixed which is worrying me.
4
0
6.6k
Jul ’23