xtool Documentation

repository·main·Indexed 24 days ago

https://github.com/xtool-org/xtool

A cross-platform Xcode replacement for building, signing, and deploying iOS apps using SwiftPM on Linux, Windows (via WSL), and macOS. Features a CLI for managing Apple Developer Services, SDKs, and device interaction, as well as the XKit library for programmatic access to iOS devices and developer services.

Tokens
3.6K
Snippets
19
Records
28
Agent score
89%

What's inside xtool

  1. Add app entitlements

    main

    To add entitlements (e.g., for HomeKit), create an .entitlements file and reference it in xtool.yml using the entitlementsPath key.

    Troubleshooting Entitlements:

    • Some entitlements (like Network Extension) require a paid Apple Developer Program account.
    • Some require special permission from Apple (like User Notifications Filtering).
    • Many entitlements require specific 'Capabilities' to be enabled. xtool handles the mapping for supported capabilities, but if you encounter an unhandled one, you may need to report it.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>com.apple.developer.homekit</key>
        <true/>
    </dict>
    </plist>
  2. Add App Extensions to an xtool project

    main
    To add an App Extension (such as a Widget, Share Extension, or Safari Extension) to an existing xtool-based iOS application, you must declare the extension as a new product in Package.swift, register it in xtool.yml, provide an Info.plist for the extension, and implement the extension code.
  3. Install xtool on Linux

    main

    To install xtool, download the latest xtool.AppImage for your architecture from the GitHub Releases page, rename it to xtool, make it executable, and move it to a directory in your PATH (e.g., /usr/local/bin/).

    Verify the installation by running xtool --help.

    curl -fL \
      "https://github.com/xtool-org/xtool/releases/latest/download/xtool-$(uname -m).AppImage" \
      -o xtool
    chmod +x xtool
    sudo mv xtool /usr/local/bin/
    
    # Verify
    xtool --help
  4. Build xtool on macOS

    main

    To build the macOS version of xtool, you must use XcodeGen to generate the Xcode project. Follow these steps:

    1. Install XcodeGen.
    2. Navigate to the ./macOS directory within the repository.
    3. Run the xcodegen command to generate the project files.
    4. Open the generated Xcode project.
    5. Build the XToolMac scheme.
  5. Prerequisites for xtool on Linux

    main

    Before installing xtool, ensure the following dependencies are met:

    • Swift: Install the Swift 6.3 toolchain (or newer) from swift.org.
    • usbmuxd: Required for communicating with iOS devices. On Ubuntu/Debian, install via sudo apt-get install usbmuxd. It is also recommended to install libimobiledevice-utils for additional device interaction tools (like ideviceinfo).
    • Xcode: Download Xcode 26 (or the version required by your workflow) from the Apple Developer website. You will need the path to the .xip file during xtool setup.
  6. Configure xtool login and SDK

    main

    After installation, run xtool setup to perform a one-time configuration. This process involves two main steps:

    1. Login: Choose between two authentication modes:

      • 0: API Key: Recommended for paid Apple Developer Program members. Requires a Team Key with the App Manager role generated via App Store Connect.
      • 1: Password: For users without a paid membership. Uses private Apple APIs and requires email, password, and 2FA.
    2. SDK Setup: Provide the local path to your downloaded Xcode.xip file. xtool will extract it to generate and install the necessary iOS Swift SDK.

    Verify the SDK installation with swift sdk list.

    xtool setup
    
    # After setup, verify the SDK
    swift sdk list
  7. Declare an App Extension in Package.swift

    main

    Add a new .library product and a corresponding .target to your Package.swift file to represent the extension.

    let package = Package(
        name: "Hello",
        platforms: [.iOS(.v17)],
        products: [
            .library(
                name: "Hello",
                targets: ["Hello"]
            ),
            .library(
                name: "HelloWidget",
                targets: ["HelloWidget"]
            ),
        ],
        targets: [
            .target(name: "Hello"),
            .target(name: "HelloWidget"),
        ]
    )