본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

fastlane 문제 해결

원문 보기 위키 갱신

이 가이드는 iOS 개발에서 흔히 겪는 fastlane 문제 중 일부를 해결하기 위한 것이에요. 특히 Buildkite Pipelines로 iOS 앱을 빌드할 때의 문제를 다루어요.

출처: 문서

본문

필수 디버깅 단계

fastlane이 실패하면 다음 문제 해결 단계부터 시작해요.

  1. 자세한 오류 정보를 위해 verbose 로깅을 활성화해요.

    fastlane [lane] --verbose
    
  2. 분석을 위해 fastlane 로그를 빌드 아티팩트로 업로드해요.

    • 파이프라인에서 빌드 아티팩트를 구성해 fastlane 또는 xcodebuild 로그를 업로드해요.
    • fastlane의 간소화된 오류 메시지 주변에서 실제 오류를 찾아보세요. verbose 로그를 살펴보면, fastlane이 자체의 간소화된 오류 메시지를 보고하는 부분 주변에서 실제 오류를 자주 발견할 수 있어요. 코드 서명 오류의 경우 "codesign", "security", "provisioning profile"이 포함된 메시지를 특히 찾아보세요.
    • 코드 서명 문제의 경우 $HOME/Library/Logs/gym/*을 확인해요. fastlane의 코드 서명 오류에 대해 더 알아보려면 fastlane 문서의 Debugging codesigning issues를 참고하세요.
  3. 다음 진단 명령으로 환경을 확인해요.

    # Check code signing certificates
    security find-identity -v -p codesigning
    
    # Verify keychain configuration
    security list-keychains
    
    # List provisioning profiles
    ls -la ~/Library/MobileDevice/Provisioning\ Profiles/
    

fastlane 오류와 해결 방법

이 섹션은 Buildkite Pipelines로 iOS 앱을 빌드할 때 겪을 수 있는 fastlane 오류 중 일부와 그 해결 방법을 다루어요.

CocoaPods 샌드박스 오류

오류 메시지:

The sandbox is not in sync with the Podfile.lock.
Run 'pod install' or update your CocoaPods installation.

샌드박스는 프로젝트의 설치된 의존성(pods)을 포함하는 Pods 디렉터리를 말해요. 이 오류는 설치된 의존성이 Podfile.lock 파일에 지정된 pods와 버전과 일치하지 않을 때 발생해요. Pods 디렉터리를 저장소에 커밋하지 않고 Podfile과 Podfile.lock 파일만 커밋한 뒤 CI 빌드 중에 의존성을 다시 빌드하는 것이 모범 사례예요.

해결 방법:

오류를 해결하려면 표준 Pod 설치 명령을 실행해요.

lane :build do
  # This will run pod install
  cocoapods()

  # Rest of your lane...
end

이 방법으로 해결되지 않으면 전체 Pods 디렉터리를 다시 빌드해 보세요.

lane :build do
  # This will delete and rebuild your entire Pods directory
  cocoapods(clean_install: true)

  # Rest of your lane...
end

이 두 해결 방법으로도 여전히 해결되지 않으면 일관된 환경을 보장하세요.

  • fastlane을 호출하기 전에 bundle install을 실행해 Gemfile.lock을 기반으로 모든 Ruby gem이 설치되었는지 확인해요. CocoaPods도 Ruby gem이기 때문이에요.
  • bundle exec fastlane으로 fastlane을 실행해 Gemfile.lock에 지정된 gem 버전을 사용해요.

Ruby gem 의존성 오류

오류 메시지:

bundler: failed to load command: fastlane (/opt/homebrew/lib/ruby/gems/3.4.0/bin/fastlane)

/opt/homebrew/lib/ruby/gems/3.4.0/gems/fastlane-2.187.0/fastlane/lib/fastlane/cli_tools_distributor.rb:125:in 'Fastlane::CLIToolsDistributor.take_off': uninitialized constant FastlaneCore::UpdateChecker (NameError)

[⠋] 🚀 /opt/homebrew/lib/ruby/gems/3.4.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:11: warning: mutex_m was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.

You can add mutex_m to your Gemfile or gemspec to silence this warning.

/opt/homebrew/lib/ruby/gems/3.4.0/gems/json-2.2.0/lib/json/generic_object.rb:2: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.

You can add ostruct to your Gemfile or gemspec to silence this warning.

[⠙] 🚀 /opt/homebrew/lib/ruby/gems/3.4.0/gems/highline-2.0.3/lib/highline.rb:17: warning: abbrev was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.

You can add abbrev to your Gemfile or gemspec to silence this warning.

해결 방법:

macOS에서 호스팅되는 Buildkite 에이전트에는 Homebrew로 설치된 Ruby 3.4+가 있어요. Ruby 3.4+에서는 mutex_m과 abbrev gem이 더 이상 기본 gem이 아니에요. Ruby 3.5+에서는 ostruct가 더 이상 기본 gem이 아니게 되어 fastlane이 실패하게 돼요.

이 차이를 고치려면 Gemfile에 다음 gem들을 추가해야 해요.

gem 'mutex_m'
gem 'ostruct'
gem 'abbrev'

코드 서명 실패

오류 메시지:

The following build commands failed:

CodeSign /Users/agent/buildkite/builds/...

Exit status: 65

이 오류는 코드 서명 과정 중에 발생해요. 코드 서명에는 여러 구성 요소가 올바르게 설정되어야 해요.

  • 인증서와 개인 키:

    • 개발자의 신원을 검증하기 위해 Apple이 발급한 인증서.
    • 키체인에 있는 개인 키.
    • 둘 다 키체인에 올바르게 가져와야 해요.
  • 프로비저닝 프로파일:

    • ~/Library/MobileDevice/Provisioning Profiles/에 설치된 .mobileprovision 파일.
    • 앱의 번들 식별자와 일치해야 해요.
    • 서명에 사용되는 인증서를 포함해야 해요.
    • 앱의 자격(entitlements, 예: 푸시 알림 지원)을 포함해야 해요.
    • 만료되지 않아야 해요.
  • 키체인 접근:

    • 빌드 중에 키체인이 잠금 해제되어 있어야 해요.
    • 키체인은 기본 login.keychain-db가 아니어야 해요.
  • Xcode 빌드 설정:

    • Signing identity: 키체인의 인증서.
    • Provisioning profile: 앱 번들 ID와 일치하는 유효한 .mobileprovision 파일.
    • Matching team ID: 인증서와 프로파일 사이에 Apple Developer Team ID가 일치해야 해요.

Fastfile 빌드 구성 예시:

build_app(
  scheme: "AppName",
  workspace: "AppName.xcworkspace",

  # Code signing configuration
  export_method: "app-store",
  export_options: {
    provisioningProfiles: {
      "com.company.appname" => "AppName Distribution Profile"
    },
    teamID: "ABCD12345E"
  },
  codesigning_identity: "iPhone Distribution: Company Name (ABCD12345E)"
)

fastlane match 사용하기

fastlane 플랫폼은 match 도구를 제공하는데, 이 도구는 인증서와 프로파일을 만들고 저장하는 작업부터, 새 머신에서 코드 서명을 설정하는 작업, Git을 통해 여러 팀의 키와 프로파일을 처리하는 작업까지 담당해요.

fastlane match를 사용한다면 대부분의 코드 서명이 자동화돼요.

lane :build do
  # Match handles certificates and profiles automatically
  match(type: "appstore")
  
  build_app(
    scheme: "AppName",
    workspace: "AppName.xcworkspace"
  )
end

fastlane match에 문제가 있다면 Matchfile에서 문제를 찾고 fastlane 출력 로그를 확인해 보세요. match를 문제 해결하려면:

  • Matchfile 구성을 확인해요.
  • match 저장소 접근 권한을 확인해요.
  • 특정 오류를 위해 match 출력 로그를 검토해요.

더 알아보기 (Learn more)

fastlane 문제를 체계적으로 해결하려면 verbose 로깅과 진단 명령으로 실제 오류를 찾는 것이 핵심이에요. CocoaPods 샌드박스, Ruby gem 의존성, 코드 서명은 iOS 빌드에서 가장 자주 겪는 문제들이에요. 코드 서명을 자동화하려면 fastlane match를 사용해 보세요.