Mac O’Clock
Published in

Mac O’Clock

macOS Tips and Tricks

Expanding PKGs on macOS

Photo by seth schwiet on Unsplash

Let’s say you’re on a computer where you don’t have administrative access, but you really need to use this one piece of software. In my case, this was Apple’s SF Symbols app. There’s a pretty simple way to extract the payload from the package (.PKG).

To get started, you first need two things. A macOS-equipped computer and a DMG with a PKG inside, or just a PKG. This tutorial will detail both.

Extracting the Package Contents

If your PKG is inside of a DMG, start here.

To extract the payload from a PKG inside of a DMG, we need to mount the DMG. There are two ways to do this. You can either use the Finder (double-click the DMG to mount it) or use the terminal with the following command:

hdiutil attach <PATH_TO_YOUR_DMG>
(EXAMPLE) hdiutil attach ~/Downloads/SF-Symbols.dmg

PKG Extraction

Now is where we have to use the terminal. In your terminal, navigate to the folder just above where you want your PKG to be extracted. An example command is as follows:

cd ~/Documents/

You can then proceed to extract the PKG with:

pkgutil --expand-full <PATH_TO_PKG> <FOLDER_TO_EXTRACT_TO>/
(PKG inside of DMG) pkgutil --expand-full /Volumes/<VOLUME_NAME>/<PACKAGE>.pkg <FOLDER_TO_EXTRACT_TO>/
(EXAMPLE) pkgutil --expand-full /Volumes/SFSymbols/SF\ Symbols.pkg extracted_package/

The snippet below is what my terminal looked like after extracting the package to the “extracted_package” folder.

Daedalus:~/Documents/extracted_package hkamran$ ls
Distribution Resources SFSymbols.pkg

To see what is inside of the payload, type:

cd <PACKAGE_NAME>.pkg/Payload/; open $(pwd)
(EXAMPLE) cd SFSymbols.pkg/Payload/; open $(pwd)

The open $(pwd) command opens the current directory with the Finder.

The folder hierarchy of the Payload folder is very simple. The directories are the places to put the files. For example, the directory Applications has “SF Symbols.app”, because that needs to be put in the Applications folder on your computer.

Once you have extracted the Payload, you can eject the volume (if you are using a DMG) or delete the PKG, as you no longer need it.

--

--

--

The best stories for Apple owners and enthusiasts

Recommended from Medium

Journal 36 — Modify UI for Ammo and Add a Wave System in Unity

DateFormatter() A Deep Vision

My understanding of Paradigm Shift in the programming world — from functional programming to…

A Trip to Objects and Classes

3 General Types of Programming Languages

Multithreaded Server with Java RMI

5 Design Patterns Every Engineer Must Know

Terraform and Ansible: Deploying a Multi-Region Architecture.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
H. Kamran

H. Kamran

I am a developer experienced in Python, JavaScript, Vue.js, Swift, and Git. I write about content that I find interesting or useful to share with the world.

More from Medium

Mac Mini vs Mac Studio

Best Ways To Uninstall Apps On Mac (2022 Guide)

Development in Windows 11 on M1 Mac Mini

Gaming on an M1 MacBook Air

hand held gaming devices and controllers