@@ -145,11 +145,31 @@ public func installApp(from ipaURL: URL) async throws
145145 let viewModel = InstallerStatusViewModel ( isIdevice: isIdevice)
146146
147147 // Debug logging for status changes
148- viewModel. $status
149- . sink { status in
150- print ( " [Installer] status -> " , status)
151- }
152- . store ( in: & cancellables)
148+ // Watch status for completion / errors (replace the previous $isCompleted sink)
149+ viewModel. $status
150+ . sink { newStatus in
151+ // If the view model exposes a computed Bool isCompleted, use it (safe regardless of enum shape)
152+ if viewModel. isCompleted {
153+ print ( " [Installer] detected completion via viewModel.isCompleted " )
154+ continuation. yield ( ( 1.0 , " ✅ Successfully installed app! " ) )
155+ continuation. finish ( )
156+ cancellables. removeAll ( )
157+ return
158+ }
159+
160+ // If the status enum contains an error / broken case, finish with that error
161+ // This covers the case where broken carries an associated Error
162+ if case . broken( let error) = newStatus {
163+ print ( " [Installer] detected broken status -> " , error)
164+ continuation. finish ( throwing: transformInstallError ( error) )
165+ cancellables. removeAll ( )
166+ return
167+ }
168+
169+ // Optional: handle a status that carries failure inside .completed (if that variant exists)
170+ // e.g. if your enum had `.completed(.failure(let e))` then add handling here.
171+ }
172+ . store ( in: & cancellables)
153173
154174 // Progress stream (combine upload & install progress)
155175 viewModel. $uploadProgress
0 commit comments