11

In the most recent Apple documentation both NSTask and Process have several deprecated methods and properties, although there's nothing marked with an API Availability Macro.

Instance Properties

@property(copy) NSString *launchPath;
@property(copy) NSString *currentDirectoryPath;

var launchPath: String? { get set }
var currentDirectoryPath: String { get set }

Instance Methods

- (void)launch;

func launch()

Type Methods

+ (NSTask *)launchedTaskWithLaunchPath:(NSString *)path 
                             arguments:(NSArray<NSString *> *)arguments; 

class func launchedProcess(launchPath path: String, 
                 arguments: [String]) -> Process

There seemingly are no replacements available, so what gives?

rmaddy
  • 298,130
  • 40
  • 468
  • 517
l'L'l
  • 40,316
  • 6
  • 77
  • 124

1 Answers1

17

There seemingly are no replacements available

There are, the API is now URL related

Instance Properties

@property(copy) NSURL *executableURL;
@property(copy) NSURL *currentDirectoryURL;

var executableURL: URL? { get set }
var currentDirectoryURL: URL? { get set }

Instance Methods

- (BOOL)launchAndReturnError:(out NSError * _Nullable *)error;

func run() throws

Type Methods

+ (NSTask *)launchedTaskWithExecutableURL:(NSURL *)url 
                                arguments:(NSArray<NSString *> *)arguments 
                                    error:(out NSError * _Nullable *)error 
                       terminationHandler:(void (^)(NSTask *))terminationHandler;

class func run(_ url: URL, 
               arguments: [String], 
               terminationHandler: ((Process) -> Void)? = nil) throws -> Process
vadian
  • 232,468
  • 27
  • 273
  • 287