|
| 1 | +--- |
| 2 | +title: Create an iOS app |
| 3 | +description: Steps to create an Azure Maps account and the first iOS App. |
| 4 | +author: deniseatmicrosoft |
| 5 | +ms.author: v-dbogomolov |
| 6 | +ms.date: 09/30/2021 |
| 7 | +ms.topic: conceptual |
| 8 | +ms.service: azure-maps |
| 9 | +services: azure-maps |
| 10 | +--- |
| 11 | +# Create an iOS app (Public Preview) |
| 12 | + |
| 13 | +This article shows you how to add the Azure Maps to an iOS app. It walks you through these basic steps: |
| 14 | + |
| 15 | +* Setup your development environment. |
| 16 | +* Create your own Azure Maps account. |
| 17 | +* Get your primary Azure Maps key to use in the app. |
| 18 | +* Reference the Azure Maps libraries from the project. |
| 19 | +* Add an Azure Maps control to the app. |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +* Create an Azure Maps account by signing into the [Azure portal](https://portal.azure.com/) . If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/) before you begin. |
| 24 | +* [Make an Azure Maps account](https://docs.microsoft.com//azure/azure-maps/quick-demo-map-app#create-an-azure-maps-account) |
| 25 | +* [Obtain a primary subscription key](https://docs.microsoft.com/azure/azure-maps/quick-demo-map-app#get-the-primary-key-for-your-account) , also known as the primary key or the subscription key. For more information on authentication in Azure Maps, see [manage authentication in Azure Maps](https://docs.microsoft.com//azure/azure-maps/how-to-manage-authentication) . |
| 26 | +* Download [Xcode on the Mac App Store](https://apps.apple.com/cz/app/xcode/id497799835?mt=12) for free. |
| 27 | + |
| 28 | +## Create an Azure Maps account |
| 29 | + |
| 30 | +Create a new Azure Maps account with the following steps: |
| 31 | + |
| 32 | +1. In the upper left-hand corner of the [Azure portal](https://portal.azure.com/) , click **Create a resource**. |
| 33 | +2. In the _Search the Marketplace_ box, type **Azure Maps**. |
| 34 | +3. From the _Results_, select **Azure Maps**. Click **Create** button that appears below the map. |
| 35 | +4. On the **Create Maps Account** page, enter the following values: |
| 36 | + * The _Subscription_ that you want to use for this account. |
| 37 | + * The _Resource group_ name for this account. You may choose to _Create new_ or _Use existing_ resource group. |
| 38 | + * The _Name_ of your new account. |
| 39 | + * The _Pricing tier_ for this account. |
| 40 | + * Read the _License_ and _Privacy Statement_, and check the checkbox to accept the terms. |
| 41 | + * Click the **Create** button. |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +## Get the primary key for your account |
| 46 | + |
| 47 | +Once your Maps account is successfully created, retrieve the primary key that enables you to query the Maps APIs. |
| 48 | + |
| 49 | +1. Open your Maps account in the portal. |
| 50 | +2. In the settings section, select **Authentication**. |
| 51 | +3. Copy the **Primary Key** to your clipboard. Save it locally to use later in this tutorial. |
| 52 | + |
| 53 | +> [!Note] |
| 54 | +> If you use the Azure subscription key instead of the Azure Maps primary key, your map won't render properly. Also, for security purposes, it is recommended that you rotate between your primary and secondary keys. To rotate keys, update your app to use the secondary key, deploy, then press the cycle/refresh button beside the primary key to generate a new primary key. The old primary key will be disabled. For more information on key rotation, see [Set up Azure Key Vault with key rotation and auditing](https://docs.microsoft.com/azure/key-vault/secrets/tutorial-rotation-dual) |
| 55 | +
|
| 56 | + |
| 57 | + |
| 58 | +## Create a project in Xcode |
| 59 | + |
| 60 | +First, create a new iOS App project. Complete these steps to create an Xcode project: |
| 61 | + |
| 62 | +1. Under **File**, select **New** -> **Project**. |
| 63 | +2. On the **iOS** tab, select **App**, and then select **Next**. |
| 64 | +3. Enter app name, bundle ID and select **Next**. |
| 65 | + |
| 66 | +See the [Creating an Xcode Project for an App](https://developer.apple.com/documentation/xcode/creating-an-xcode-project-for-an-app) for more help with creating a new project. |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +## Install the Azure Maps iOS SDK |
| 71 | + |
| 72 | +The next step in building your application is to install the Azure Maps iOS SDK. Complete these steps to install the SDK: |
| 73 | + |
| 74 | +1. In **Project navigator** select project file |
| 75 | +2. In opened **Project Editor** select project |
| 76 | +3. Switch to **Swift Package** tab |
| 77 | +4. Add Azure Maps iOS SDK: `{link goes here}` |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +## Add MapControl view |
| 82 | + |
| 83 | +1. Add custom `UIView` to view controller |
| 84 | +2. Select `MapControl` class from `AzureMapsControl` module |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | +3. In the **AppDelegate.swift** file you'll need to: |
| 89 | + * add import for the Azure Maps SDK |
| 90 | + * set your Azure Maps authentication information |
| 91 | +Setting the authentication information on the AzureMaps class globally using the `AzureMaps.configure(subscriptionKey:)` or `AzureMaps.configure(aadClient:aadAppId:aadTenant:)` methods makes it so you won't have to add your authentication information on every view. |
| 92 | + |
| 93 | +4. Select the run button, as shown in the following graphic (or press `CMD` + `R`), to build your application. |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +Xcode will take a few seconds to build the application. After the build is complete, you can test your application in the simulated iOS device. You should see a map like this one: |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +## Clean up resources |
| 102 | + |
| 103 | +> [!WARNING] |
| 104 | +> The tutorials listed in the [Next Steps](#next-steps) section detail how to use and configure Azure Maps with your account. Don't clean up the resources created in this quickstart if you plan to continue to the tutorials. |
| 105 | +
|
| 106 | +If you don't plan to continue to the tutorials, take these steps to clean up the resources: |
| 107 | + |
| 108 | +1. Close Xcode and delete the project you created. |
| 109 | +2. If you tested the application on an external device, uninstall the application from that device. |
| 110 | + |
| 111 | +If you don't plan on continuing to develop with the Azure Maps iOS SDK: |
| 112 | + |
| 113 | +1. Navigate to the Azure portal page. Select **All resources** from the main portal page. Or, click on the menu icon in the upper left-hand corner. Select **All resources**. |
| 114 | +2. Click on your Azure Maps account. At the top of the page, click **Delete**. |
| 115 | +3. Optionally, if you don't plan to continue developing iOS apps, uninstall Xcode. |
| 116 | + |
| 117 | +<!-- |
| 118 | +For more code examples, see these guides: |
| 119 | +
|
| 120 | +* [Manage authentication in Azure Maps](https://docs.microsoft.com/azure/azure-maps/how-to-manage-authentication) |
| 121 | +* [Change map styles in iOS maps](Set%20map%20style%20%28iOS%20SDK%29.md) |
| 122 | +* [Add a symbol layer](Add%20a%20symbol%20layer%20%28iOS%20SDK%29.md) |
| 123 | +* [Add a line layer](Add%20a%20line%20layer%20to%20the%20map%20%28iOS%20SDK%29.md) |
| 124 | +* [Add a polygon layer](Add%20a%20polygon%20layer%20to%20the%20map%20%28iOS%20SDK%29.md) |
| 125 | +--> |
| 126 | + |
| 127 | +## Next steps |
| 128 | + |
| 129 | +In this quickstart, you created your Azure Maps account and created a demo application. Take a look at the following tutorials to learn more about Azure Maps: |
| 130 | +In this quickstart, you created your Azure Maps account and created a demo application. Take a look at the following tutorials to learn more about Azure Maps: |
| 131 | + |
| 132 | +> [!div class="nextstepaction"] |
| 133 | +> [Load GeoJSON data into Azure Maps](tutorial-load-geojson-file-android.md) |
| 134 | +
|
0 commit comments