Daelhoser
Daelhoser

Reputation: 117

Azure Devops Pipeline Integration for iOS

I'm trying to continuously deliver my iOS application for QA testing. For that I first need to generate an ipa file. Unfortunately, I don't see it being generated in the 'XCode' task. I do see that the archive was created successfully and I do have the checkbox to generate the package. Below is my current yml file.

# Xcode

# Build, test, and archive an Xcode workspace on macOS.
# Add steps that install certificates, test, sign, and distribute an app, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/xcode

trigger:
- Development

pool: 'OSX'

steps:

- task: InstallAppleCertificate@2
  inputs:
    certSecureFile: 'MyAppDistributionCert-20200305.320pm.p12'
    certPwd: '$(MyAppiOSDistributionCert)'
    keychain: 'temp'

- task: InstallAppleProvisioningProfile@1
  inputs:
    provisioningProfileLocation: 'secureFiles'
    provProfileSecureFile: 'Bot_MyApp_Debug.mobileprovision'

- task: Xcode@5
  inputs:
    actions: 'clean build test archive'
    scheme: 'MyApp'
    sdk: 'iphonesimulator'
    configuration: 'Debug'
    xcWorkspacePath: '**/MyApp.xcworkspace'
    xcodeVersion: 'default' # Options: 8, 9, 10, default, specifyPath
    packageApp: true
    destinationPlatformOption: 'iOS'
    destinationSimulators: 'iPhone 8 Plus'
    signingOption: default
    provisioningProfileName: 'Bot_MyApp_Debug.mobileprovision'
    exportMethod: 'Development'
    exportPath: '$(system.defaultworkingdirectory)'

- task: CopyFiles@2
  inputs:
    contents: '**/*.ipa'
    targetFolder: '$(build.artifactStagingDirectory)'
- task: PublishBuildArtifacts@1

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

Upvotes: 5

Views: 7048

Answers (2)

Daelhoser
Daelhoser

Reputation: 117

Thank you for your help Levi Lu-MSFT. You led me in the right direction. Initially, the issue was that I had the wrong certificate for the provisioning and was using 'sdk iphonesimulator' instead of 'sdk iphoneos'. I then tried using two different provisioning profiles (one for the iphone target and one for the extension) but i was running into issues. Then i realized i could just use one cert and one provisioning profile with app groups enabled. This, along with other small changes allowed me to export and create an artifact. Although i'm still having issues with using my ipa to distribute the app via the MS App Center I think this ticket can be closed. Below is my yaml file in case someone runs into issues:

# Xcode

# Build, test, and archive an Xcode workspace on macOS.
# Add steps that install certificates, test, sign, and distribute an app, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/xcode

# The following lists all of the  Xcode options
# https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/xcode?view=azure-devops

trigger:
- Development

pool: 'OSX'

steps:

- task: InstallAppleCertificate@2
  inputs:
    certSecureFile: 'TFSDJR-Certificates.p12'
    certPwd: '$(TSFMyAppPW)' #MyAppiOSDistributionCert
    keychain: 'temp'


- task: InstallAppleProvisioningProfile@1
  inputs:
    provisioningProfileLocation: 'secureFiles'
    provProfileSecureFile: 'TFSMyAppDebug.mobileprovision'

- task: Xcode@5
  inputs:

  # Build Aurguments
    actions: 'clean'
    scheme: 'MyApp'
    **sdk: 'iphoneos'**
    configuration: 'Debug'
    xcWorkspacePath: '**/MyApp.xcworkspace'
    xcodeVersion: 'default' # Options: 8, 9, 10, default, specifyPath

# Package options
    packageApp: true
    exportOptions: specify
    **exportMethod: 'development'**
    exportPath: '$(system.defaultworkingdirectory)'
    teamId: YOURTEAMID
    exportTeamId: YOURTEAMID


- task: CopyFiles@2
  inputs:
    contents: '**/*.ipa'
    targetFolder: '$(build.artifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

Upvotes: 3

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30353

You can try specifying a different folder for exportPath (ie. $(agent.buildDirectory)/output/$(sdk)/$(configuration)) instead of $(system.defaultworkingdirectory), in case the contents(along with the ipa file) in default working folder is overwrote by the exported contents.

You can also check the log of xcode task to see if the ipa file was generated and where it was located.

You can aslo check out the archive path parameter for Xcode task. The ipa file will be placed in the folder defined in archive path. You can specify a customized place to store the ipa file. For below example i place the ipa file in folder $(system.defaultworkingdirectory)/archive. Then in the following task I will refer to the ipa file by the path $(system.defaultworkingdirectory)/archive/*.ipa

- task: Xcode@5
  inputs:
    ...
    exportPath: "$(agent.buildDirectory)/output/$(sdk)/$(configuration)"
    archivePath: "$(system.defaultworkingdirectory)/archive"


- task: CopyFiles@2
  inputs:
    sourceFolder: "$(system.defaultworkingdirectory)/archive"
    contents: '**/*.ipa'
    targetFolder: '$(build.artifactStagingDirectory)'
- task: PublishBuildArtifacts@1

Hope above helps!

Upvotes: 1

Related Questions