Creating an Embedded installer plugin for macOS application - how to pass parameters when run from command line

461 views Asked by At

I've created an installer using Packages with an additional plugin that has 2 text fields whose values are being printed upon moving forward to the next step on the installation wizard.

Here's the code :

MyInstallerPage.h

#import <InstallerPlugins/InstallerPlugins.h>

@interface MyInstallerPane : InstallerPane <NSTextFieldDelegate>

@end

MyInstallerPane.m

#import "MyInstallerPane.h"

@interface MyInstallerPane() {

}

@property (weak) IBOutlet NSTextField *firstNameTextField;
@property (weak) IBOutlet NSTextField *lastNameTextField;

@end

@implementation MyInstallerPane

- (NSString *)title
{
    return [[NSBundle bundleForClass:[self class]] localizedStringForKey:@"PaneTitle" value:nil table:nil];
}

- (void)didEnterPane:(InstallerSectionDirection)dir {
    self.firstNameTextField.delegate = self;
    self.lastNameTextField.delegate = self;
}

- (void)controlTextDidEndEditing:(NSNotification *)obj {
    NSLog(@"First name: %@", self.firstNameTextField.stringValue);
    NSLog(@"Last name : %@",
          self.lastNameTextField.stringValue);
}

@end

I wonder how do I set those text fields when running my the installer from command line using command /usr/sbin/installer -pkg ./MyPackage.pkg -target /

In the UI mode, when run my package using the command open myPackage.pkg, and I get the plugin window whereas I simply need to enter those values in the appropriate text fields.

enter image description here

One workaround for this problem is to use an additional script that perform the following steps instead of running the installer directly from command line.

  1. gets those values (first+last name) as input parameters and write them to special file.

  2. run the installer command installer -pkg....

  3. From within the installer. The plugin will check if textBoxes are empty (which is correct in the case of non-ui installation. In this case, it will lookup those values in the special file.

0

There are 0 answers