简体   繁体   中英

Swift ui macOS open a new google chrome window incognito on a specific url

I've tried the following but it's not working.

Can you give me a hand?

Code:

let _ = Process.launchedProcess(
launchPath: "/Applications/Google Chrome.app", 
arguments: [" -incognito --new-window google.com"]
)

Try the following (tested with Xcode 11.7 / macOS 10.15.6)

let _ = Process.launchedProcess(
   launchPath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", 
   arguments: ["-incognito", "--new-window google.com"]
)

Note: assuming of course that your app is not sandboxed, and there is Google Chrome at that path. In real app it is better to find it dynamically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM