Search code examples
iosswiftmacosmac-catalyst

Mac Catalyst: Determine App's Command Line Arguments


Is there a way within a Mac Catalyst app to access the arguments passed along to an application launched through the command line?

Thinking it would be passed through to func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { however, it doest not appear there.


Solution

  • According to Apple’s documentation ProcessInfo is available on Catalyst 13, so this should give you what you need:

    import Foundation
    
    let args = ProcessInfo.processInfo.arguments
    

    The type of args is [String].