Handy Script to detect app installed and version
site_archiver@lists.apple.com Delivered-To: installer-dev@lists.apple.com Hi List, ------------------------------------ #!/usr/bin/perl use Foundation; use Mac::Processes; # find the application from the bundle indentifier $path = LSFindApplicationForInfo (undef, "com.apple.iPhoto"); print "iPhoto found at $path\n"; # now that we have the path - get the Info.plist file of the application $file = $path . "/Contents/Info.plist"; $plist = NSDictionary->dictionaryWithContentsOfFile_( $file ); if ( ! $plist or ! $$plist ) { print "Could not find iPhoto\n"; exit 96; } # search the plist for the version number of the app $version = 0.0; $value = $plist->objectForKey_("CFBundleShortVersionString"); if ($value && $$value) { $version = $value->description()->UTF8String(); } # test version number for minimum requirements print "Version: $version\n"; if ($version < 6.0) { print "Need iPhoto 6.0 or better\n"; exit 96; } exit 0; -------------------------- _______________________________________________ Do not post admin requests to the list. They will be ignored. Installer-dev mailing list (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/site_archiver%40lists.a... I thought some might find this tidbit of code useful. If you are creating a package installer that requires an application to be installed and that application must have a minimum version number here is a handy perl script to detect this. It will test the presence of an app and version number and cancel the installation if the requirements are not met. This sample script will detect if iPhoto is installed and test to make sure it's at least version 6.0 or better. Substitute the parameters appropriately to detect other apps and versions Save this perl script as InstallationCheck and put in the Contents/ Resources folder of the package. More information on using a InstallationCheck script can be found by Google'ing InstallationCheck (top hit takes you to the developer page here at apple). This email sent to site_archiver@lists.apple.com
participants (1)
-
Hagen Kaye