Search code examples
swiftxcodeazure-devopsazure-pipelinescicd

Azure devops pipeline xcode build archive failed with automatic code signin


I try to build a pipeline which enable to archive and upload build on test flight as CI/CD task. But when I try to archive build it continuously failed with code signing error.I made yml with auto sign in but still it give me error for sign in as account of developer did not added on xcode of azure pipeline.

Reason are following

 Using default simulator: iPhone 7.
    /usr/bin/xcodebuild -version
    Xcode 15.2
    Build version 15C500b
    
    /usr/bin/xcodebuild -sdk iphoneos -configuration Debug -workspace /Users/runner/work/1/s/xxxxx.xcworkspace -scheme xxxxxx -destination platform=ios Simulator,name=iPhone 7 archive -verbose
-allowProvisioningUpdates CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=xxxxxxx
    Command line invocation:
        /Applications/Xcode_15.2.app/Contents/Developer/usr/bin/xcodebuild
-sdk iphoneos -configuration Debug -workspace /Users/runner/work/1/s/xxxxxx.xcworkspace -scheme xxxxx -destination "platform=ios Simulator,name=iPhone 7" archive -verbose
-allowProvisioningUpdates CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=xxxxxxxx
    
    User defaults from command line:
        IDEPackageSupportUseBuiltinSCM = YES
    
    Build settings from command line:
        CODE_SIGN_STYLE = Automatic
        DEVELOPMENT_TEAM = xxxxxxx
        SDKROOT = iphoneos17.2
    
    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
    { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
    { platform:iOS Simulator, id:B06E40B9-47B6-4BA2-8E28-90AC66C3ADF4, OS:17.0.1, name:iPad (10th generation) }
    { platform:iOS Simulator, id:337853BE-7CA6-4920-82EF-47C6B3410DAD, OS:17.2, name:iPad (10th generation) }
    { platform:iOS Simulator, id:5293F755-CF59-4378-839E-0CBDA7CFA08C, OS:17.0.1, name:iPad Air (5th generation) }
    { platform:iOS Simulator, id:74DD7A76-4D60-4055-BA7D-8F0298ADCA60, OS:17.2, name:iPad Air (5th generation) }
    { platform:iOS Simulator, id:C8ECBCEA-380D-493A-A85F-C220E7EC871C, OS:17.0.1, name:iPad Pro (11-inch) (4th generation) }
    { platform:iOS Simulator, id:2A028112-D9A9-44AC-9296-F3BAC1BCBB3F, OS:17.2, name:iPad Pro (11-inch) (4th generation) }
    { platform:iOS Simulator, id:6639FAC9-EF1C-45FA-B010-D17C6DCE6446, OS:17.0.1, name:iPad Pro (12.9-inch) (6th generation) }
    { platform:iOS Simulator, id:555FF61B-3C0A-47D9-8D0D-96A1790F9D4A, OS:17.2, name:iPad Pro (12.9-inch) (6th generation) }
    { platform:iOS Simulator, id:02471309-E0BE-4F47-9833-25AFDE1D1357, OS:17.0.1, name:iPad mini (6th generation) }
    { platform:iOS Simulator, id:6464AF5D-17D8-4A45-A155-05EFCF792BD3, OS:17.2, name:iPad mini (6th generation) }
    { platform:iOS Simulator, id:5870AEBC-AC7B-4C21-86F6-065C10524EDA, OS:17.0.1, name:iPhone 14 }
    
    
    /Users/runner/work/1/s/xxxxxx.xcodeproj: error: No Accounts: Add a new account in Accounts settings. (in target 'xxxxx' from project 'xxxxx')
    /Users/runner/work/1/s/xxxxxx.xcodeproj: error: No profiles for 'xxxxxxx.xxx.xxx.xx' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'xxxxxxx.xxx.xxx.xx'. (in target 'xxxxxx' from project 'xxxxx')


trigger:
- development

pool:
  vmImage: 'macos-13'

jobs:
- job: iOS
  steps:

  - checkout: self
    submodules: true
    persistCredentials : true

  - task: UseRubyVersion@0
    inputs:
      versionSpec: '>=2.6'
      addToPath: true

  - task: Cache@2
    inputs:
      key: 'pods | "$(Agent.OS)" | Podfile.lock'
      path: 'Pods'
      cacheHitVar: 'PODS_CACHE_RESTORED'
  
  - task: CocoaPods@0
    displayName: 'pod install using the CocoaPods task with defaults'
    condition: ne(variables.PODS_CACHE_RESTORED, 'true')
    inputs:
        forceRepoUpdate: false

  - task: Xcode@5
    inputs:
      actions: 'clean'
      xcWorkspacePath: 'xxxxx.xcworkspace'
      scheme: '$(SCHEME)'
    displayName: Clean Build

  - task: Xcode@5
    inputs:
      actions: 'build'
      sdk: $(SDK)
      scheme: $(SCHEME)
      signingOption: 'auto'
      teamId: $(TEAMID)
      packageApp: false
      destinationPlatformOption: 'ios'
      configuration: $(CONFIGURATION)
      xcWorkspacePath: 'xxxx.xcworkspace'
      destinationSimulators: 'iPhone 15'
      args: '-verbose"'
      useXcpretty: false
    env:
      PODS_ROOT: '$(Build.SourcesDirectory)/Pods'
      PODS_XCFRAMEWORKS_BUILD_DIR: '$(Build.BinariesDirectory)/xcframeworks'

  - task: Xcode@5
    inputs:
      actions: 'archive'
      configuration: '$(CONFIGURATION)'
      xcWorkspacePath: 'xxxxx.xcworkspace'
      scheme: '$(SCHEME)'
      packageApp: true
      archivePath: '$(Build.BinariesDirectory).archive.xcarchive'
      exportPath: '$(Build.BinariesDirectory)/exported'
      signingOption: 'auto'
      teamId: '$(TEAMID)'
      destinationPlatformOption: 'ios'
      args: '-verbose -allowProvisioningUpdates'
      useXcpretty: false
    env:
      PODS_ROOT: '$(Build.SourcesDirectory)/Pods'
      PODS_XCFRAMEWORKS_BUILD_DIR: '$(Build.BinariesDirectory)/xcframeworks'

Solution

  • error: No profiles for 'xxxxxxx.xxx.xxx.xx' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'xxxxxxx.xxx.xxx.xx'. (in target 'xxxxxx' from project 'xxxxx')

    From your YAML sample, you are using Microsoft-hosted agent: macOS-13 agent. In this case, there are no pre-configured or cached credentials and provisioning profiles in the machine environment.

    You need to add the Install Apple Certificate task and Install Apple Provisioning Profile task to install certificates and provisioning profiles prior to the Xcode build.

    For example:

    steps:
    - task: InstallAppleCertificate@2
      inputs:
        certSecureFile: 'my-secure-file.p12' 
        certPwd: '$(P12password)'
    - task: InstallAppleProvisioningProfile@1
      inputs:
        provProfileSecureFile: 'my-provisioning-profile.mobileprovision' 
    
    - task: Xcode@5
    

    For more detailed info, you can refer to this doc: Sign your Apple iOS, macOS, tvOS, or watchOS app and Xcode@4 - Xcode v4 task

    Specifies the method of signing the build. Select Do not code sign to disable signing. Select Project defaults to use only the project's signing configuration. Select Manual signing to force manual signing and optionally specify a signing identity and provisioning profile. Select Automatic signing to force automatic signing and optionally specify a development team ID. If your project requires signing, use the Install Apple... tasks to install certificates and provisioning profiles prior to the Xcode build.

    Update:

    Here is a sample to manually sign app:

    steps:
    - task: InstallAppleCertificate@2
      inputs:
        certSecureFile: 'my-secure-file.p12' 
        certPwd: '$(P12password)'
    - task: InstallAppleProvisioningProfile@1
      inputs:
        provProfileSecureFile: 'my-provisioning-profile.mobileprovision' 
    - task: Xcode@5
      inputs:
        actions: 'build'
        scheme: 'App'
        sdk: 'iphoneos'
        configuration: 'Release'
        xcWorkspacePath: '**/App.xcworkspace'
        xcodeVersion: 'default'
        packageApp: true
        signingOption: 'manual'
        signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
        provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
        archivePath: "$(System.DefaultWorkingDirectory)/archive"