@@ -153,56 +153,57 @@ class DownloadSignManager: ObservableObject {
153153 }
154154 }
155155
156- private func signIPA( ipaURL: URL , p12URL: URL , provURL: URL , password: String , appName: String ) {
157- DispatchQueue . main. async {
158- self . status = " Starting signing process... "
159- self . progress = 0.5
160- }
161-
162- signer. sign (
163- ipaURL: ipaURL,
164- p12URL: p12URL,
165- provURL: provURL,
166- p12Password: password,
167- progressUpdate: { [ weak self] status, progress in
168- DispatchQueue . main. async {
169- // Convert from 0-1 range within signing phase to 0.5-1.0 overall range
170- let overallProgress = 0.5 + ( progress * 0.5 )
171- self ? . progress = overallProgress
172- let percent = Int ( overallProgress * 100 )
173- self ? . status = " \( status) ( \( percent) %) "
174- }
175- } ,
176- completion: { [ weak self] result in
177- DispatchQueue . main. async {
178- switch result {
179- case . success( let signedIPAURL) :
180- self ? . progress = 1.0
181- self ? . status = " ✅ Successfully signed! Saved to: \( signedIPAURL. lastPathComponent) "
182- self ? . showSuccess = true
183-
184- // Hide progress bar after 3 seconds
185- DispatchQueue . main. asyncAfter ( deadline: . now( ) + 3 ) {
186- self ? . isProcessing = false
187- self ? . showSuccess = false
188- self ? . progress = 0.0
189- self ? . status = " "
190- }
191-
192- // Clean up original downloaded IPA
193- try ? FileManager . default. removeItem ( at: ipaURL)
194-
195- case . failure( let error) :
196- self ? . status = " ❌ Signing failed: \( error. localizedDescription) "
156+ private func signIPA( ipaURL: URL , p12URL: URL , provURL: URL , password: String , appName: String ) {
157+ DispatchQueue . main. async {
158+ self . status = " Starting signing process... "
159+ self . progress = 0.5
160+ }
161+
162+ signer. sign (
163+ ipaURL: ipaURL,
164+ p12URL: p12URL,
165+ provURL: provURL,
166+ p12Password: password,
167+ progressUpdate: { [ weak self] status, progress in
168+ DispatchQueue . main. async {
169+ // progress is already in the range 0.0-1.0 for the signing phase
170+ // We need to map it to 0.5-1.0 overall
171+ let overallProgress = 0.5 + ( progress * 0.5 )
172+ self ? . progress = overallProgress
173+ let percent = Int ( overallProgress * 100 )
174+ self ? . status = " \( status) ( \( percent) %) "
175+ }
176+ } ,
177+ completion: { [ weak self] result in
178+ DispatchQueue . main. async {
179+ switch result {
180+ case . success( let signedIPAURL) :
181+ self ? . progress = 1.0
182+ self ? . status = " ✅ Successfully signed! Saved to: \( signedIPAURL. lastPathComponent) "
183+ self ? . showSuccess = true
184+
185+ // Hide progress bar after 3 seconds
186+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 3 ) {
197187 self ? . isProcessing = false
198-
199- // Clean up temp files
200- try ? FileManager . default . removeItem ( at : ipaURL )
188+ self ? . showSuccess = false
189+ self ? . progress = 0.0
190+ self ? . status = " "
201191 }
192+
193+ // Clean up original downloaded IPA
194+ try ? FileManager . default. removeItem ( at: ipaURL)
195+
196+ case . failure( let error) :
197+ self ? . status = " ❌ Signing failed: \( error. localizedDescription) "
198+ self ? . isProcessing = false
199+
200+ // Clean up temp files
201+ try ? FileManager . default. removeItem ( at: ipaURL)
202202 }
203203 }
204- )
205- }
204+ }
205+ )
206+ }
206207
207208 func cancel( ) {
208209 downloadTask? . cancel ( )
0 commit comments