गाइड - CI/CD

Mac Mini M4 पर CircleCI सेल्फ-होस्टेड रनर कैसे सेट करें

एक समर्पित Mac Mini M4 पर CircleCI सेल्फ-होस्टेड मशीन रनर को इंस्टॉल और कॉन्फ़िगर करने की संपूर्ण चरण-दर-चरण गाइड। नेटिव Apple Silicon प्रदर्शन, स्थायी कैशिंग, और CircleCI क्लाउड macOS संसाधनों की तुलना में 80% तक सस्ता।

35 मिनट का पठन मार्च 2026 में अपडेट किया गया

1. Mac पर सेल्फ-होस्टेड CircleCI रनर क्यों उपयोग करें?

CircleCI क्लाउड-आधारित macOS एक्ज़ीक्यूशन वातावरण प्रदान करता है, लेकिन ये महत्वपूर्ण लागतों और सीमाओं के साथ आते हैं। CircleCI पर macOS संसाधन एक क्रेडिट-आधारित प्रणाली का उपयोग करते हैं, जहाँ macOS एक्ज़ीक्यूटर पर प्रत्येक मिनट रिसोर्स क्लास के आधार पर 50-100 क्रेडिट खपत करता है। अक्सर iOS बिल्ड चलाने वाली टीमों के लिए, यह जल्दी ही प्रति माह $300-$500 या उससे अधिक तक पहुँच सकता है।

MyRemoteMac के एक समर्पित Mac Mini M4 पर एक सेल्फ-होस्टेड रनर प्रति-मिनट बिलिंग को पूरी तरह समाप्त कर देता है। आपको स्थायी स्टोरेज, वार्म कैश, और पूर्ण रूट एक्सेस वाली एक समर्पित Apple Silicon मशीन एक फ्लैट मासिक शुल्क पर मिलती है, जो $85/माह से शुरू होता है। यहाँ एक विस्तृत तुलना है:

विशेषता CircleCI क्लाउड macOS MyRemoteMac सेल्फ-होस्टेड
लागत मॉडल 50-100 क्रेडिट/मिनट (~$0.06-$0.12/मिनट) $85/माह फ्लैट (असीमित मिनट)
आर्किटेक्चर Intel x86 या M1 (साझा) Apple M4 (समर्पित, नवीनतम)
बिल्ड गति ~14 मिनट (मध्यम iOS प्रोजेक्ट) ~5 मिनट (समान प्रोजेक्ट)
कैश परसिस्टेंस एफ़ेमरल (हर जॉब में रिस्टोर करना ज़रूरी) डिस्क पर स्थायी (तत्काल)
कतार प्रतीक्षा समय 30 सेकंड - 5 मिनट (प्लान के अनुसार भिन्न) 0 सेकंड (समर्पित हार्डवेयर)
गोपनीयता / डेटा नियंत्रण साझा इन्फ्रास्ट्रक्चर समर्पित मशीन, पूर्ण नियंत्रण
कस्टम सॉफ़्टवेयर केवल पूर्व-इंस्टॉल की गई इमेज पूर्ण रूट एक्सेस, कोई भी सॉफ़्टवेयर

मुख्य लाभ: एक स्थायी सेल्फ-होस्टेड रनर के साथ, DerivedData, Swift Package Manager कैश, और CocoaPods बिल्ड के बीच संरक्षित रहते हैं। अकेले यही बिल्ड समय को CircleCI के एफ़ेमरल क्लाउड macOS वातावरणों की तुलना में 50-70% तक कम कर सकता है, जो हर बार शून्य से शुरू होते हैं। M4 चिप के श्रेष्ठ सिंगल-थ्रेडेड प्रदर्शन के साथ मिलकर, आपके iOS बिल्ड नाटकीय रूप से तेज़ होंगे।

2. पूर्वापेक्षाएँ

शुरू करने से पहले, सुनिश्चित करें कि आपके पास निम्नलिखित हैं:

  • MyRemoteMac से एक Mac Mini M4 सर्वर ($85/माह से)
  • Performance, Scale, या Server प्लान वाला एक CircleCI खाता (सेल्फ-होस्टेड रनर के लिए एक सशुल्क प्लान आवश्यक है)
  • आपके Mac Mini तक SSH एक्सेस (आपकी MyRemoteMac सदस्यता के साथ प्रदान किया गया)
  • एक Apple Developer खाता (कोड साइनिंग और प्रोविज़निंग प्रोफ़ाइल के लिए)
  • YAML, CircleCI कॉन्फ़िगरेशन, और टर्मिनल कमांड से बुनियादी परिचय

3. चरण 1: अपने Mac Mini में SSH करें और डिपेंडेंसी इंस्टॉल करें

सबसे पहले, SSH के ज़रिए अपने Mac Mini M4 से कनेक्ट करें। जब आपने अपना MyRemoteMac सर्वर सेट किया था तब आपको अपने क्रेडेंशियल मिले होंगे। CircleCI रनर सेट करने से पहले हमें Xcode और iOS बिल्ड के लिए आवश्यक टूल इंस्टॉल करने होंगे।

SSH के ज़रिए कनेक्ट करें

# Connect to your Mac Mini M4
ssh admin@your-server-ip

# Verify you're on Apple Silicon
uname -m
# Expected output: arm64

# Check macOS version
sw_vers
# ProductName:    macOS
# ProductVersion: 15.2
# BuildVersion:   24C101

Homebrew और Xcode Command Line Tools इंस्टॉल करें

# Install Homebrew (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Add Homebrew to PATH
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

# Install Xcode Command Line Tools
xcode-select --install

# Accept the license agreement
sudo xcodebuild -license accept

Xcode इंस्टॉल करें (पूर्ण संस्करण)

iOS बिल्ड के लिए, आपको पूर्ण Xcode एप्लिकेशन की आवश्यकता होती है। इसे हेडलेस सर्वर पर इंस्टॉल करने का सबसे तेज़ तरीका xcodes का उपयोग करना है:

# Install xcodes CLI tool
brew install xcodes

# List available Xcode versions
xcodes list

# Install the latest stable Xcode
xcodes install 16.2

# Set it as the active Xcode
sudo xcode-select -s /Applications/Xcode-16.2.app/Contents/Developer

# Verify installation
xcodebuild -version
# Xcode 16.2
# Build version 16C5032a

iOS सिम्युलेटर और बिल्ड टूल इंस्टॉल करें

# Install the iOS 18 simulator runtime
xcodebuild -downloadPlatform iOS

# Verify simulator availability
xcrun simctl list runtimes
# == Runtimes ==
# iOS 18.2 (18.2 - 22C150) - com.apple.CoreSimulator.SimRuntime.iOS-18-2

# Install additional build tools
brew install xcbeautify fastlane swiftlint

4. चरण 2: CircleCI रनर एजेंट इंस्टॉल करें

CircleCI आपके Mac Mini को CircleCI प्लेटफ़ॉर्म से जोड़ने के लिए एक मशीन रनर एजेंट का उपयोग करता है। मशीन रनर CircleCI से जॉब्स प्राप्त करता है और उन्हें सीधे आपके macOS होस्ट पर एक्ज़ीक्यूट करता है। यह कंटेनर रनर से अलग है (जो केवल Linux पर काम करता है)।

रनर के लिए एक समर्पित उपयोगकर्ता बनाएं

सुरक्षा आइसोलेशन के लिए CircleCI एजेंट चलाने हेतु एक समर्पित उपयोगकर्ता बनाने की सलाह दी जाती है:

# Create a circleci user (optional but recommended)
sudo dscl . -create /Users/circleci
sudo dscl . -create /Users/circleci UserShell /bin/zsh
sudo dscl . -create /Users/circleci RealName "CircleCI Runner"
sudo dscl . -create /Users/circleci UniqueID 550
sudo dscl . -create /Users/circleci PrimaryGroupID 20
sudo dscl . -create /Users/circleci NFSHomeDirectory /Users/circleci
sudo mkdir -p /Users/circleci
sudo chown circleci:staff /Users/circleci

# Or simply use your existing admin user (simpler setup)

रनर एजेंट डाउनलोड और इंस्टॉल करें

# Create a directory for the runner
sudo mkdir -p /opt/circleci

# Download the latest CircleCI machine runner for macOS ARM64
# Check https://circleci.com/docs/runner-installation-mac/ for latest version
curl -o /tmp/circleci-runner.pkg \
  https://circleci-binary-releases.s3.amazonaws.com/circleci-runner/1.0/circleci-runner_darwin_arm64.pkg

# Install the runner package
sudo installer -pkg /tmp/circleci-runner.pkg -target /

# Verify the installation
circleci-runner --version

रनर एजेंट कॉन्फ़िगर करें

रनर कॉन्फ़िगरेशन फ़ाइल बनाएं। आपको CircleCI डैशबोर्ड से अपने रनर प्रमाणीकरण टोकन की आवश्यकता होगी (चरण 3 में शामिल)। अभी के लिए, कॉन्फ़िग फ़ाइल संरचना बनाएं:

# Create the configuration directory
sudo mkdir -p /opt/circleci/config

# Create the runner configuration file
sudo tee /opt/circleci/config/runner-agent-config.yaml << 'EOF'
api:
  auth_token: YOUR_RUNNER_TOKEN_HERE

runner:
  name: mac-mini-m4-runner
  working_directory: /opt/circleci/workdir
  cleanup_working_directory: true
  max_run_time: 5h

  # Optional: limit concurrent tasks
  # command_prefix: ["nice", "-n", "10"]

logging:
  file: /opt/circleci/logs/runner.log
EOF

# Create required directories
sudo mkdir -p /opt/circleci/workdir
sudo mkdir -p /opt/circleci/logs

# Set permissions (adjust user if using dedicated circleci user)
sudo chown -R admin:staff /opt/circleci

परसिस्टेंस के लिए एक macOS Launch Agent बनाएं

यह सुनिश्चित करने के लिए कि रनर बूट पर स्वचालित रूप से शुरू हो और क्रैश होने पर पुनः शुरू हो, एक macOS LaunchDaemon बनाएं:

# Create the LaunchDaemon plist
sudo tee /Library/LaunchDaemons/com.circleci.runner.plist << 'EOF'
<?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>Label</key>
    <string>com.circleci.runner</string>
    <key>ProgramArguments</key>
    <array>
        <string>/opt/circleci/circleci-runner</string>
        <string>machine</string>
        <string>--config</string>
        <string>/opt/circleci/config/runner-agent-config.yaml</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/opt/circleci/logs/runner-stdout.log</string>
    <key>StandardErrorPath</key>
    <string>/opt/circleci/logs/runner-stderr.log</string>
    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
    </dict>
</dict>
</plist>
EOF

# Load and start the service
sudo launchctl load /Library/LaunchDaemons/com.circleci.runner.plist

# Verify the service is running
sudo launchctl list | grep circleci
# Expected: PID listed with com.circleci.runner

# Check the logs
tail -f /opt/circleci/logs/runner.log

महत्वपूर्ण: जब तक आप एक वैध प्रमाणीकरण टोकन नहीं जोड़ते, रनर एजेंट कनेक्ट नहीं होगा। टोकन जनरेट करने के लिए पहले चरण 3 पूरा करें, फिर runner-agent-config.yaml फ़ाइल को असली टोकन के साथ अपडेट करें और सेवा को पुनः शुरू करें।

5. चरण 3: CircleCI डैशबोर्ड में रनर कॉन्फ़िगर करें

अब आपको CircleCI वेब इंटरफ़ेस में अपना रनर पंजीकृत करना होगा और एक प्रमाणीकरण टोकन जनरेट करना होगा। यह आपके Mac Mini को आपके CircleCI संगठन से जोड़ता है।

एक रिसोर्स क्लास बनाएं

CircleCI में, सेल्फ-होस्टेड रनर रिसोर्स क्लास द्वारा व्यवस्थित होते हैं। एक रिसोर्स क्लास एक लेबल है जो आपके .circleci/config.yml को रनर के एक विशिष्ट सेट से मैप करता है।

  1. CircleCI डैशबोर्डOrganization SettingsSelf-Hosted Runners पर जाएं
  2. "Create Resource Class" पर क्लिक करें
  3. Namespace को अपने संगठन के नाम पर सेट करें (उदाहरण: your-org)
  4. Resource Class नाम को कुछ वर्णनात्मक पर सेट करें (उदाहरण: mac-runner)
  5. इससे एक रिसोर्स क्लास पहचानकर्ता बनता है: your-org/mac-runner

एक रनर प्रमाणीकरण टोकन जनरेट करें

  1. रिसोर्स क्लास बनाने के बाद, "Create New Token" पर क्लिक करें
  2. टोकन को एक वर्णनात्मक नाम दें (उदाहरण: mac-mini-m4-token)
  3. जनरेट किए गए टोकन को तुरंत कॉपी करें — यह केवल एक बार दिखाया जाएगा

अपने टोकन के साथ रनर कॉन्फ़िगरेशन अपडेट करें

# SSH back into your Mac Mini
ssh admin@your-server-ip

# Update the runner configuration with your real token
sudo nano /opt/circleci/config/runner-agent-config.yaml

# Replace YOUR_RUNNER_TOKEN_HERE with the actual token:
# api:
#   auth_token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

# Restart the runner service to apply the new token
sudo launchctl unload /Library/LaunchDaemons/com.circleci.runner.plist
sudo launchctl load /Library/LaunchDaemons/com.circleci.runner.plist

# Verify the runner connects successfully
tail -20 /opt/circleci/logs/runner.log
# Look for: "Runner is ready to receive jobs"

कनेक्ट होने के बाद, रनर को CircleCI डैशबोर्ड में Self-Hosted Runners के अंतर्गत "Online" के रूप में दिखना चाहिए। यदि यह 60 सेकंड के भीतर नहीं दिखता, तो त्रुटि संदेशों के लिए लॉग फ़ाइल जाँचें।

CircleCI CLI का उपयोग करना (वैकल्पिक)

आप CircleCI CLI के ज़रिए भी रनर प्रबंधित कर सकते हैं:

# Install the CircleCI CLI
brew install circleci

# Authenticate with CircleCI
circleci setup

# Create a resource class via CLI
circleci runner resource-class create your-org/mac-runner \
  "Mac Mini M4 Runner" --generate-token

# List your runners
circleci runner instance list your-org/mac-runner

6. चरण 4: iOS बिल्ड के लिए अपना .circleci/config.yml बनाएं

अपने रिपॉज़िटरी के रूट में एक .circleci/config.yml फ़ाइल बनाएं। एक मानक CircleCI कॉन्फ़िग से मुख्य अंतर यह है कि अपने सेल्फ-होस्टेड रनर को टारगेट करने के लिए अपने कस्टम resource_class के साथ machine: true का उपयोग किया जाता है।

version: 2.1

jobs:
  build-and-test:
    machine: true
    resource_class: your-org/mac-runner

    environment:
      SCHEME: "MyApp"
      DESTINATION: "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2"
      DERIVED_DATA_PATH: "DerivedData"
      SPM_CACHE_PATH: ".spm-cache"

    steps:
      - checkout

      - run:
          name: Select Xcode version
          command: |
            sudo xcode-select -s /Applications/Xcode-16.2.app/Contents/Developer
            xcodebuild -version

      - run:
          name: Resolve Swift Package Dependencies
          command: |
            xcodebuild -resolvePackageDependencies \
              -scheme "$SCHEME" \
              -clonedSourcePackagesDirPath "$SPM_CACHE_PATH"

      - run:
          name: Build the app
          command: |
            xcodebuild build \
              -scheme "$SCHEME" \
              -destination "$DESTINATION" \
              -clonedSourcePackagesDirPath "$SPM_CACHE_PATH" \
              -derivedDataPath "$DERIVED_DATA_PATH" \
              | xcbeautify

      - run:
          name: Run unit tests
          command: |
            xcodebuild test \
              -scheme "$SCHEME" \
              -destination "$DESTINATION" \
              -clonedSourcePackagesDirPath "$SPM_CACHE_PATH" \
              -derivedDataPath "$DERIVED_DATA_PATH" \
              -resultBundlePath TestResults.xcresult \
              | xcbeautify

      - store_test_results:
          path: TestResults.xcresult

      - store_artifacts:
          path: TestResults.xcresult
          destination: test-results

workflows:
  ios-pipeline:
    jobs:
      - build-and-test:
          filters:
            branches:
              only:
                - main
                - develop

ध्यान दें: resource_class: your-org/mac-runner मान बिल्कुल उसी रिसोर्स क्लास से मेल खाना चाहिए जो आपने CircleCI डैशबोर्ड में बनाई थी। यदि यह मेल नहीं खाता, तो जॉब्स अनिश्चित काल तक कतार में रहेंगे।

7. चरण 5: कैशिंग और पैरेललिज़्म के साथ ऑप्टिमाइज़ करें

सेल्फ-होस्टेड रनर के सबसे बड़े लाभों में से एक स्थायी कैशिंग है। चूँकि रनर का फ़ाइलसिस्टम स्थायी होता है, आपको CircleCI क्लाउड संसाधनों की तरह कैश अपलोड और डाउनलोड करने की आवश्यकता नहीं होती। हालाँकि, अपनी बिल्ड गति को अधिकतम करने के लिए अतिरिक्त ऑप्टिमाइज़ेशन मौजूद हैं।

स्थायी DerivedData का लाभ उठाएं

चूँकि रनर डिस्क बिल्ड के बीच बनी रहती है, DerivedData पहले से ही स्वचालित रूप से कैश हो जाता है। एक सुसंगत पथ का उपयोग करें:

# In your config.yml steps, always use a consistent DerivedData path:
- run:
    name: Build with persistent cache
    command: |
      xcodebuild build \
        -scheme "$SCHEME" \
        -destination "$DESTINATION" \
        -derivedDataPath ~/DerivedData/"$SCHEME" \
        -clonedSourcePackagesDirPath ~/spm-cache \
        | xcbeautify

# Periodically clean old DerivedData on the runner (cron job):
# 0 3 * * 0 find ~/DerivedData -maxdepth 1 -mtime +7 -exec rm -rf {} +

जॉब्स के बीच वर्कस्पेस परसिस्टेंस

एक ही वर्कफ़्लो में जॉब्स के बीच आर्टिफ़ैक्ट पास करने के लिए CircleCI वर्कस्पेस का उपयोग करें:

jobs:
  build:
    machine: true
    resource_class: your-org/mac-runner
    steps:
      - checkout
      - run:
          name: Build
          command: |
            xcodebuild build \
              -scheme "MyApp" \
              -destination "generic/platform=iOS" \
              -derivedDataPath DerivedData
      - persist_to_workspace:
          root: .
          paths:
            - DerivedData

  test:
    machine: true
    resource_class: your-org/mac-runner
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Run tests
          command: |
            xcodebuild test \
              -scheme "MyApp" \
              -destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2" \
              -derivedDataPath DerivedData \
              | xcbeautify

workflows:
  build-test:
    jobs:
      - build
      - test:
          requires:
            - build

पैरेलल टेस्ट एक्ज़ीक्यूशन

- run:
    name: Run tests in parallel
    command: |
      xcodebuild test \
        -scheme "MyApp" \
        -destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2" \
        -destination "platform=iOS Simulator,name=iPhone 15,OS=17.5" \
        -parallel-testing-enabled YES \
        -maximum-parallel-testing-workers 4 \
        -derivedDataPath DerivedData \
        | xcbeautify

CircleCI टेस्ट स्प्लिटिंग

बड़े टेस्ट सूट के लिए, पैरेलल रनर में टेस्ट वितरित करने के लिए CircleCI की अंतर्निहित टेस्ट स्प्लिटिंग का उपयोग करें:

jobs:
  test:
    machine: true
    resource_class: your-org/mac-runner
    parallelism: 3
    steps:
      - checkout
      - run:
          name: Split and run tests
          command: |
            # Generate test plan
            TESTS=$(circleci tests glob "**/*Tests.swift" | \
              circleci tests split --split-by=timings)

            # Run only this container's portion of tests
            xcodebuild test \
              -scheme "MyApp" \
              -destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2" \
              -only-testing:$TESTS \
              | xcbeautify

8. वर्कफ़्लो उदाहरण

सामान्य iOS CI/CD परिदृश्यों के लिए यहाँ संपूर्ण, प्रोडक्शन-रेडी वर्कफ़्लो उदाहरण दिए गए हैं।

संपूर्ण iOS बिल्ड, टेस्ट, और डिप्लॉय पाइपलाइन

version: 2.1

jobs:
  lint:
    machine: true
    resource_class: your-org/mac-runner
    steps:
      - checkout
      - run:
          name: Run SwiftLint
          command: swiftlint lint --reporter json > swiftlint-results.json || true
      - store_artifacts:
          path: swiftlint-results.json

  build-and-test:
    machine: true
    resource_class: your-org/mac-runner
    steps:
      - checkout
      - run:
          name: Select Xcode
          command: sudo xcode-select -s /Applications/Xcode-16.2.app/Contents/Developer
      - run:
          name: Resolve dependencies
          command: |
            xcodebuild -resolvePackageDependencies \
              -scheme "MyApp" \
              -clonedSourcePackagesDirPath ~/spm-cache
      - run:
          name: Build and test
          command: |
            xcodebuild test \
              -scheme "MyApp" \
              -destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2" \
              -clonedSourcePackagesDirPath ~/spm-cache \
              -derivedDataPath ~/DerivedData/MyApp \
              -resultBundlePath TestResults.xcresult \
              -parallel-testing-enabled YES \
              | xcbeautify
      - store_test_results:
          path: TestResults.xcresult
      - store_artifacts:
          path: TestResults.xcresult

  deploy-testflight:
    machine: true
    resource_class: your-org/mac-runner
    steps:
      - checkout
      - run:
          name: Select Xcode
          command: sudo xcode-select -s /Applications/Xcode-16.2.app/Contents/Developer
      - run:
          name: Install certificates with Fastlane Match
          command: |
            fastlane match appstore --readonly
      - run:
          name: Build and upload to TestFlight
          command: |
            fastlane beta
          environment:
            FASTLANE_USER: ${APPLE_ID}
            MATCH_PASSWORD: ${MATCH_PASSWORD}

workflows:
  ios-pipeline:
    jobs:
      - lint
      - build-and-test:
          requires:
            - lint
      - deploy-testflight:
          requires:
            - build-and-test
          filters:
            branches:
              only: main

Fastlane एकीकरण उदाहरण

यदि आप अपने बिल्ड ऑटोमेशन के लिए Fastlane का उपयोग करते हैं, तो इसे अपने CircleCI सेल्फ-होस्टेड रनर के साथ एकीकृत करने का तरीका यहाँ दिया गया है:

# Fastfile (fastlane/Fastfile)
default_platform(:ios)

platform :ios do
  desc "Run tests"
  lane :test do
    scan(
      scheme: "MyApp",
      device: "iPhone 16 Pro",
      derived_data_path: "~/DerivedData/MyApp",
      result_bundle: true,
      output_directory: "./test_output"
    )
  end

  desc "Build and push to TestFlight"
  lane :beta do
    match(type: "appstore", readonly: true)
    increment_build_number(
      build_number: ENV["CIRCLE_BUILD_NUM"]
    )
    gym(
      scheme: "MyApp",
      export_method: "app-store",
      derived_data_path: "~/DerivedData/MyApp"
    )
    pilot(skip_waiting_for_build_processing: true)
  end
end
# .circleci/config.yml using Fastlane
version: 2.1

jobs:
  fastlane-test:
    machine: true
    resource_class: your-org/mac-runner
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: bundle install
      - run:
          name: Run Fastlane tests
          command: bundle exec fastlane test
      - store_test_results:
          path: ./test_output
      - store_artifacts:
          path: ./test_output

  fastlane-deploy:
    machine: true
    resource_class: your-org/mac-runner
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: bundle install
      - run:
          name: Deploy to TestFlight
          command: bundle exec fastlane beta

workflows:
  ios-workflow:
    jobs:
      - fastlane-test
      - fastlane-deploy:
          requires:
            - fastlane-test
          filters:
            branches:
              only: main

9. प्रदर्शन तुलना

CircleCI क्लाउड macOS संसाधनों और MyRemoteMac के एक सेल्फ-होस्टेड Mac Mini M4 के बीच यहाँ एक विस्तृत प्रदर्शन और लागत तुलना दी गई है:

बिल्ड समय बेंचमार्क

परिदृश्य CircleCI क्लाउड macOS सेल्फ-होस्टेड Mac Mini M4 सुधार
क्लीन बिल्ड (मध्यम ऐप) 14 मिनट 5 मिनट 2.8 गुना तेज़
इंक्रीमेंटल बिल्ड 14 मिनट (कोई कैश नहीं) 1.5 मिनट 9.3 गुना तेज़
SPM डिपेंडेंसी रिज़ॉल्यूशन 3-5 मिनट (हर बार डाउनलोड) 5 सेकंड (डिस्क पर कैश) ~60 गुना तेज़
यूनिट टेस्ट सूट (500 टेस्ट) 8 मिनट 2.5 मिनट 3.2 गुना तेज़
कतार प्रतीक्षा समय 30 सेकंड - 5 मिनट 0 सेकंड तत्काल

मासिक लागत विश्लेषण

टीम का आकार बिल्ड/माह CircleCI क्लाउड लागत MyRemoteMac लागत मासिक बचत
एकल डेवलपर 100 बिल्ड (औसतन 10 मिनट) $100/माह $85/माह $25/माह
छोटी टीम (5) 500 बिल्ड (औसतन 10 मिनट) $500/माह $85/माह $425/माह
मध्यम टीम (15) 1500 बिल्ड (औसतन 10 मिनट) $1,500/माह $229/माह (M4 Pro) $1,271/माह
एंटरप्राइज़ (50+) 5000+ बिल्ड $5,000+/माह $458/माह (2x M4 Pro) $4,542+/माह

निष्कर्ष: प्रति माह ~75 से अधिक बिल्ड चलाने वाली किसी भी टीम के लिए, एक सेल्फ-होस्टेड Mac Mini M4 तुरंत अपनी लागत वसूल कर लेता है। लागत बचत और भी बढ़ जाती है क्योंकि वार्म कैश वाले समर्पित हार्डवेयर पर बिल्ड तेज़ होते हैं, जिसका अर्थ है कि हर बिल्ड पहले से ही कम मिनट खपत करता है।

10. सामान्य समस्याओं का निवारण

रनर डिस्कनेक्ट हो जाता है या "Offline" दिखाता है

नेटवर्क समस्याओं या क्रैश हुई प्रक्रिया के कारण रनर एजेंट कनेक्शन खो सकता है। LaunchDaemon को स्वचालित रूप से पुनः शुरू होना चाहिए, लेकिन यदि ऐसा नहीं होता:

# Check if the process is running
ps aux | grep circleci-runner

# Check the LaunchDaemon status
sudo launchctl list | grep circleci

# View the error logs
tail -50 /opt/circleci/logs/runner-stderr.log
tail -50 /opt/circleci/logs/runner.log

# Restart the service
sudo launchctl unload /Library/LaunchDaemons/com.circleci.runner.plist
sudo launchctl load /Library/LaunchDaemons/com.circleci.runner.plist

# If the token expired, generate a new one in CircleCI dashboard
# and update /opt/circleci/config/runner-agent-config.yaml

resource_class नहीं मिला या जॉब्स कतार में अटके हुए

यदि जॉब्स "No matching runner found" के साथ कतार में रहते हैं, तो आपके कॉन्फ़िग में रिसोर्स क्लास डैशबोर्ड से मेल नहीं खाती:

# Verify the exact resource class name in CircleCI dashboard:
# Organization Settings > Self-Hosted Runners > Resource Classes

# The resource_class in .circleci/config.yml must match exactly:
# resource_class: your-org/mac-runner  (case-sensitive!)

# Check your runner is online:
circleci runner instance list your-org/mac-runner

# Common mistakes:
# - Wrong namespace (org name vs personal namespace)
# - Typo in resource class name
# - Runner is offline or token is invalid
# - Using 'docker' executor instead of 'machine: true'

Xcode कोड साइनिंग त्रुटियाँ

एक CI मशीन पर कोड साइनिंग के लिए सावधानीपूर्वक कीचेन प्रबंधन की आवश्यकता होती है। रनर प्रक्रिया के पास लॉगिन कीचेन तक पहुँच नहीं हो सकती:

# Option 1: Use Fastlane Match (recommended)
# In your Fastfile:
match(type: "appstore", readonly: true)

# Option 2: Manual keychain management in your job steps
- run:
    name: Setup code signing
    command: |
      # Decode and import the certificate
      echo "$BUILD_CERTIFICATE_BASE64" | base64 --decode > /tmp/cert.p12

      # Create a temporary keychain
      security create-keychain -p "ci" /tmp/ci.keychain
      security set-keychain-settings -lut 21600 /tmp/ci.keychain
      security unlock-keychain -p "ci" /tmp/ci.keychain

      # Import the certificate
      security import /tmp/cert.p12 -P "$P12_PASSWORD" \
        -A -t cert -f pkcs12 -k /tmp/ci.keychain
      security list-keychain -d user -s /tmp/ci.keychain

      # Install provisioning profile
      mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
      echo "$PROVISIONING_PROFILE_BASE64" | base64 --decode \
        > ~/Library/MobileDevice/Provisioning\ Profiles/profile.mobileprovision

सिम्युलेटर बूट होने में विफल या टाइम आउट हो जाता है

लंबे समय तक चलने वाली CI मशीनों पर सिम्युलेटर खराब स्थिति में आ सकते हैं। उन्हें बिल्ड के बीच रीसेट करें:

# Add a pre-build step to clean simulators
- run:
    name: Reset simulators
    command: |
      xcrun simctl shutdown all 2>/dev/null || true
      xcrun simctl erase all 2>/dev/null || true

# If a specific runtime is missing, reinstall it:
xcodebuild -downloadPlatform iOS

# List available simulators
xcrun simctl list devices available

डिस्क स्थान कम हो रहा है

Xcode बिल्ड बड़ी मात्रा में डेटा उत्पन्न करते हैं। अपने रनर पर स्वचालित सफ़ाई सेट करें:

# Check available disk space
df -h /

# Clean old DerivedData
rm -rf ~/Library/Developer/Xcode/DerivedData/*

# Remove old simulator runtimes
xcrun simctl runtime delete all

# Clean Homebrew cache
brew cleanup --prune=7

# Remove old CircleCI working directories
find /opt/circleci/workdir -maxdepth 1 -mtime +3 -exec rm -rf {} +

# Set up a weekly cron job for automatic cleanup
(crontab -l 2>/dev/null; echo "0 4 * * 0 rm -rf ~/Library/Developer/Xcode/DerivedData/* && brew cleanup --prune=7") | crontab -

11. अक्सर पूछे जाने वाले प्रश्न

Mac Mini M4 पर CircleCI सेल्फ-होस्टेड रनर की लागत कितनी है?

MyRemoteMac का एक समर्पित Mac Mini M4 असीमित बिल्ड मिनटों के साथ $85/माह से शुरू होता है। यह CircleCI के क्लाउड macOS रनर की तुलना में काफ़ी सस्ता है, जिनकी लागत लगभग $0.06-$0.12 प्रति मिनट होती है (सक्रिय टीमों के लिए मोटे तौर पर $300-500/माह)। सेल्फ-होस्टेड रनर पर कोई प्रति-मिनट शुल्क नहीं होता, इसलिए बिल्ड की मात्रा चाहे जो हो, आपकी लागतें पूर्वानुमेय रहती हैं।

क्या मैं iOS और macOS बिल्ड के लिए CircleCI सेल्फ-होस्टेड रनर का उपयोग कर सकता हूँ?

हाँ। Mac Mini M4 पर एक सेल्फ-होस्टेड रनर किसी भी macOS वर्कलोड को चला सकता है, जिसमें iOS बिल्ड, macOS ऐप बिल्ड, Swift पैकेज टेस्टिंग, Xcode UI टेस्ट, और Fastlane ऑटोमेशन शामिल हैं। चूँकि यह Apple Silicon पर नेटिव रूप से चलता है, बिल्ड एमुलेटेड या Intel-आधारित क्लाउड रनर की तुलना में तेज़ होते हैं।

CircleCI मशीन रनर और कंटेनर रनर में क्या अंतर है?

CircleCI मशीन रनर जॉब्स को सीधे होस्ट मशीन के ऑपरेटिंग सिस्टम पर एक्ज़ीक्यूट करता है, जो उन macOS/iOS बिल्ड के लिए आवश्यक है जिन्हें Xcode, सिम्युलेटर, और Apple फ्रेमवर्क की ज़रूरत होती है। कंटेनर रनर जॉब्स को Docker कंटेनरों के अंदर एक्ज़ीक्यूट करता है और केवल Linux पर उपलब्ध है। Mac बिल्ड के लिए, आपको मशीन रनर का उपयोग करना होगा।

मैं अपने CircleCI सेल्फ-होस्टेड रनर को अपडेटेड कैसे रखूँ?

CircleCI मशीन रनर एजेंट डिफ़ॉल्ट रूप से स्वचालित अपडेट का समर्थन करता है। आप CircleCI से नवीनतम रिलीज़ डाउनलोड करके और बाइनरी को बदलकर मैन्युअल रूप से भी अपडेट कर सकते हैं। महीने में एक बार अपडेट की जाँच करने और Xcode तथा macOS को भी अपडेटेड रखने की सलाह दी जाती है।

क्या एक सेल्फ-होस्टेड रनर CircleCI क्लाउड macOS की तुलना में तेज़ है?

हाँ, क्लीन बिल्ड के लिए आमतौर पर 2-3 गुना तेज़ और इंक्रीमेंटल बिल्ड के लिए 9 गुना तक तेज़। CircleCI क्लाउड macOS रनर एफ़ेमरल वातावरण के साथ साझा Intel या M1 हार्डवेयर का उपयोग करते हैं, जिसका अर्थ है कि हर बिल्ड एक कोल्ड कैश के साथ शुरू होता है। एक सेल्फ-होस्टेड Mac Mini M4 में समर्पित Apple Silicon प्रदर्शन, स्थायी DerivedData और SPM कैश, और कोई कतार प्रतीक्षा समय नहीं होता।

क्या मैं एक Mac Mini पर एक साथ कई CircleCI जॉब्स चला सकता हूँ?

हाँ। Mac Mini M4 में 10-कोर CPU और 16GB या अधिक RAM होती है, जो आराम से 2-3 समवर्ती बिल्ड जॉब्स संभाल सकती है। भारी वर्कलोड के लिए, 14 कोर और 24GB RAM वाला Mac Mini M4 Pro 4-6 समवर्ती जॉब्स संभाल सकता है। आप रनर कॉन्फ़िगरेशन फ़ाइल में रनर के अधिकतम समवर्ती कार्यों को कॉन्फ़िगर कर सकते हैं।

अपनी CircleCI पाइपलाइनों के लिए एक Mac Mini M4 से शुरुआत करें

अपने CircleCI सेल्फ-होस्टेड रनर के रूप में एक समर्पित Mac Mini M4 डिप्लॉय करें। असीमित बिल्ड मिनट $85/माह से शुरू।

और जानकारी चाहिए?

चरण-दर-चरण सेटअप, कॉन्फ़िगरेशन संदर्भ और समस्या-निवारण के लिए संपूर्ण दस्तावेज़ देखें।

दस्तावेज़ खोलें →