Uncategorized

What’s In An App?

A Mac “application” is a bundle of files. These files include a signature to confirm that an application hasn’t been altered, executables, and a number of other files and folders. These are all stored in a directory called Contents. To see these, Control-Click on an application and click “Show Package Contents.”

The Contents directory includes:

  • _CodeSignature: All applications should be signed and contain a CodeResources file in this folder. If that doesn’t match the app will not open.
  • _MASReceipt: Contains a certificate from the App Store.
  • info.plist: Configuration information for the application, including 
  • MacOS: The Mach-O executable code file (Mach-O), which is a binary with an entry point and constantly linked code throughout, which when broken down includes:
    • Header: The header contains information about the binary (similar to a packet header) including the  type of CPU that will process the binary, the byte order, and the number of load commands the interpreter will receive. 
    • Load Commands: These load commands have the logical structure of an executable and the data that will be stored in virtual memory during processing, including the symbol tables.
    • Segments: The application code and data, compiled.
  • Resources: Images, logos, files to display in an app, etc. 
  • Framework: Private shared libraries and frameworks called by the binary. 
  • PlugIns: Loadable/pluggable files and libraries that are used to add application features. 
  • SharedSupport: Resources that can be loaded when needed but don’t extend the app functionality. 
  • Version.plist: Indicates if the app is an alias of another, the BuildVersion, a CFBundleShortVersionString, a CFBundleVersion, a ProductBuildVersion, a ProjectName, and a SourceVersion. 
  • XPCServices: Contains any .xpc bundles loaded with the app. Those are compiled and substantiate an XPC connection. For more on creating an XPC Service using the API, see https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingXPCServices.html

Additionally, many apps can call scripts and shared objects from other apps. Developers don’t consistently put things in different directories so it’s not uncommon to find a script you think would be in one place in a different area of an application bundle. I’ll have another post to hopefully add more context around this one soon.