iOS (Xcode and Fastlane)
iOS compilation runs as a native script: job on an agent tagged macos.
Xcode is not containerized, and gocdnext plugins remain Linux OCI images. This
recipe uses Fastlane as the project-owned build interface: scan runs tests and
gym archives the app into an .ipa plus dSYMs.
Complete the macOS agent and
iOS toolchain/signing
runbooks first. The full copyable project is in examples/ios-build/.
Project convention
Section titled “Project convention”Commit these files with the app:
.gocdnext/ios.yamlGemfileGemfile.lockfastlane/Fastfilescripts/ios-build.shThe lockfile pins Fastlane, CocoaPods, and all transitive gems for both Apple Silicon and Intel Darwin. The host bootstrap selects a non-system Ruby; the project lock selects the build tools.
Set project-specific values in the pipeline:
variables: DEVELOPER_DIR: /Applications/Xcode_18.1.app/Contents/Developer IOS_WORKSPACE: MobileApp.xcworkspace IOS_SCHEME: MobileApp IOS_BUNDLE_ID: com.acme.mobile IOS_SIMULATOR_DEVICE: iPhone 16 Pro IOS_EXPORT_METHOD: app-store IOS_OUTPUT_NAME: MobileApp.ipa MATCH_GIT_URL: https://github.com/acme/ios-signing.gitDEVELOPER_DIR selects an Xcode installed side by side for this job only. It
does not mutate machine-wide xcode-select, so two app pipelines can migrate
between Xcode versions independently.
Test on Simulator
Section titled “Test on Simulator”The test job has no signing credentials and cannot run a plugin image:
jobs: test: stage: test tags: [macos] script: - source "$HOME/.config/gocdnext/ios-toolchain.env" - bundle config set --local path .bundle-cache - bundle check || bundle install --jobs 4 --retry 3 - if [ -f Podfile ]; then bundle exec pod install; fi - bundle exec fastlane test test_reports: [build/test-results/junit.xml] artifacts: paths: [build/test-results/]The example test lane calls scan, writes JUnit to a deterministic path, and
keeps its result bundle under build/test-results/ for diagnosis.
Produce the signed archive
Section titled “Produce the signed archive”The archive job runs only after the test stage succeeds. It declares exactly
the signing secrets it needs and is restricted to push/manual on main:
archive: stage: archive tags: [macos] secrets: - ASC_KEY_ID - ASC_ISSUER_ID - ASC_KEY_P8_BASE64 - MATCH_PASSWORD - MATCH_GIT_BASIC_AUTHORIZATION script: - source "$HOME/.config/gocdnext/ios-toolchain.env" - bundle config set --local path .bundle-cache - bundle check || bundle install --jobs 4 --retry 3 - if [ -f Podfile ]; then bundle exec pod install; fi - ./scripts/ios-build.sh artifacts: paths: - build/artifacts/*.ipa - build/artifacts/*.app.dSYM.zipThe wrapper only owns secret materialization and cleanup. Its build operation is exactly:
bundle exec fastlane buildThe build lane creates a temporary keychain, runs read-only match, and calls
gym. It then asserts that Fastlane returned both an IPA path and a dSYM zip;
missing symbols fail the job rather than silently publishing an incomplete
artifact set. An ensure block removes the keychain, while the wrapper removes
the mode-0600 .p8 outside the workspace and provides a second keychain
cleanup attempt on exit.
Real-Mac acceptance
Section titled “Real-Mac acceptance”Before calling the setup production-ready, run the example against the actual app and verify:
- routing selects the intended
macosagent andxcodebuild -versionmatchesDEVELOPER_DIR; scanexecutes the expected test plan and gocdnext ingests its JUnit file;matchresolves the expected App Store profile without changing its repo;gymproduces a signed.ipaand*.app.dSYM.zip, both downloadable from the run’s artifact list; and- no signing value appears in live or persisted logs, and no temporary keychain remains after either a successful or deliberately failed archive.
The repository tests validate the YAML, Fastfile syntax, argv and cleanup contracts on Linux. They cannot substitute for this Xcode/Apple smoke.