I have an app called myapp.app. It is signed and don't prompt any warning when launch.
The goal is to have it installed by an installer silently and launch it. This installer should be triggered in command line.
The solution I imagine is to create an install.app which carries myapp.
Execute "open /Volumes/myapp/install.app".
installer.app copies myapp to ~/Applications and run it.
Is that realistic ?
If yes, creating a cocoa command line application is the way to go?
Would I be able to copy myapp.app to /Applications? (so far all my attempts with swift 3 failed).
[Edit] I was able to copy the Bundle app to ~/Applications/
let sourcePath = Bundle.main.path(forResource: "myapp", ofType: "app")
if (sourcePath == nil) {
print("myapp.app was not found");
return;
}
let target = FileManager.default.urls(for: .applicationDirectory, in: .userDomainMask).first
let target_path = target?.appendingPathComponent("myapp.app").path
do {
try FileManager.default.copyItem(atPath: sourcePath!, toPath: target_path!)
} catch let error {
print(error.localizedDescription)
}
Now, I am looking to launch it (with swift 3 if possible)
[Edit 2] How it is launched
let run_app = Process()
run_app.launchPath = "/usr/bin/open"
run_app.arguments = [target_path!]
run_app.launch()
Any better way, please let me know.