Mac hosting guide

Jenkins iOS Build Pipeline on a Remote Mac

Keep Jenkins on your controller, attach a Mac as an agent labeled mac && ios, and run a five-stage Jenkinsfile that installs dependencies, archives, tests and exports the IPA. SSH is available on every Figment Mac plan.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Run Jenkins on your existing controller and attach a Mac as an agent that executes every iOS step: checkout, dependencies, archive, test and export. Label the agent mac && ios, launch it over SSH or as an inbound agent, and use the Jenkinsfile below. The syntax follows Jenkins' declarative pipeline reference and its managing nodes guide.

How do I connect the Mac to Jenkins?

Use SSH when the controller can reach the Mac, and an inbound agent when the Mac should start the connection. Every Figment Mac plan has SSH, so both directions are available. The Jenkinsfile is the same either way; only the launch method on the node differs.

ConnectionWho starts itChoose it when
SSH launchThe Jenkins controller connects to the MacThe controller can reach the Mac's SSH address
Inbound agent (java -jar agent.jar, WebSocket or JNLP)The Mac connects out to the controllerYour controller is behind a firewall and only allows outbound-initiated connections

How do I check the Mac is ready before the first build?

Run a short pre-flight script on the Mac first. It fails fast when a build dependency is missing, instead of letting the pipeline find out halfway through. Save it as preflight.sh and run chmod +x preflight.sh.

#!/usr/bin/env bash
set -euo pipefail

echo "Running as: $(whoami) on $(sw_vers -productName) $(sw_vers -productVersion), arch $(uname -m)"
for tool in java xcodebuild xcrun git brew bundle pod; do
  if command -v "$tool" >/dev/null 2>&1; then
    printf '  OK  %-12s -> %s\n' "$tool" "$(command -v "$tool")"
  else
    printf '  MISS %-12s (install before continuing)\n' "$tool"
  fi
done
xcodebuild -version
xcrun simctl list runtimes | head -5
security list-keychains -d user

If xcodebuild is missing, open Xcode once from the Applications folder and run sudo xcodebuild -license accept. If brew is missing, install Homebrew under the ci user, not root. If uname -m returns x86_64 (an Intel Mac VM), pin your pipeline to an Xcode release that still supports Intel and macOS Sequoia, and check the exact row in Apple's Xcode release notes.

How do I install the tools for the CI user?

Install everything as the ci user that Jenkins runs as, not under your own login.

# 1) Java 21 for the Jenkins agent
brew install openjdk@21

# 2) CocoaPods via Homebrew (avoids system-Ruby permission issues)
brew install cocoapods

# 3) Bundler for per-project Fastlane / xcpretty pins
gem install --user-install bundler

Confirm the PATH the Jenkins agent will see:

sudo -u ci -i bash -lc 'which xcodebuild pod bundle java'

Add the correct Homebrew prefix to ~ci/.zprofile: /opt/homebrew on Apple silicon, /usr/local on Intel. Append; do not overwrite an existing PATH.

What does the Jenkinsfile look like?

It has five declarative stages: checkout, install dependencies, build and archive, test, and export IPA. Replace MyApp with your scheme and workspace before the first run. The pipeline fails fast when they do not exist, so a typo cannot be reported as green. This code has not been executed against a specific project here; treat it as a template to adapt and dry-run on your own repository.

// Jenkinsfile — iOS CI pipeline on a Figment Mac node
pipeline {
    agent { label 'mac && ios' }

    options {
        timeout(time: 60, unit: 'MINUTES')
        buildDiscarder(logRotator(numToKeepStr: '30'))
        disableConcurrentBuilds()
    }

    parameters {
        string(name: 'SCHEME',         defaultValue: 'MyApp',             description: 'Xcode scheme in your project')
        string(name: 'WORKSPACE_FILE', defaultValue: 'MyApp.xcworkspace', description: 'Workspace file')
        string(name: 'SIM_DEVICE',     defaultValue: 'iPhone 16',         description: 'Simulator for the test stage')
    }

    environment {
        ARCHIVE_PATH = 'build/MyApp.xcarchive'
        EXPORT_DIR   = 'build/export'
        // Secret text binding: a single variable, no _USR / _PSW suffix.
        // _USR / _PSW are only added for Username-with-password credentials.
        KEYCHAIN_PW  = credentials('ci-keychain-password')
    }

    stages {
        stage('Checkout') {
            steps {
                checkout scm
                sh 'git submodule update --init --recursive'
            }
        }

        stage('Install Dependencies') {
            steps {
                sh '''
                    set -euo pipefail
                    bundle config set --local path vendor/bundle
                    bundle install
                    bundle exec pod install
                '''
            }
        }

        stage('Build & Archive') {
            steps {
                sh '''
                    set -euo pipefail
                    security unlock-keychain -p "$KEYCHAIN_PW" \
                        "$HOME/Library/Keychains/CI.keychain-db"

                    xcodebuild archive \
                        -workspace "$WORKSPACE_FILE" \
                        -scheme "$SCHEME" \
                        -configuration Release \
                        -destination "generic/platform=iOS" \
                        -archivePath "$ARCHIVE_PATH"
                '''
            }
        }

        stage('Test') {
            steps {
                sh '''
                    set -euo pipefail
                    set -o pipefail
                    xcodebuild test \
                        -workspace "$WORKSPACE_FILE" \
                        -scheme "$SCHEME" \
                        -destination "platform=iOS Simulator,name=${SIM_DEVICE},OS=latest" \
                        -resultBundlePath build/TestResults.xcresult \
                      | bundle exec xcpretty --report junit --output build/test-results.xml
                '''
                junit 'build/test-results.xml'
            }
        }

        stage('Export IPA') {
            steps {
                sh '''
                    set -euo pipefail
                    xcodebuild -exportArchive \
                        -archivePath "$ARCHIVE_PATH" \
                        -exportOptionsPlist ExportOptions-AppStore.plist \
                        -exportPath "$EXPORT_DIR"
                '''
                archiveArtifacts artifacts: 'build/export/**/*.ipa', fingerprint: true
            }
        }
    }

    post {
        always {
            // Best-effort cleanup only. A hard machine failure or force-termination
            // can prevent this block from running — do not rely on it for secret hygiene.
            sh '''
                security lock-keychain "$HOME/Library/Keychains/CI.keychain-db" || true
                rm -rf "$HOME/Library/Developer/Xcode/DerivedData/ModuleCache.noindex" || true
            '''
        }
        failure {
            echo "Build ${env.BUILD_NUMBER} failed on ${env.BRANCH_NAME ?: 'detached'}"
        }
    }
}

Each choice ties to a real failure mode:

  • set -euo pipefail plus set -o pipefail in the test stage make the shell exit on the first failed command, including the xcodebuild | xcpretty pipe. A failed test cannot be silently rewritten as a success.
  • disableConcurrentBuilds() stops two branches racing for the same keychain and DerivedData directory on one Mac.
  • The credentials('ci-keychain-password') binding for Secret text produces a single variable ($KEYCHAIN_PW). The _USR and _PSW pair is reserved for Username-with-password credentials, so do not append _PSW to a Secret text variable.
  • The signing identity is chosen through ExportOptions-AppStore.plist and the project's Signing & Capabilities panel, not on the xcodebuild command line, which keeps secrets out of ps aux output.
  • There are no benchmark numbers here. Timings depend on your project, scheme and Mac.

How do I handle the keychain and signing secrets?

Store the CI keychain password as a Jenkins Secret text credential with ID ci-keychain-password. The credentials() binding exposes it only inside the shell step and masks it in the console log. These rules keep the agent out of trouble:

  • Do not replace the user's keychain search list. If CI.keychain-db needs to be on the list, read the current list with security list-keychains -d user, append your entry, and restore the original list in a trap on exit. Overwriting the list silently breaks every tool that relies on login.keychain.
  • Signing certificate: export a password-protected .p12 (private key included) from a trusted Mac and import it with security import cert.p12 -k "$HOME/Library/Keychains/CI.keychain-db" -P "$P12_PW" -T /usr/bin/codesign. A certificate-only export cannot sign.
  • Provisioning profiles are files, not Keychain entries. Copy each .mobileprovision to ~/Library/MobileDevice/Provisioning Profiles/.
  • Never dump the whole environment to a plaintext file to move it between machines. Environment blocks can carry API keys and signing passwords. Transfer the required names only and fill in the values from your secret manager on the destination Mac.
  • Allowlists apply to services you control (your Jenkins controller, artifact store, Git host). Apple does not publish a stable IP range for App Store Connect or TestFlight.
  • Set umask 077 before writing any secret file, not after.
  • post { always {} } is best effort. Treat long-lived secrets on disk as if they will survive a crashed build, and rotate them accordingly.

Apple's Distributing your app for beta testing and releases documents the archive, export and upload sequence that this pipeline automates.

How do I trigger builds, keep archives and recover after a reboot?

Trigger builds from your Git host. For GitHub, install the GitHub plugin and declare:

triggers { githubPush() }

Set the repository webhook payload URL to https://your-jenkins-host/github-webhook/ and choose push or pull-request events. For GitLab, install the GitLab plugin and use https://your-jenkins-host/project/<job-name>.

archiveArtifacts stores the IPA on the Jenkins controller. The buildDiscarder(numToKeepStr: '30') option keeps roughly the last 30 builds so neither the Mac's disk nor the controller's artifact store fills up with stale exports.

After a Mac reboot, the agent does not come back by itself unless you set it up:

SSH-launched agent
keep Remote Login enabled in System Settings → General → Sharing. Jenkins reconnects on the next scheduled or manual build.
Inbound agent
install a user LaunchAgent that runs java -jar agent.jar -url <controller> -secret <value> -name <node> with KeepAlive=true and RunAtLoad=true, logging to ~/jenkins/agent.log. The exact command string and secret appear on the node's Status page in Jenkins. Launch the agent once by hand; the LaunchAgent handles later reboots.

A shutdown inside macOS does not stop billing, so a rebooted or idle agent still costs its plan price.

Which Figment Mac plan fits Jenkins iOS builds?

Use the Apple Silicon Mac VM ($39 a month, $6 a day) for one agent on current Xcode, and the Dedicated M4 Pro 48 GB ($349 a month) when you run parallel builds or heavy archives. The Intel Mac VM ($25 a month) runs macOS Sequoia, so it fits only when Xcode 26.3 or earlier is enough, and it cannot run arm64-only binaries or visionOS. Figment runs the Mac and network layer; you manage Jenkins, the agent, Xcode versions and your pipeline. We do not offer managed CI. Check the macOS version shown before purchase against Apple's Xcode table.

Related guides:

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan