alper
alper

Reputation: 3390

No profiles for 'xyz' were found: Xcode couldn't find any iOS App Development provisioning profiles matching xyz (works locally)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

MacOS

Question

I am trying to run a Azure Pipeline for Task Name: Xcode@5.

Xcode@5 fails to build an Xcode project couldn't find any iOS App Development provisioning profiles matching profile_name, resulting in a Code Signing Error with this format:

trigger:
- none

pool:
  vmImage: 'macOS-14'

resources:
 repositories:
 - repository: AheLineIOS
   type: git
   name: AheLineIOS/AheLineIOS
   trigger:
     branches:
       include:
       - deneme
     paths:
       include:
       - AHELine.UI/*
       - AheLine.Robo/*
       - AHELine.Data/*
       - AHELine.Common/*
       - Pods/*
       exclude:
       - ExportOptions_prod.plist

steps:
- checkout: AheLineIOS
  clean: true

- task: PowerShell@2
  displayName: Select Xcode Version
  inputs:
    targetType: 'inline'
    script: |
      echo Mac OS version:
      sw_vers -productVersion
      echo Installed Xcode versions:
      ls /Applications | grep 'Xcode'
      echo currently selected xcode:
      xcrun xcode-select --print-path
      echo selecting latest xcode...
      sudo xcode-select -s /Applications/Xcode_15.0.1.app
      xcrun xcode-select --print-path
      echo Selected Xcode version:
      xcodebuild -version
      xcodebuild -downloadAllPlatforms
  
- task: InstallAppleCertificate@2
  inputs:
    certSecureFile: 'DistributionCertificates2024.p12'
    certPwd: '$(provisioningProfilePassword2)'
    keychain: 'temp'
  
- task: InstallAppleProvisioningProfile@0
  inputs:
    provProfileSecureFile: 'AheMobilProd.mobileprovision'
    removeProfile: true
  
- task: Xcode@5
  inputs:
    actions: 'clean'
    configuration: 'Release'
    sdk: 'iphoneos'
    xcWorkspacePath: 'AheLine.xcworkspace'
    scheme: 'AHELine.UI'
    packageApp: true
    signingOption: 'auto'
    useXcpretty: false

- task: CopyFiles@2
  displayName: Copy ipa file
  inputs:
    SourceFolder: 'output/$(SDK)/$(Configuration)'
    Contents: '*.ipa'
    TargetFolder: '$(System.ArtifactsDirectory)/ipa'
    CleanTargetFolder: true
    OverWrite: true

- task: PublishPipelineArtifact@1
  inputs:
    targetPath: 'output/$(SDK)/$(Configuration)'
    artifact: 'ipaRelease'
    publishLocation: 'pipeline'

Important section where error is generated from in Xcode@5 task:

- task: Xcode@5
  inputs:
    actions: 'clean'
    configuration: 'Release'
    sdk: 'iphoneos'
    xcWorkspacePath: 'AheLine.xcworkspace'
    scheme: 'AHELine.UI'
    packageApp: true
    signingOption: 'auto'
    useXcpretty: false

Here's the output where I recieve the error:

/Users/runner/work/1/s/AHELine.UI/AHELine.UI.xcodeproj: 
error: No profiles for 'com.ahe.aheline' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.ahe.aheline'. 
Automatic signing is disabled and unable to generate a profile. 
To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'AHELine.UI' from project 'AHELine.UI')
** ARCHIVE FAILED **


##[error]Error: The process '/usr/bin/xcodebuild' failed with exit code 65

=> InstallAppleCertificate: https://gist.github.com/avatar-lavventura/64943138a05f5ca67afcd2d0361429df

=> InstallAppleProvisioningProfile: https://gist.github.com/avatar-lavventura/73f926e1e5c89d90504a57095193fe16

Upvotes: 1

Views: 137

Answers (1)

cristallo
cristallo

Reputation: 2089

On azure hosted macOS machine you cannot use the signingOption="auto" but you have to use signingOption="manual" with specific $(APPLE_CERTIFICATE_SIGNING_IDENTITY) $(APPLE_PROV_PROFILE_UUID) variables.

InstallAppleCertificate and InstallAppleProvisioningProfile tasks set both variables for you.

task: Xcode@5
  inputs:
    actions: 'archive'
    configuration: 'Release'
    sdk: 'iphoneos'
    xcWorkspacePath: 'AheLine.xcworkspace'
    scheme: 'AHELine.UI'
    packageApp: true
    signingOption: 'manual'
    signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
    provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'

You may also need to remove the following lines:

useXcpretty: false
args: '-verbose CODE_SIGNING_ALLOWED=No'
exportOptions: 'specify'
teamId: "Team Id" 
exportTeamId: "Team Id"

signingOption="auto" option is designed to be used on Self-hosted macOS machine with a properly pre-configured Apple account.

Note that the certificate and provisioning profile must match, in my case I preferred to manually generate the distribution ones instead of using the XCode auto-generated ones.

Upvotes: 1

Related Questions