Q
Installing my application does not require to restart the Mac if it's installed for the first time. But a restart is required if a previous version is already installed. How can I do that?
A
It's possible to achieve this behavior with a distribution by relying on the fact that the installation will only take into account the post-installation behaviors of selected choices.
This article will describe how to do this with Packages.
Instructions
- Open Packages.
- Create a new Distribution project.
- Rename the default package to "Payload".
- Proceed as usual to configure this package but make sure Post-installation Behavior is set to "Do Nothing".
- Choose Project > New Package.
- Rename the default package to "Restart".
- Set a proper identifier for the Restart package and make sure Post-installation Behavior is set to "Require Restart".
- Select the Project item in the source list.
- Click the Presentation tab.
- Choose the Installation Type step.
- Select the Restart choice.
- Set its visibility to Invisible.
- Click the Requirements tab.
- Add a requirement.
- Define which requirement should trigger a restart (for instance the existence of a file in a specific location).
- Click OK.
You can now build your package and test it.
Sample Project