0

I want to upload a screen saver to the app store, after contacting them I was told to encapsulate the .saver inside the .app

I want to build a simple .app that launches the .saver which is in its bundle. However I failing to do so :(

I tried several solutions with NSTask and NSWorkspace but none works :(

Here are some attempts

    if(![[NSWorkspace sharedWorkspace] launchApplication:@"/Users/romanl/Desktop/XsaverApp/XsaverApp/SCTEST.saver/Contents/MacOS/SCTEST"])
    NSLog(@"Path Finder failed to launch");



    NSTask * task = [[NSTask alloc] init];
   [task setLaunchPath:@"/Users/romanl/Desktop/XsaverApp/XsaverApp/SCTEST.saver/Contents/MacOS/SCTEST"];
   [task launch];//Outputs : "Couldn't posix_spawn: error 8"

What is the approach to launch it ?

Coldsteel48
  • 3,482
  • 4
  • 26
  • 43

1 Answers1

0

Well I solved it now... If someone will be interested in future I posting the answer here

    [self.window close];
    NSTask * installTask = [[NSTask alloc]init];
    NSBundle * bundle = [NSBundle mainBundle];

    NSString * saverPath = [bundle pathForResource:@"CatsScreenSaver" ofType:@"saver"];

    NSMutableString * launchString = [[NSMutableString alloc]initWithString:@"open "];
    [launchString appendString:saverPath];

    [installTask setLaunchPath:@"/bin/bash"];

    NSArray *args = [NSArray arrayWithObjects:@"-l",
                 @"-c",
                 launchString,
                 nil];
    [installTask setArguments: args];
    [installTask launch ];

    [installTask waitUntilExit];
    [NSApp terminate:self];

The tricky part is here

        NSArray *args = [NSArray arrayWithObjects:@"-l",
                 @"-c",
                 launchString,
                 nil];
        [installTask setArguments: args];

Should put those arguments in NSTask in order to let it run Pathes from the user space.

Coldsteel48
  • 3,482
  • 4
  • 26
  • 43