Post

Replies

Boosts

Views

Activity

Use Object Capture with Combine in a macOS app
Hi! I noticed that in a macOS app, session.process will not run unless I add RunLoop.main.run() afterwards, which successfully creates the model but leaves the app unresponsive with the spinning color wheel. Also, the sample code for the async/await version shows a session.outputs property that doesn't exist in Xcode. I'd appreciate any suggestions on how to fix this! Thank you. session.output //            .receive(on: DispatchQueue.global())             .sink(receiveCompletion: { completion in                 var maybeError: Error? = nil                 if case .failure(let error) = completion {                     print("Output: ERROR = \(String(describing: error))")                     maybeError = error                     Foundation.exit(maybeError != nil ? 0 : 1)                 }             }, receiveValue: { output in                 DispatchQueue.main.async {                     self.output = output                 }                 switch output {                 case .processingComplete:                     // All requests are done so you can safely exit.                     print("Processing is complete!")                 case .requestError(let request, let error):                     print("Request \(String(describing: request)) had an error: \(String(describing: error))")                 case .requestComplete(let request, let result):                     self.complete(request: request, result: result)                 case .requestProgress(let request, let fractionComplete):                     self.progress(request: request, fractionComplete: fractionComplete)                 case .inputComplete:  // Data ingestion has finished.                     print("Data ingestion is complete.  Beginning processing...")                 case .invalidSample(let id, let reason):                     print("Invalid Sample! id=\(id)  reason=\"\(reason)\"")                 case .skippedSample(let id):                     print("Sample id=\(id) was skipped by processing.")                 case .automaticDownsampling:                     print("Automatic downsampling was applied!")                 default:                     print("Output: unhandled message: \(output.localizedDescription)")                 }             })             .store(in: &subscriptions)                  reference = try! session.process(requests: [             .modelFile(url: URL(fileURLWithPath: "model123.usdz"), detail: .reduced)             RunLoop.main.run()         ])
2
0
1.2k
Jun ’21
SharePlay camera and microphone access, and message size limit
Hi! I was at a very excellent Group Activities lab earlier and am writing this post as a follow up on a couple questions. I am interested in using Group Activities and SharePlay with AR. Since my app uses the back camera for AR, FaceTime doesn't seem to be able to use the front camera. Can my app and FaceTime use the camera at the same time? It would be great to identify which user is currently speaking, so I'm wondering if the same problem exists for using the microphone at the same time as FaceTime. What is the size limit for data that can be sent in real time over GroupSessionMessenger? Thank you so much!
0
0
1.1k
Jun ’21
Moving the position of the search UI with .searchable modifier
Hi! I’m building a sheet UI similar to the sheet in Maps and Stocks that is overlayed over the main screen and can be dragged up and down with a gesture. I'm using .offset(x: 0, y: verticalOffset) on the entire sheet view. I have a search bar in the sheet and attempted to replace it with the .searchable modifier. However, the search view appears in a fixed position near the top of the screen (about where it would be in a NavigationView) and does not move with the offset. It would be great if I could have it move with the sheet. Thank you! Code: @State private var filter: String = "" VStack { Grid() }         .background(.regularMaterial)         .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))         .padding(.top, 100)         .animation(.default, value: 5)         .shadow(radius: 8)         .edgesIgnoringSafeArea(.bottom)         .searchable(text: $filter, placement: .automatic)         .offset(x: 0, y: offset)
0
0
1.6k
Jun ’21
NavigationSplitView crashes in Xcode, iOS Beta 7
I have a NavigationSplitView with a sidebar. When selecting a new item on the sidebar, the app crashes. The error message says: Simultaneous accesses to 0x6000030107f0, but modification requires exclusive access. Xcode shows that the crash occurs inside the generated code in my class with @Observable macro. @ObservationIgnored private let _$observationRegistrar = Observation.ObservationRegistrar() internal nonisolated func access<Member>( keyPath: KeyPath<NavModel , Member> ) { _$observationRegistrar.access(self, keyPath: keyPath) } internal nonisolated func withMutation<Member, MutationResult>( keyPath: KeyPath<NavModel , Member>, _ mutation: () throws -> MutationResult ) rethrows -> MutationResult { // Crash occurs on the following line try _$observationRegistrar.withMutation(of: self, keyPath: keyPath, mutation) } @ObservationIgnored private var _section: SidebarSection? = .one To reproduce the crash, I tap a new item on the sidebar until the app crashes. It usually only takes 1-3 times selecting a new item before the crash occurs. Below is the code for an entire app to reproduce the crash. Has anyone else encountered this issue? Thank you! import SwiftUI @main struct NavigationBugApp: App { var body: some Scene { WindowGroup { ContentView() } } } @Observable class NavModel { var section: SidebarSection? = .one } enum SidebarSection: Hashable { case one case two } struct ContentView: View { @State private var model = NavModel() var body: some View { NavigationSplitView { List(selection: $model.section) { NavigationLink("One", value: SidebarSection.one) NavigationLink("Two", value: SidebarSection.two) } .listStyle(.sidebar) } detail: { Text("Hello World") } } } #Preview { ContentView() }
2
0
1k
Aug ’23
Crash on iOS 16 when built with Xcode 15 in release mode only - Symbol not found: _$s10Foundation13__DataStorageC12replaceBytes2in4with6lengthySnySiG_SVSgSitF
When running on iOS 16 in release mode, my app (built with Xcode 15) crashes with the following message: Symbol not found: _$s10Foundation13__DataStorageC12replaceBytes2in4with6lengthySnySiG_SVSgSitF The same app works fine when: Run on iOS 16 in debug mode Run on iOS 17 Built with Xcode 14 There are no deprecation warnings showing in Xcode, and everything compiles fine. I found this method that seems to match the missing symbol (https://developer.apple.com/documentation/foundation/nsmutabledata/1412428-replacebytes); however, it's not being used anywhere in the app. Is there a specific symbol removed in Xcode 15 causing this issue? Thank you!
5
2
2.1k
Sep ’23
App Intents do not appear in macOS Shortcuts app
I've created a barebones Multiplatform app and added an App Intent and App Shortcut. When running on iOS, I can see my app show up in Shortcuts and use the intent or App Shortcut as normal. On macOS, my app does not appear in the Shortcuts app, neither the App Shortcut nor the intent. Is there additional configuration required to enable Shortcuts / App Intents on macOS? This is the only code I've added to a brand-new Xcode Multiplatform project: import AppIntents struct OpenIntent: AppIntent { static let title: LocalizedStringResource = "Open MacShortcut" static let description: LocalizedStringResource = "Opens the app" /// Launch your app when the system triggers this intent. static let openAppWhenRun: Bool = true /// Define the method that the system calls when it triggers this event. @MainActor func perform() async throws -> some IntentResult { /// Return an empty result since we're opening the app return .result() } } struct MacShortcutShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: OpenIntent(), phrases: [ "Open a session of \(.applicationName)" ], shortTitle: "Open", systemImageName: "arrow.up.circle.fill" ) } }
0
0
599
Dec ’23