Reputation: 2182
Im new to developing mac applications. (but I have work a lot for ios)
For start I want to have a window on which there is a button. When user click on the button, it should trigger an action that will run some shell commands inside the folder that the user dragged & dropped inside the app before.
For example User will drag and drop some folder inside my app and the app should create gemfile inside this folder.
Here is my current version where I run the shell and the first command is cd <pathToFolder>
but the output is /usr/bin/cd: line 4: cd: file:///Users/klemen/Downloads/ABCAcura/: No such file or directory
Here is my code:
@IBAction func handleCreateGemfileButton(_ sender: NSButton) {
let pipe = Pipe()
let process = Process()
process.launchPath = "/bin/bash"
process.arguments = ["cd", projectURL.absoluteString]
process.standardOutput = pipe
let file = pipe.fileHandleForReading
process.launch()
if let result = NSString(data: file.readDataToEndOfFile(), encoding: String.Encoding.utf8.rawValue) {
print(result as String)
}
else {
print("error")
}
}
Is there some restrictions. How is it possible to request from user that my app will have access to some of his files?
Upvotes: 0
Views: 323
Reputation: 5223
You should use ~/Downloads/ABCAcura
instead of file:///...
, file:///
is a protocol (URL) not a path to file.
Upvotes: 1