@@ -39,9 +39,10 @@ final class InstallLogger {
3939 }
4040
4141 private func setupLogFile( ) {
42+ guard let documents = FileManager . default. urls ( for: . documentDirectory, in: . userDomainMask) . first else { return }
43+
4244 do {
4345 let fm = FileManager . default
44- let documents = try fm. urls ( for: . documentDirectory, in: . userDomainMask) . first!
4546 let logsDir = documents. appendingPathComponent ( " Logs " , isDirectory: true )
4647
4748 if !fm. fileExists ( atPath: logsDir. path) {
@@ -204,8 +205,6 @@ final class LocalStaticHTTPServer {
204205 startSemaphore. signal ( )
205206 case . waiting( let reason) :
206207 InstallLogger . shared. log ( " Listener waiting: \( reason) " )
207- case . preparing:
208- InstallLogger . shared. log ( " Listener preparing... " )
209208 case . setup:
210209 InstallLogger . shared. log ( " Listener in setup state " )
211210 @unknown default :
@@ -362,13 +361,13 @@ final class LocalStaticHTTPServer {
362361 private func sendSimpleResponse( connection: NWConnection , status: Int , text: String ) {
363362 let body = text + " \n "
364363 // fixed: build Data from full string rather than trying to add UTF8View slices
365- let combined = Data ( ( " HTTP/1.1 \( status) \( httpStatusText ( status) ) \r \n " +
364+ let combined = Data ( ( " HTTP/1.1 \( status) \( self . httpStatusText ( status) ) \r \n " +
366365 " Content-Length: \( body. utf8. count) \r \n " +
367366 " Content-Type: text/plain \r \n " +
368367 " Connection: close \r \n \r \n " +
369368 body ) . utf8)
370369 connection. send ( content: combined, completion: . contentProcessed( { _ in
371- InstallLogger . shared. logDebug ( " Sent response: \( status) \( httpStatusText ( status) ) " )
370+ InstallLogger . shared. logDebug ( " Sent response: \( status) \( self . httpStatusText ( status) ) " )
372371 } ) )
373372 }
374373
@@ -410,14 +409,12 @@ public func installApp(from ipaURL: URL) throws {
410409 let fm = FileManager . default
411410 InstallLogger . shared. log ( " FileManager initialized " )
412411
413- let documents : URL
414- do {
415- documents = try fm. urls ( for: . documentDirectory, in: . userDomainMask) . first!
416- InstallLogger . shared. log ( " Documents directory: \( documents. path) " )
417- } catch {
418- InstallLogger . shared. logError ( " Failed to get documents directory: \( error) " )
419- throw error
412+ // FIX: Remove 'try' from non-throwing function
413+ guard let documents = fm. urls ( for: . documentDirectory, in: . userDomainMask) . first else {
414+ InstallLogger . shared. logError ( " Failed to get documents directory " )
415+ throw InstallAppError . fileWriteFailed ( " Failed to get documents directory " )
420416 }
417+ InstallLogger . shared. log ( " Documents directory: \( documents. path) " )
421418
422419 let appRoot = documents. appendingPathComponent ( " AppFolder " , isDirectory: true )
423420 if !fm. fileExists ( atPath: appRoot. path) {
0 commit comments