1

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.

Zohar81
  • 4,554
  • 5
  • 29
  • 82
  • can you guide how to store these values in a file from a plugin and execute the script by using these values as an input. I have post install script in my installer which will use user email as an input value. – Zeeshan Suleman Nov 21 '20 at 10:04
  • Hi, you can use `writeToFile` ( `NSString` method) from each of your input values like `self.firstNameTextField.stringValue ` and that read the file from postinstall script using bash command like `cat yourFilePath` - just don't forget to remove the file in the end. – Zohar81 Nov 21 '20 at 19:00
  • what will be the path for this file? I mean if i create it from my installer plugin and write some data into it. where this file will be stored on my mac machine? – Zeeshan Suleman Nov 23 '20 at 07:48

0 Answers0