AvdLee / RocketSimApp

Enhancing the iOS simulator for productivity
601 stars 20 forks source link

Long deeplinks fail to open #355

Open AvdLee opened 1 year ago

AvdLee commented 1 year ago

Describe the bug

2023-05-12 15:13:25 | AppActionsControlling+ErrorHandling.swift:L22 | ERROR: Error Domain=NSPOSIXErrorDomain Code=7 "Argument list too long" | The operation couldn’t be completed. Argument list too long | Deeplink opening failed

Reported by A. Bell


Tried my best to solve this, but it's pretty hard as we have to pipe in the arguments. However, simctl is not waiting for input and fails right away.

Next step would be to find out how to execute commands in the terminal step by step.

AvdLee commented 1 year ago

Something like this could work:

let startDate = Date()
        Log.simctl.debug("Started running \(command)")
        if let lastArgument = process.arguments?.last, lastArgument.count >= 1048576 {
            process.arguments?.removeLast()
            process.arguments?.append(String(lastArgument.prefix(10)))
            let inputPipe = Pipe()
            process.standardInput = inputPipe

            inputPipe.fileHandleForWriting.write(lastArgument.prefix(1000).data(using: .utf8)!)
            inputPipe.fileHandleForWriting.closeFile()
//            process.launch()
//            process.waitUntilExit()
            try process.run()
        } else {
            try process.run()
        }