VISUAL STUDIO   Windows Mac

Manual Provisioning

Setting up a device for development

PDF for offline use
Related Articles:

Let us know how you feel about this

Translation Quality


0/250

last updated: 2017-07

Once Xamarin.iOS has been successfully installed, the next step in iOS development is to provision your iOS device. This guide will explore requesting development certificates and profiles, working with app services, and deploying an app to device.

Contents

Creating a Signing Identity

The first step in setting up a development device is to create a signing identity. A signing identity consists of two things:

  • A Development Certificate
  • A private key

Development certificates and associated keys are critical for an iOS developer: they establish your identity with Apple and associate you with a given device and profile for development, akin to putting your digital signature on your applications. Apple checks for certificates to control access to the devices you are allowed to deploy.

Development teams, certificates, and profiles can be managed by accessing the Certificates, Identifiers & Profiles section of Apple's Members Center. Apple requires you to have a signing identity in order to build your code for device or simulator.

⚠️

It is important to note that you can only have two iOS Development certificates at any one time. If you need to create any more, you will need to revoke an existing one. Any machine using a revoked certificate will not be able to sign their app.

To Generate a signing identity, do the following:

  1. Login to the Certificates, Identifiers, and Profiles section of the Developer Portal and select the Certificates section from the iOS Apps column. Then, hit the + to create a new certificate:

  2. Select the iOS App Development option for the certificate type and click Continue. This screen may look different depending on your account privileges:

  3. Request a Certificate Signing Request, which will be uploaded to generate a certificate manually. To do this, launch Keychain Access on a Mac. Navigate to the main menu, and select Certificate Assistant and Request a Certificate from a Certificate Authority..., as illustrated below:

  4. Fill in your information, and select the option to Save to disk:

  5. Save the CSR at a location where it can be easily found:

  6. Return to the Provisioning Portal, upload the Certificate to the portal, and submit:

    If you do not have admin privileges, the Certificate must be approved by an admin or team agent.

  7. Once the Certificate is approved, download it from the Provisioning Portal:

  8. Double-click on the downloaded Certificate to launch Keychain Access and open the My Certificates panel, showing the new certificate(s), and associated private key:

Understanding Certificate Key Pairs

The Developer Profile contains certificates, their associated keys, and any provisioning profiles associated with the account. There are actually two versions of a Developer Profile — one is on the Developer Portal, and the other lives on a local Mac. The difference between the two is the type of keys they contain: the Profile on the Portal houses all the public keys associated with your certificates, while the copy on your local Mac contains all the private keys. For the certificates to be valid, the key pairs must match. Keep a backup of the Developer Profile on the local Mac, because if the private keys are lost, all the certificates and provisioning profiles will need to be regenerated.

The Developer Profile contains certificates, their associated keys, and any provisioning profiles associated with the account. There are actually two versions of a Developer Profile — one is on the Developer Portal, and the other lives on a Mac. The difference between the two is the type of keys they contain: the Profile on the Portal houses all the public keys associated with your certificates, while the copy on your the Mac contains all the private keys. For the certificates to be valid, the key pairs must match. Keep a backup of the Developer Profile on from the Xamarin Build Host's Mac, because if the private keys are lost, all the certificates and provisioning profiles will need to be regenerated.

🚫

Note: Losing the certificate and associated keys can be incredibly disruptive, as it will require revoking existing certificates and re-provisioning any associated devices, including those registered for ad-hoc deployment. After successfully setting up Development Certificates, export a backup copy and store them in a safe place. For more information on how to do this, refer to the Exporting and Importing Certificates and Profiles section of the Maintaining Certificates guide in Apple's docs.

Provisioning an iOS Device for Development

Now that you’ve established your identity with Apple and have a development certificate, you must set up a provisioning profile and the required entities so it is possible to deploy an app to an Apple device. The device must be running a version of iOS that is supported by Xcode — it may be necessary to update the device, Xcode or both.

Add a Device

When creating a provisioning profile for development, we must state which devices can run the application. To enable this, up to 100 devices per calendar year can be added to our Developer Portal, and from here we can select the devices to be added to a particular provisioning profile. Follow the steps below to add a device to the Developer Portal

The following step will need to be done on the Mac:

  1. Start Xcode.
  2. Connect the device to be provisioned to the Mac with its supplied USB cable.
  3. From the Windows menu select Devices:

  4. Select the desired iOS device from the DEVICES list on the left side of the Devices Window.

  5. Highlight the Identifier string and copy it to the clipboard:

  6. In Safari, navigate to the Apple Developer Center and log in.

  7. Click the Certificates, Identifiers & Profiles link:

  8. Click on the Devices link:

  9. Click the + button:

  10. Provide a name for the new device and paste the device Identifier that we copied above into the UUID field:

  11. Click the Continue button.

  12. Finally, review the information and click the Register button:

Repeat the above steps for any iOS device that will be used to test or debug a Xamarin.iOS application.

After adding the device to the developer portal, it is necessary to create a provisioning profile and add the device to it.

Creating a Development Provisioning Profile

As with the Development Certificate, Provisioning Profiles can be manually created through the Certificates, Identifiers & Profiles section of Apple's Members Center.

Before creating a provisioning profile, an App ID must be made. An App ID is a reverse-DNS style string that uniquely identifies an application. The steps below will demonstrate how to create a Wildcard App ID, which can be used to build and install most applications. Explicit App IDs only allow the installation of one application (with the matching bundle ID), and are generally used for certain iOS features such as Apple Pay and HealthKit. For information on creating Explicit App IDs, refer to the Working with Capabilities guide.

App ID

  1. In the developer portal browse to the Certificate, Identifiers and Profiles section in the Apple Developer Center. Select App IDs under Identifiers.
  2. Click the + button and provide a Name:

  3. The App prefix should be preset. Select Wildcard App ID for the app suffix. Enter a Bundle ID in the format com.[DomainName].*:

  4. Click the Continue button and following the on screen instructions to create the new App ID.

Provisioning Profile

Once the App ID has been created, the Provisioning Profile can be produced. This Provisioning Profile contains information on what app (or apps, if it's a wildcard app ID) this profile relates to, who can use the profile (depending on what developer certificates are added), and what devices can install the app.

To manually create a provisioning profile for development, do this:

  1. Use Safari to browse to the Apple Developers Member Center, and under the section Certificates, Identifiers & Profiles select Provisioning Profiles.
  2. Click the + button, in the top right corner to create a new profile.
  3. From the Development section, select the radio button next to iOS App Development, and press Continue:

  4. From the dropdown menu, select the App ID that to use:

  5. Select the Certificate(s) to include in the provisioning profile, and press Continue:

  6. Select all the devices that the app will be installed on.

  7. Provide the Provisioning Profile with an identifiable a name, and press Continue to create the profile:

  8. Press Download to download the provisioning profile onto a Mac:

  9. Double-click on the file to install the provisioning profile in Xcode. Note that Xcode might not show any visual clues that it has installed the profile except for opening. This can be verified by browsing to Xcode > Preferences > Accounts. Select your Apple ID and click View Details.... Your new provisioning profile should be listed, as illustrated below:

After the provisioning profile has been successfully created it may be necessary to refresh Xcode so that all the development certificates are available to Visual Studio for Mac and Visual Studio.

Downloading Profiles and Certificates in Xcode

Certificates and provisioning profiles that have been created in the Apple Developer Portal, may not automatically appear in Xcode. Therefore, it may be necessary to download them so they that they can be accessed by Visual Studio for Mac and Visual Studio. To update and download any certificates created in the Apple Developer portal, do the following:

  1. Quit Visual Studio for Mac or Visual Studio.
  2. Start Xcode.
  3. Choose Xcode Menu > Preferences...
  4. Click the Accounts tab.
  5. Select a team and click the Download all Profiles button:

  6. Quit Xcode.

  7. Start Visual Studio for Mac or Visual Studio.

The new certificates or provisioning profiles will be available in Visual Studio for Mac or Visual Studio and ready to use.

⚠️

Note: It is sometime necessary to stop and restart Visual Studio for Mac before it will see any new or modified certificates or profiles updated by Xcode.

⚠️

Note: It is sometime necessary to stop and restart Visual Studio before it will see any new or modified certificates or profiles updated by Xcode.

Provisioning for Application Services

Apple provides a selection of special Application Services, also called capabilities, that can be activated for a Xamarin.iOS application. These Application Services must be configured on both the iOS Provisioning Portal when the App ID is created and in the Entitlements.plist file that is part of the Xamarin.iOS application's project. For information on adding Application Services to your app, refer to the Introduction to Capabilities guide and the Working with Entitlements guide.

  • Create an App ID with the required app services.
  • Create a new provisioning profile that contains this App ID.
  • Set Entitlements in the Xamarin.iOS Project

Deploying to a Device

At this point provisioning should be complete, and the app is ready to be deployed to the device. To do this, follow the steps below:

Make sure to set the Team selector to None under Project Options > iOS Bundle Signing.

  1. Plug the device in to a Mac.
  2. In the project's Info.plist, make sure the Bundle Identifier matches the App ID (unless the App ID is a wildcard):

  3. Right-click on the project to view the Project Options dialog and browse to Build > iOS Bundle Signing. From the drop-down list next to both the Signing Identity and Provisioning Profile, verify that Visual Studio for Mac can see the correct profiles, and select a specific identity & profile:

    If this is set to Automatic, Visual Studio for Mac will select the identity and profile based on the Bundle ID that was set in step #2.

  4. Make sure to set the build configuration to iPhone / iPad, rather the simulator.

  5. Click Run in Visual Studio for Mac and view the app running on the device.
  1. Plug the device in to a Mac.
  2. In the project's Info.plist, make sure the Bundle Identifier matches the App ID:

  3. Right-click on the project to view the Project Options dialog, and browse to Build > iOS Bundle Signing. From the drop-down list next to both the Signing Identity and Provisioning Profile verify that Visual Studio can see the correct profiles, and select a specific identity & profile.

    If this is set to Automatic, Visual Studio will select the identity and profile based on the Bundle ID that was set in step #2.

  4. Make sure to set the build configuration to iPhone or iPad, rather the simulator.

  5. Click Run in Visual Studio and view the app running on the device.

Summary

This guide covered the steps required to setup the development environment for Xamarin.iOS. It explored how an application is code signed with information about the developer, their team, the devices that an app can run on, and individual app id.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.