Swiftpack.co - aydenp/PassEncoder as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Simple PassKit (Apple Wallet) encoding and signing in Swift.
.package(url: "https://github.com/aydenp/PassEncoder.git", from: "1.0.0")


Apple Wallet (formerly Passbook) pass encoding and signing in Swift.


  • Modern Swift API
  • Allows you to specify custom pass data
  • Add other files (images, JSON, etc)
  • Manifest generation
  • Signing support
  • File system managed seamlessly
  • Get pass Data easily


  • iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+
  • Or Linux with zlib development package
  • Xcode 9.0
  • Swift 4.0
  • OpenSSL


Swift Package Manager

Add the following line to your dependencies section of Package.swift:

.package(url: "https://github.com/aydenp/PassEncoder.git", .upToNextMajor(from: "1.0.0"))

and add "PassEncoder" to your target's dependencies.


// Create our encoder
if let encoder = PassEncoder(passDataURL: directory.appendingPathComponent("pass.json")) {
    // Add a nice icon
    encoder.addFile(from: directory.appendingPathComponent("icon.png"))
    let passData = encoder.encode(signingInfo: (certificate: URL_TO_CERT.PEM, password: CERT_PASSWORD))
    // Your archived .pkpass file is in passData as Data

Before using the library, you'll also need to set the Apple WWDR certificate URL, which you can read about below.

Heads up! Operations in this library are all synchronous, so it is advisable to run them on a separate OperationQueue so that they do not block your thread.

Creating and preparing your certificate

You need to repeat this step for each different passTypeId you have in your pass.json.

  1. Go to the Apple Developer Pass Type IDs page and create your pass type.
  2. Go to the certificate section and follow the instructions to create a certificate for your pass.
  3. Download the certificate, and ensure it is named Certificates.p12.
  4. Run the following command: openssl pkcs12 -in Certificates.p12 -out PassCert.pem.
  5. Your pass certificate is now stored in PassCert.pem!

You'll also need to download the Apple Worldwide Developer Relations Root Certificate Authority file to sign passes.

  1. Download the certificate from here.

  2. Import it into Keychain Access (double click it).

  3. Find it in Keychain Access, and export it as a .pem file.

  4. Set the PassSigner's WWDR URL to it in your code.

     PassSigner.shared.appleWWDRCertURL = URL(fileURLWithPath: PATH_TO_WWDR_CERT.PEM)


To take full advantage of the package, check out the documentation and see all of the methods and variables that are made available to you.


Feel free to contribute to the source code of PassEncoder to make it something even better! Just try to adhere to the general coding style throughout, to make it as readable as possible.

If you find an issue in the code or while using it, create an issue. If you can, you're encouraged to contribute and make a pull request.


This project is licensed under the MIT license. Please make sure you comply with its terms while using it in any way.



Stars: 20
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics