Swiftpack.co - MortenGregersen/Bagbutik as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by MortenGregersen.
MortenGregersen/Bagbutik 3.1.3
Generated Swift code for the App Store Connect API based on the official OpenAPI spec.
⭐️ 112
🕓 6 weeks ago
iOS macOS watchOS tvOS linux
.package(url: "https://github.com/MortenGregersen/Bagbutik.git", from: "3.1.3")


Generated Swift code for the App Store Connect API based on the official OpenAPI spec.
Swift versions Platforms
CI Documentation Twitter

What is Bagbutik?

Bag·bu·tik (noun) /ˈb̥a̝w-ˌb̥u-tiːk/ - (Danish) A room behind a store

Bagbutik is two things, a command line tool for generating Swift code, and a library with the generated code for the App Store Connect API. The command line tool decodes the official OpenAPI spec for Apple's App Store Connect API.

While generating the code, the command line tool also downloads the official documentation from Apple's Documentation site for the App Store Connect API and applies it to the generated code, so you can get documentation right in Xcode.

The command line tool is only needed, when Apple publishes a new version of the spec. A GitHub Action automatically checks for new versions of the spec and creates a pull request with the changes.

How to use Bagbutik

Bagbutik uses JSON Web Tokens (JWT) for authorization. You obtain the required keys from your organization's App Store Connect account.

See Creating API Keys for App Store Connect API for how to create your keys.

Here is a basic example for fetching all bundle IDs for iOS apps including related profiles sorted by seed ID and the bundle ID itself descending.

import Bagbutik_Core
import Bagbutik_Provisioning

let service = BagbutikService(jwt: try .init(
    keyId: "P9M252746H",
    issuerId: "82067982-6b3b-4a48-be4f-5b10b373c5f2",
    privateKey: """
    -----BEGIN PRIVATE KEY-----
    -----END PRIVATE KEY-----
let response = try await service.request(
    .listBundleIdsV1(filters: [.platform([.iOS])],
                     includes: [.profiles],
                     sorts: [.seedIdDescending, .idDescending])

How to get Bagbutik into a project

Bagbutik supports Swift Package Manager and the internal libraries used to generate the code is also managed by it.

The library of generated code actually consists of multiple libraries, to let the consumer only depend on the endpoints needed. So to get Bagbutik, you need to decide which functionality you need.

In your Package.swift add Bagbutik as a dependency:

dependencies: [
    .package(url: "https://github.com/MortenGregersen/Bagbutik", from: "3.0.0"),

Then in targets add the libraries needed by your target:

targets: [
        name: "Awesome",
        dependencies: [
            .product(name: "Bagbutik-AppStore", package: "Bagbutik"),
            .product(name: "Bagbutik-TestFlight", package: "Bagbutik"),

If all libraries are needed, the umbrella library Bagbutik can be used:

targets: [
        name: "Awesome",
        dependencies: [
            .product(name: "Bagbutik", package: "Bagbutik"),

Remember to replace the hyphen with an underscore when importing the libraries.

When importing Bagbutik-TestFlight write:

import Bagbutik_TestFlight


The core library is Bagbutik-Core which contains the BagbutikService, the JWT, protocols and the general generated types like ErrorResponse and PagingInformation.

All other libraries depend on Bagbutik-Core. This is the only library which is documented on Bagbutik.dev, as the other libraries only contain types which are already documented by Apple.


Because the models from the API are used from many different endpoints, they are all located in Bagbutik-Models. All libraries with endpoints depend on Bagbutik-Models.


The endpoints of all the areas of the App Store Connect API are located in different libraries with a describing name.

Right now there are 6 libraries with endpoints:


Stars: 112
Last commit: 6 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.


Release Notes

6 weeks ago

What's Changed

Full Changelog: https://github.com/MortenGregersen/Bagbutik/compare/3.1.2...3.1.3

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