Skip to content

Instantly share code, notes, and snippets.

@wojtek717
Forked from shakaib-arif/README.md
Created April 27, 2022 12:51
Show Gist options
  • Save wojtek717/a03d28f52a1db9c5a973dac62688ffe1 to your computer and use it in GitHub Desktop.
Save wojtek717/a03d28f52a1db9c5a973dac62688ffe1 to your computer and use it in GitHub Desktop.
Azure Pipeline: iOS Application with App Extension

Pipeline: iOS Application with App Extension

Unfortunately there is not a straight forward way for the iOS application with App extension in Azure. But to make it work you'll have to do a couple of changes in the project that I'll share later.

Azure Pipeline: Xcode task

As per my recent experience to create the pipeline for such sort of application, the given xcode task from Azure is not capable to handle this case.

And I have later confirmed this from the PG team by reaching out to Azure DevOps support.

"The current version Xcode@5 has the limitation to build the application with App extension."

Project configuration

  1. Modify project file project.pbxproj
  2. Use xcodebuild command in terminal to compile commands for the pipeline

We have modified the project configuration in project.pbxproj file as proposed in the following link.

https://stackoverflow.com/a/29605731/3611427

This way we have a variable for each provisioning profile and later in the terminal we can assign values to it. I have gathered few commands to build and archive and used the same in

Workaround

Declare the following variables.

signingIdentity='iPhone Distribution: XXXX YYYY'
sdkOption='iphoneos'
configurationOption='Release'
workspaceName='MyApplication.xcworkspace'
schemeName='MyApplication'
APP_PROFILE_ID='00110011-0011-101-0011-000011110000'
APP_EXT_PROFILE_ID='00110011-0011-101-0011-000011110000'

Build Command

/usr/bin/xcodebuild -sdk $sdkOption -configuration $configurationOption -workspace $workspaceName -scheme "$schemeName" build -allowProvisioningUpdates CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="$signingIdentity" APP_PROFILE="$APP_PROFILE_ID"  EXTENSION_PROFILE="$APP_EXT_PROFILE_ID"

Archive Command

/usr/bin/xcodebuild -sdk $sdkOption -configuration $configurationOption -workspace $workspaceName -scheme "$schemeName" archive -allowProvisioningUpdates CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="$signingIdentity" APP_PROFILE="$APP_PROFILE_ID"  EXTENSION_PROFILE="$APP_EXT_PROFILE_ID"

Export Command

/usr/bin/xcodebuild -exportArchive -archivePath ~/Desktop/TestBuild.xcarchive -exportOptionsPlist $Build.SourcesDirectory/MyApplication-Info.plist -exportPath ~/Desktop/MyApplication.ipa
pool:
name: Azure Pipelines
demands: xcode
variables:
certSecureFileName: 'Certificates.p12'
P12Password: 'SomeStrongPassword2021!'
signingIdentity: 'iPhone Distribution: XXXX YYYY'
provProfileSecureFileOne: 'MyApplication.mobileprovision'
provProfileSecureFileTwo: 'OneSignal.mobileprovision'
sdkOption: 'iphoneos'
configurationOption: 'Release'
workspaceName: 'MyApplication.xcworkspace'
schemeName: 'MyApplication'
APP_PROFILE_ID: 00110011-0011-101-0011-000011110000
APP_EXT_PROFILE_ID: 00110011-0011-101-0011-000011110000
ArchivePath: ~/Desktop/TestBuild.xcarchive
ExportIpaPath: ~/Desktop/MyApplication.ipa
steps:
- task: InstallAppleCertificate@2
displayName: 'Install Certificates'
inputs:
certSecureFile: '$(certSecureFileName)'
certPwd: '$(P12Password)'
signingIdentity: '$(signingIdentity)'
- task: InstallAppleProvisioningProfile@1
displayName: 'Install App provisioning profile'
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: '$(provProfileSecureFileOne)'
- task: InstallAppleProvisioningProfile@1
displayName: 'Install App Extension (OneSignal) provisioning profile'
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: '$(provProfileSecureFileTwo)'
- task: CmdLine@2
inputs:
script: |
echo "Carthage installation"
cd $(Build.SourcesDirectory)
carthage update --platform iOS
displayName: 'Carthage dependencies'
- task: CmdLine@2
inputs:
script: |
echo "Pod installation"
cd $(Build.SourcesDirectory)
pod install
displayName: 'CocoaPods install'
- task: CmdLine@2
inputs:
script: |
echo "Build iOS app"
cd $(Build.SourcesDirectory)
/usr/bin/xcodebuild -sdk $(sdkOption) -configuration $(configurationOption) -workspace $(workspaceName) -scheme "$(schemeName)" build -allowProvisioningUpdates CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="$(signingIdentity)" APP_PROFILE="$(APP_PROFILE_ID)" EXTENSION_PROFILE="$(APP_EXT_PROFILE_ID)"
displayName: 'Xcode Buid'
- task: CmdLine@2
inputs:
script: |
echo "Archive the iOS app"
cd $(Build.SourcesDirectory)
/usr/bin/xcodebuild -sdk $(sdkOption) -configuration $(configurationOption) -workspace $(workspaceName) -scheme "$(schemeName)" archive -allowProvisioningUpdates CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="$(signingIdentity)" APP_PROFILE="$(APP_PROFILE_ID)" EXTENSION_PROFILE="$(APP_EXT_PROFILE_ID)" -archivePath $(ArchivePath)
displayName: 'Xcode Archive'
- task: CmdLine@2
inputs:
script: |
/usr/bin/xcodebuild -exportArchive -archivePath $(ArchivePath) -exportOptionsPlist $(Build.SourcesDirectory)/MyApplication-Info.plist -exportPath $(ExportIpaPath)
displayName: 'Xcode Export'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment