Posts

Post not yet marked as solved
0 Replies
339 Views
Does RealityKit have a way to do instanced rendering? When I clone a ModelEntity, and add it to scene, I get 1 draw call per ModelEntity – even if I don't change any properties on the entity, etc. I was hoping to use RealityKit for a 3D .nonAR game, and think this would be required.
Posted
by rudedogg.
Last updated
.
Post not yet marked as solved
0 Replies
870 Views
Is it possible to use/draw a SwiftUI view in TextKit 2? The NSTextLayoutManagerDelegate seems to be built around returning a NSTextLayoutFragment. Since NSTextLayoutFragment is a class, I can't subclass it and use SwiftUI. I'd love to create my views using SwiftUI, since it's a lot faster than figuring out CGPaths, pixel perfect anti-aliasing, etc. Thanks!
Posted
by rudedogg.
Last updated
.
Post not yet marked as solved
4 Replies
4.1k Views
I have an Onboarding Window/Scene I want to appear on the first launch of the app, or when a use clicks a menu command. Using an AppStorage with a boolean value would be perfect, but when I try to add an if in my SceneBuilder I get the following error: Closure containing control flow statement cannot be used with function builder 'SceneBuilder'. import SwiftUI @main struct MyApp: App {   @AppStorage("tutorialVisible") var tutorialVisible: Bool = true   var body: some Scene {     MainScene()     if tutorialVisible {       TutorialScene()     }   } } How can this be done?
Posted
by rudedogg.
Last updated
.
Post marked as solved
27 Replies
15k Views
I have a library I created with Swift Package Manager, and I'd like to use it in both my Containing App and Safari App Extension.- I've added the library to the Project using the new "Swift Packages" tab in Xcode.- The Safari App Extension Target has my library added under "Frameworks and Libraries".With this configuration I get "Undefined symbol" compiler errors. If I add the library to the App under "Frameworks, Libraries, and Embedded Content", then I get:"Swift package product '{SWIFT PACKAGE}' is linked as a static library by '{APP NAME}' and '{EXTENSION NAME}'. This will result in duplication of library code."The odd thing is that the project compiles fine in Xcode 11.3.1. Did something change with SPM in the Xcode 11.4 beta? Maybe I should use a dynamic library? Or am I doing something else wrong?
Posted
by rudedogg.
Last updated
.
Post not yet marked as solved
5 Replies
3.6k Views
Is it possible to only allow a single window instance on macOS? WindowGroup/DocumentGroup allow the user to create multiple instances of a window. I'd like to only allow one, for an Onboarding sequence. I've checked the Scene documentation - https://developer.apple.com/documentation/swiftui/scene, and it appears the only types conforming to the Scene protocol are WindowGroup, DocumentGroup and Settings. How can I create a single Window in a SwiftUI App? An example use case: struct TutorialScene: Scene {   var body: some Scene { 	// I don't want to allow multiple windows of this Scene! 	WindowGroup { 		TutorialView() 	}	 }
Posted
by rudedogg.
Last updated
.
Post marked as solved
6 Replies
4.1k Views
I can't seem to get my SwiftUI preview to work in a Swift Package created with the "Multiplatform Swift Package" Xcode 12 template. Does this feature require macOS 11+? I'm currently on Catalina with the Xcode 12 beta. Here's what I get from the SwiftUI Preview Diagnostics on macOS: HumanReadableNSError: connectToPreviewHost: Failed to connect to 2247: Error Domain=com.apple.dt.ProcessAttachUtilities Code=0 "Failed to get task for pid 2247: 0" UserInfo={NSLocalizedDescription=Failed to get task for pid 2247: 0} com.apple.dt.xcodepreviews.service (17): and on iOS: 'SwiftUIView_Previews' is not a member type of 'NoiseKit' CompileDylibError: Failed to build SwiftUIView.swift Compiling failed: 'SwiftUIView_Previews' is not a member type of 'NoiseKit' /Users/rudedogg/Library/Developer/Xcode/DerivedData/NoiseKit-gefbuwplfdnsqkghveaurldpgavw/Build/Intermediates.noindex/Previews/NoiseKit/Intermediates.noindex/NoiseKit.build/Debug-appletvsimulator/NoiseKit.build/Objects-normal/x86_64/SwiftUIView.2.preview-thunk.swift:22:43: error: 'SwiftUIView_Previews' is not a member type of 'NoiseKit' typealias SwiftUIView_Previews = NoiseKit.SwiftUIView_Previews                                  ~~~~~~~~ ^ /Volumes/Files/work/packages/NoiseKit/Sources/NoiseKit/NoiseKit.swift:1:8: note: 'NoiseKit' declared here struct NoiseKit {        ^ /Users/rudedogg/Library/Developer/Xcode/DerivedData/NoiseKit-gefbuwplfdnsqkghveaurldpgavw/Build/Intermediates.noindex/Previews/NoiseKit/Intermediates.noindex/NoiseKit.build/Debug-appletvsimulator/NoiseKit.build/Objects-normal/x86_64/SwiftUIView.2.preview-thunk.swift:21:34: error: 'SwiftUIView' is not a member type of 'NoiseKit' typealias SwiftUIView = NoiseKit.SwiftUIView                         ~~~~~~~~ ^ /Volumes/Files/work/packages/NoiseKit/Sources/NoiseKit/NoiseKit.swift:1:8: note: 'NoiseKit' declared here struct NoiseKit {        ^
Posted
by rudedogg.
Last updated
.
Post not yet marked as solved
3 Replies
2.2k Views
I can't seem to get the SwiftUI TabView images to work on macOS, no matter what I try. I've tried different images, image sizes, etc. I've also swapped the Image/Text order in the .tabItem, and tried wrapping it in a VStack/Group.Are they just not working?struct PlaygroundView: View { @State private var selectedTab: Int = 0 var body: some View { TabView(selection: $selectedTab) { Text("Tab 1 contents") .tag(0) .tabItem { Image(nsImage: NSImage(named: NSImage.goLeftTemplateName)!) Text("Tab 1") } Text("Tab 2 contents") .tag(1) .tabItem { Image(nsImage: NSImage(named: NSImage.goRightTemplateName)!) Text("Tab 2") } } } }
Posted
by rudedogg.
Last updated
.
Post not yet marked as solved
3 Replies
1.6k Views
I'd like to open a new tab, and have the location bar focused. Is there a way to do this?I'd love a method on SFSafariTab that allows focusing the location bar. Without it, I'll have to build a custom search (and to do it right, ask permission, and import history, bookmarks, etc.). Calling tab.focusLocationBar() or something would be much easier and would keep me from having to touch so much user data. Any help/guidance would be appreciated.
Posted
by rudedogg.
Last updated
.
Post not yet marked as solved
10 Replies
2.1k Views
After updating to macOS 10.15 Beta 7 my macOS App using SwiftUI crashes immediately. Same behavior with both Xcode Beta 6 and Xcode Beta 7. I've tried clearing derived data, etc.The runtime error is:dyld: Symbol not found: _$s7SwiftUI7BindingVyxGSkAASMRzSkRzSH5IndexSlRpzlMcHas anyone run into this?
Posted
by rudedogg.
Last updated
.
Post not yet marked as solved
2 Replies
2.2k Views
Hello,Is there a way to capture keyboard events from a TextField? I'm trying to make a keyboard shortcut entry field, and need to know whether the user is pressing the Command, Shift, Option, etc key. Looking at the docs it appears I can only get the string the user has typed - is there a way to get more granular keyboard events? Especially on macOS?Thanks,Austin
Posted
by rudedogg.
Last updated
.