Post

Replies

Boosts

Views

Activity

Using NSHostingSceneRepresentation to open arbitrary window in AppKit app
I’m trying to open a window from a SwiftUI Scene inside an AppKit app using NSHostingSceneRepresentation (macOS 26). The idea is that I want to call openWindow(id: "some-id") to show the new window. However, nothing happens when I try this — no window appears, and there’s nothing in the logs. Interestingly, if I use the openSettings() route instead, it does open a window. Does anyone know the correct way to open an arbitrary SwiftUI window scene from an AppKit app? import Cocoa import SwiftUI @main class AppDelegate: NSObject, NSApplicationDelegate { let settingsScene = NSHostingSceneRepresentation { #if true MyWindowScene() #else Settings { Text("My Settings") } #endif } func applicationWillFinishLaunching(_ notification: Notification) { NSApplication.shared.addSceneRepresentation(settingsScene) } @IBAction func showAppSettings(_ sender: NSMenuItem) { #if true settingsScene.environment.openWindow(id: MyWindowScene.windowID) #else settingsScene.environment.openSettings() #endif } } struct MyWindowScene: Scene { static let windowID = "com.company.MySampleApp.myWindow" var body: some Scene { Window("Sample Window", id: MyWindowScene.windowID) { Text("Sample Content") .scenePadding() } } }
Topic: UI Frameworks SubTopic: SwiftUI
0
0
74
Jul ’25
Custom SwiftUI view with localization support similar to the SwiftUI Text view
I'd like to create a custom SwiftUI view that supports extracting its title string along with the localization comment into a string catalog. Like the SwiftUI Text view does. I have a view with an init similar to the localization init of Text. But it looks like I'm missing something obvious. Two questions: How do I get the actual localized string using a LocalizedStringKey? Why is the comment not picked up and added to the string catalog? // 1) My custom view with localization support: // I'd like to build a view which supports extraction of strings into a string catalog like the SwiftUI `Text` view does. struct MyLocalizableView: View { private var localizedTitle: String init (_ titleKey: LocalizedStringKey, table: String? = nil, bundle: Bundle? = nil, comment: StaticString? = nil) { // PROBLEM I: // The following line does not work. I is a fantasy call. It depicts my idea how I would expect it to work. // My question is: How do I get the actual localized string using a `LocalizedStringKey`? self.localizedTitle = String(localizedKey: titleKey, table: table, bundle: bundle, comment: comment) } var body: some View { // At this point I want to do an operation on an actual string and not on a LocalizedStringKey. So I can't just pass the LocalizedStringKey value along. // Do `isEmpty` or some other operation on an actual string: if localizedTitle.isEmpty { Text("Show one thing") } else { Text("Show another thing") Text("** \(localizedTitle) **") } } } // 2) The call site: struct ContentView: View { var body: some View { // PROBLEM II: "My title key" is picked up and is extracted into the string catalog of the app. But the comment is NOT! MyLocalizableView("My title key", comment: "The title of the view...") .padding() } }
1
0
257
Mar ’25
ITMS-90334 error when executing a Xcode Cloud TestFlight build
When I try to create a TestFlight build of my app using Xcode Cloud, I get a couple of ITMS-90334 errors and the build fails. The error messages look like: ITMS-90334: Invalid Code Signature Identifier - The identifier 'MySwiftPackage-55554944e95A2da4fe9e3357b44de57c3ba890e8' in your code signature for 'MySwiftPackage_-658550CFFF128C8B_PackageProduct' must match its Bundle Identifier 'MySwiftPackage' Where MySwiftPackage is a Swift Package which is used by a framework as well as the application. The dependencies look like this: MyApp + MyFramework + MySwiftPackage + MySwiftPackage MyApp is a macOS app MyFramework is a mixed Swift and Objective-C framework MyApp is also mixed Swift and Objective-C When I run an archive build on my local Mac and upload the build to App Store Connect to be used as a TestFlight build, everything seams to be fine and the build is accepted I found some discussions on ITMS-90334 but not related to using Swift Packages and Frameworks Any ideas what might be going on or where I can look to get more info on the nature of ITMS-90334?
6
7
3.2k
Jun ’22