From 475dd392e644adfb73bad1ad130de1ef12eef1c2 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Wed, 24 Jun 2026 08:07:37 -0700 Subject: [PATCH] Fix iOS Load file picker not opening MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Five presentation modifiers (.sheet, .alert, two .fileImporter, .fileExporter) were stacked on the builder's root view. SwiftUI reliably drives only one presentation per view node, so adding the Boards .sheet swallowed the iOS rig Load importer — the Load button toggled its flag but no picker appeared. Move each presentation onto its own Color.clear background anchor so they no longer collide. Co-Authored-By: Claude Opus 4.8 --- .../ShoeGazeBuilder.xcodeproj/project.pbxproj | 8 +- .../ShoeGazeBuilderView.swift | 82 +++++++++++++------ 2 files changed, 61 insertions(+), 29 deletions(-) diff --git a/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj b/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj index 4dee72f..e20f391 100644 --- a/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj +++ b/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj @@ -163,7 +163,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = HE5VJFE9E4; @@ -176,7 +176,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 0.9; + MARKETING_VERSION = 0.91; PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -194,7 +194,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = HE5VJFE9E4; ENABLE_HARDENED_RUNTIME = YES; @@ -206,7 +206,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 0.9; + MARKETING_VERSION = 0.91; PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift index 17340fb..6c4d73f 100644 --- a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift +++ b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift @@ -160,15 +160,10 @@ public struct ShoeGazeBuilderView: View { ) .background(boardSwitchShortcuts) .onAppear { restoreInputSelection() } - .sheet(isPresented: $showBoardsSheet) { - BoardsSheetView( - shoeGaze: shoeGaze, - editingBoardIndex: $selectedBoardIndex, - crossfadeSeconds: $crossfadeSeconds, - onAddBoard: { addBoard() } - ) - .presentationDetents([.medium, .large]) - } + // Each presentation (sheet / importers / exporter / alert) lives on its own anchor + // node. SwiftUI reliably drives only one presentation per view node, so stacking them + // all on the root view silently swallowed some (e.g. the iOS Load file importer). + .background(boardsSheetAnchor) .alert("Microphone Access Needed", isPresented: $showMicDeniedAlert) { Button("OK", role: .cancel) { } } message: { @@ -176,25 +171,62 @@ public struct ShoeGazeBuilderView: View { + "Security › Microphone, then select the input again.") } #if !os(macOS) - .fileImporter(isPresented: $showImporter, allowedContentTypes: [.json]) { result in - handleImport(result) - } - .fileImporter(isPresented: $showRecordingFolderImporter, allowedContentTypes: [.folder]) { result in - handleRecordingFolderImport(result) - } - .fileExporter( - isPresented: $showExporter, - document: exportDocument, - contentType: .json, - defaultFilename: ShoeGazeBuilderView.defaultRigFileName - ) { result in - if case .failure(let error) = result { - print("[ShoeGazeBuilderView] export failed: \(error)") - } - } + .background(rigImportAnchor) + .background(recordingFolderImportAnchor) + .background(rigExportAnchor) #endif } + // MARK: - Presentation anchors + + /// Hosts the board-manager sheet on its own node so it does not collide with the file + /// importers / exporter (one presentation per view node). + private var boardsSheetAnchor: some View { + Color.clear + .sheet(isPresented: $showBoardsSheet) { + BoardsSheetView( + shoeGaze: shoeGaze, + editingBoardIndex: $selectedBoardIndex, + crossfadeSeconds: $crossfadeSeconds, + onAddBoard: { addBoard() } + ) + .presentationDetents([.medium, .large]) + } + } + + #if !os(macOS) + /// Hosts the rig-load (`.json`) importer on its own node. + private var rigImportAnchor: some View { + Color.clear + .fileImporter(isPresented: $showImporter, allowedContentTypes: [.json]) { result in + handleImport(result) + } + } + + /// Hosts the recording-folder importer on its own node. + private var recordingFolderImportAnchor: some View { + Color.clear + .fileImporter(isPresented: $showRecordingFolderImporter, allowedContentTypes: [.folder]) { result in + handleRecordingFolderImport(result) + } + } + + /// Hosts the rig-save (`.json`) exporter on its own node. + private var rigExportAnchor: some View { + Color.clear + .fileExporter( + isPresented: $showExporter, + document: exportDocument, + contentType: .json, + defaultFilename: ShoeGazeBuilderView.defaultRigFileName + ) { result in + if case .failure(let error) = result { + print("[ShoeGazeBuilderView] export failed: \(error)") + } + } + } + #endif + // MARK: - Transport row private var transportRow: some View {