Wednesday, 17 October 2018

Resigning and Deploying Xamarin iOS Apps with Azure DevOps

Creating iOS mobile application with Xamarin is a good option for developers who are familiar with Visual Studio family of products. Any project you create nowadays demand for CI/CD implementation as it is the first step towards enabling DevOps. Azure DevOps comes with feature rich set of tasks for building the iOS apps. Tasks that allows re-signing of packaged ipa (iOS deployment files) are available as Marketplace task. App Center allows you to do mobile application testing in much simpler way. Let’s look at steps required to resign and deploy iOS package to APP Center using Azure DevOps pipelines.

Building iOS Xamarin projects to create the deployable ipa file can be done with the iOS.image

A build ipa can be packaged into a nuget package and added to Azure DevOps NuGet feed or other NuGet feed. Or you can publish the ipa as a build artifact.

Before deploying iOS application to target testing environment (or even to App Store for production use), you have to update the configurations of ipa package content and resign the package with required keys. This is fairly easy task in Azure DevOps as it offers hosted Mac OS agents. First step required is to receive the package containing ipa from Azure DevOps NuGet feed (if ipa published as build artifact this step is not required). Download Package task automatically extracts the package to default working folder (you can set the extract path using Destination Directory parameter).image

Then you can copy the ipa to a temporary location (root of working folder in this example) using copy task. image

ipa files can be extracted using unzip command in Mac OS terminal. It is advisable to extract to a folder, named ipa in this example.

unzip youipaname.ipa -d $(System.DefaultWorkingDirectory)/ipaimage

Then you can use a replace token task and replace any configuration file variables tokens with release definition variable values. In order for this to work in your build you should be transforming the variable values in to tokens as described in this post. After changing config values you have to repack the ipa. For this you can use zip command. But make sure to execute the command from within the ipa content root folder to ensure it is getting packaged as ipa with the correct structure. First command deletes existing ipa in working directory and then second one create the ipa (notice the . at the end of second command).

rm $(System.DefaultWorkingDirectory)/youipaname.ipa

zip -r $(System.DefaultWorkingDirectory)/youipaname.ipa .image

Once ipa is repacked, it should be resigned using the Ipa Resign task available with the extension Apple App Store in the marketplace.image

Resigned ipa can be deployed to app center using app center deployment task. App slug should be orgname/app name in app center. The destination id  should be the app center distribution group id.image

No comments:

Popular Posts