NSTask launch path not accessible

前端 未结 5 443
谎友^
谎友^ 2020-12-11 16:12

I am using the following code in my Cocoa project to call a script I made. The script is in the same folder as the project and even shows up under the \"Resources\" folder i

5条回答
  •  自闭症患者
    2020-12-11 16:46

    When I change the name of my script (stored in the App Bundle) from foo.sh to foo.command I avoid this error.

    let path = Bundle.main.path(forResource: "foo", ofType: "command")
    

    The .command extension is what is used in the Ray Wenderlich tutorial for NSTask / Process. I can't seem to find this documented anywhere (I also make sure the script is executable via chmod +x foo.sh).

提交回复
热议问题