Packages


How can I found out what packages are installed?


Repeatedly option-tapping the x in the inspector's title bar will cycle through the contexts known to the system (including the system itself).

You could also do this from code if you want to. Below is a code fragment which shows how to iterate over all the installed package contexts.

Private ObjectID
ReportOneContext(ObjectID context, Parameters* header)
{
   Str255  nameStr;
   char    packageStr[512];
   ObjectID softwarePackage;
   ObjectID citation;
        
   softwarePackage = Import(context, iSoftwarePackage);
   citation = Citation(softwarePackage);
        
   GetName(Title(citation), nameStr);
        
   SPrintF(packageStr, "%P Edition %d.%d", nameStr, MajorEdition(citation),
           MinorEdition(citation));
   Log((packageStr));
   return nilObject;
}
    
Method void
PackageReporterScene_ReportPackages(ObjectID self)
{
#pragma unused (self)

   OpenLog();
   EachContext(PackageContext_, (EachFunction)ReportOneContext, nil);
   CloseLog();
}


I'm writing a package that needs to get another package's context by calling FindSoftwarePackageByCitation. The minor version number of the package that I look for changes frequently since it is also under development. Will FindSoftwarePackageByCitation find the package if the minor version number does not match? If not, is there a way for me make FindSoftwarePackageByCitation ignore the minor version number in its search?


FindSoftwarePackageByCitation() ignores the minor version number. If the Citation object you pass to this routine specifies version 1.0, but the user has version 1.1, the context for that package will still get returned to you. Similarly, it's entirely possible that you request 1.1 but the user only has 1.0. In this case, you would still get a package context back.

Finally, FindSoftwarePackageByCitation() will return a package context to a package regardless of its packed state. If this matters to you, you should use FindActiveSoftwarePackageByCitation() instead.