@@ -17,7 +17,8 @@ class SigningManager {
1717 removeProvision: Bool ,
1818 completion: @escaping ( Bool , Error ? ) -> Void
1919 ) {
20- Zsign . sign (
20+ // Explicitly discard result to silence "result unused" warning
21+ _ = Zsign . sign (
2122 appPath: appPath,
2223 provisionPath: provisionPath,
2324 p12Path: p12Path,
@@ -45,11 +46,10 @@ class SigningManager {
4546 let localP12 = inputsDir. appendingPathComponent ( p12URL. lastPathComponent)
4647 let localProv = inputsDir. appendingPathComponent ( provURL. lastPathComponent)
4748
48- // Remove existing files if they exist
49- [ localIPA, localP12, localProv] . forEach {
50- if fm. fileExists ( atPath: $0. path) {
51- try ? fm. removeItem ( at: $0)
52- }
49+ [ localIPA, localP12, localProv] . forEach {
50+ if fm. fileExists ( atPath: $0. path) {
51+ try ? fm. removeItem ( at: $0)
52+ }
5353 }
5454
5555 try fm. copyItem ( at: ipaURL, to: localIPA)
@@ -60,9 +60,8 @@ class SigningManager {
6060 }
6161
6262 static func extractIPA( ipaURL: URL , to workDir: URL ) throws {
63- guard let archive = Archive ( url: ipaURL, accessMode: . read) else {
64- throw NSError ( domain: " Zsign " , code: 3 , userInfo: [ NSLocalizedDescriptionKey: " Failed to open IPA archive " ] )
65- }
63+ // Use throwing initializer (deprecated non-throwing variant removed)
64+ let archive = try Archive ( url: ipaURL, accessMode: . read)
6665
6766 let fm = FileManager . default
6867 for entry in archive {
@@ -71,7 +70,8 @@ class SigningManager {
7170 if entry. type == . directory {
7271 try fm. createDirectory ( at: dest, withIntermediateDirectories: true )
7372 } else {
74- try archive. extract ( entry, to: dest)
73+ // Explicit discard in case extract returns a value in this version
74+ _ = try archive. extract ( entry, to: dest)
7575 }
7676 }
7777 }
@@ -93,14 +93,12 @@ class SigningManager {
9393 static func createSignedIPA( from workDir: URL , originalIPAURL: URL , outputDir: URL ) throws -> URL {
9494 let fm = FileManager . default
9595
96- // Use the original IPA name (without .ipa) as the prefix for the final file
9796 let originalBase = originalIPAURL. deletingPathExtension ( ) . lastPathComponent
9897 let finalFileName = " \( originalBase) _signed_ \( UUID ( ) . uuidString) .ipa "
9998 let signedIpa = outputDir. appendingPathComponent ( finalFileName)
10099
101- guard let writeArchive = Archive ( url: signedIpa, accessMode: . create) else {
102- throw NSError ( domain: " Zsign " , code: 4 , userInfo: [ NSLocalizedDescriptionKey: " Failed to create IPA archive " ] )
103- }
100+ // Throwing initializer
101+ let writeArchive = try Archive ( url: signedIpa, accessMode: . create)
104102
105103 let enumerator = fm. enumerator ( at: workDir, includingPropertiesForKeys: [ . isDirectoryKey] , options: [ ] , errorHandler: nil ) !
106104 var directories : [ URL ] = [ ]
@@ -150,30 +148,26 @@ class SigningManager {
150148 do {
151149 progressUpdate ( " Preparing files 📂 " )
152150
153- // Create temporary workspace
154151 let ( tmpRoot, inputsDir, workDir) = try prepareTemporaryWorkspace ( )
155152 defer { cleanupTemporaryFiles ( at: tmpRoot) }
156153
157- // Copy input files
158154 let ( localIPA, localP12, localProv) = try copyInputFiles (
159155 ipaURL: ipaURL,
160156 p12URL: p12URL,
161157 provURL: provURL,
162158 to: inputsDir
163159 )
164160
165- // Extract IPA
166161 progressUpdate ( " Unzipping IPA 🔓 " )
167162 try extractIPA ( ipaURL: localIPA, to: workDir)
168163
169- // Find app bundle
170164 let payloadDir = workDir. appendingPathComponent ( " Payload " )
171165 let appDir = try findAppBundle ( in: payloadDir)
172166
173- // Sign the app
174167 progressUpdate ( " Signing \( appDir. lastPathComponent) ✍️ " )
175168
176- var signingCompleted = false
169+ // Replace spin-wait with semaphore (optional improvement)
170+ let sema = DispatchSemaphore ( value: 0 )
177171 var signingError : Error ?
178172
179173 sign (
@@ -182,23 +176,15 @@ class SigningManager {
182176 p12Path: localP12. path,
183177 p12Password: p12Password,
184178 entitlementsPath: " " ,
185- removeProvision: false ,
186- completion: { success, error in
187- signingCompleted = true
188- signingError = error
189- }
190- )
191-
192- // Wait for signing to complete
193- while !signingCompleted {
194- Thread . sleep ( forTimeInterval: 0.1 )
179+ removeProvision: false
180+ ) { _, error in
181+ signingError = error
182+ sema. signal ( )
195183 }
196184
197- if let error = signingError {
198- throw error
199- }
185+ sema. wait ( )
186+ if let error = signingError { throw error }
200187
201- // Create signed IPA
202188 progressUpdate ( " Zipping signed IPA 📦 " )
203189 let signedIPAURL = try createSignedIPA (
204190 from: workDir,
0 commit comments