Sunday, July 17, 2016

A fun build trist: Xamarin.iOS, a provisioning profile, and a certificate

A [sarcasm]fun[/sarcasm] problem to have:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets : error: No installed provisioning profiles match the installed iOS signing identities.

I use Bitrise for my mobile CI.  While its a great system, sometimes opaque errors can increase your blood pressure.  Honestly, its not any fault of Bitirse, its more a Xamarin problem in general and the maturity of the tool-sets.

For my error I had created my Apple certificate and provisioning profile in the Apple Developer portal with no issues.  I always download and install the certificate (a development certificate in my case) onto my Mac's Keychain.

For Bitrise you need to export the p12 file for the certificate and upload into Bitrise:
Here you can see I've uploaded both the certificate and the provisioning profile and I've saved the password. All good so far.

After still getting the error from Bitrise:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets : error: No installed provisioning profiles match the installed iOS signing identities.

I forced the selection of the correct certificate in the iOS project properties:

Still no luck.

Next I decided to explicitly set the provisioning profile so it's not using "magic" to determine which profile to use.

Visual Studio doesn't seem to understand or recognise the list of valid provisioning profiles however, as for me, the drop down list is blank.  Nevermind, it can be set in the XML.
First get the provisioning profile ID from your provisoning profile file. Its a file with the extension .mobileprovision, that you download from the Apple Developer portal.  Find a section in the XML that has a key "UUID".  Next to it is the Provisioning Profile ID. Copy this value.
        <key>UUID</key>
<string>19000000-aaaa-bbbb-cccc-ddddeeeeffff</string>

Paste the value into your Xamarin.iOS project csproj file.  You'll need to know which build configuration it will be building on the CI server.  For me its, Ad-Hoc/iPhone

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
    <DebugType>none</DebugType>
    <Optimize>True</Optimize>
    <OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>False</ConsolePause>
    <MtouchArch>ARMv7, ARM64</MtouchArch>
    <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
    <BuildIpa>True</BuildIpa>
    <CodesignProvision>19000000-aaaa-bbbb-cccc-ddddeeeeffff</CodesignProvision>
    <CodesignKey>iPhone Developer: Ben Rees (XABCDEFGHI)</CodesignKey>
  </PropertyGroup>

Paste the value into the CodesignProvision element.  This will force the Xamarin Builder to go looking for that exact provisioning profile.

But still no luck.  
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets : error: No installed provisioning profiles match the installed iOS signing identities.

I also turned on some extra debugging in Bitrise and found this:
/Users/vagrant/git/iOS/Info.plist : error: Project bundle identifier 'biz.rees.CorporateBs' does not match specified provisioning profile '19000000-aaaa-bbbb-cccc-ddddeeeeffff'

AHA!  The Bundle App ID must be case sensitive!  In the Apple Developer Portal I specified it as 
biz.rees.CorporateBS

Problem solved.

No comments:

Post a Comment