0

I have a problem starting a UNIX Programm (Csvmidi) from an cocoa app. It should convert a csv file to a midi file which actually works when i run it through the Terminal.

In Terminal it works fine by putting the URL of the UNIX file, the .csv file and .mid file in a row. Like this: /Users/...../Csvmid </Users/.../test.csv> /Users/.../Melody.mid -> and automatically the Midi-File changes.

In Windows it worked with an easy code:

Process.Start("Csvmidi.exe", "test.csv Melody.mid");

In swift I tried to make it work with task.Process() but still it won't work. How can I make it work?

        let csvmidiURL =  "/Users/.../Csvmidi" 
        let process = Process()
        process.executableURL = URL(fileURLWithPath: csvmidiURL)
        process.arguments = [" <" , lblURL.stringValue , "> " , lblMidi.stringValue]
        process.terminationHandler = { (process) in
           print("\ndidFinish: \(!process.isRunning)")
        }
        do {
          try process.run()
        } catch {}

Thanks in advance!

  • in `process.arguments = [" <" , lblURL.stringValue , "> " , lblMidi.stringValue]` the lblURL and lblMidi are the URLs of the .csv file and .mid file – lulutuschk Apr 22 '20 at 10:42
  • Hot ru run this Terminal code `/Users/...../Csvmid /Users/.../Melody.mid` in an swift code...? – lulutuschk Apr 22 '20 at 12:26

0 Answers0