Time for action – Publishing to our device

To publish to our device we will have to provide a bundle identifier for Unity. To create one we will have to provide one within the iOS Provisioning Portal. This portal is located within the iOS Dev Center accessible at http://developer.apple.com.

On the main page for the iOS developer program you will find a link that will take you to the iOS Provisioning Portal. In addition, you will see links to the iTunes Connect portal that is used for publishing your product and getting information about sales and market performance:

Time for action – Publishing to our device
  1. In the iOS Provisioning Portal you will select the App IDs setting so that you can create a new application ID (which is the same as the bundle identifier which Unity is looking for):
    Time for action – Publishing to our device

    Let's take a look at how we create App IDs for our applications:

    Time for action – Publishing to our device

    An App ID for an iOS application is very important, as it is the mechanism through which the application will be uniquely identified by Game Center, in App Purchases, Push Notifications, and inside of the Unity development environment:

    Time for action – Publishing to our device

    An application identifier has a description, a prefix and a suffix. The prefix is a collection of characters that are randomized for uniqueness, and the suffix represents the unique identifier for the application. When Unity refers to the Bundle Identifier, it is referring only to the suffix.

    Create your App ID with a clear description of what this application is so that it will be easy to find it later. This is important, as over time you will end up with a large number of App IDs for all the games you will be creating. For the Seed ID itself, simply leave that set to Generate New.

    For your Bundle Identifier , use the standard reverse-domain name notation to come up with the identifier for your app. Once this is created we just need a way to move this over to our development environment.

    Note

    For the bundle identifier make sure that you do not append a wildcard character to the end as this will limit you later as you seek to add more advanced functionality.

  2. We now need to associate this application ID with a provisioning profile. If you already have a provisioning profile, you can modify the one you already have and change the App ID that it represents. If you don't have one, or don't want to modify an existing one, enter the Provisioning section of the iOS Provisioning Portal:
    Time for action – Publishing to our device
  3. Once there, create a new profile for this App ID and fill in all of the fields, making sure to select the appropriate App ID in the drop-down list box:
    Time for action – Publishing to our device

    Tip

    You may not have noticed it, but this example illustrates what happens when you follow the bad practice of not coming up with very descriptive names for your App IDs. While in this case I know that I want Chapter 1, if I were developing several books – I would not be able to identify which Chapter 1 this App ID represented.

    Notice that I have selected all of the devices that I want this application to be provisioned for. If you don't select a device here, you won't be able to deploy the application to that device.

  4. Your provisioning profile is created, you now need to press Download so that it will be downloaded to your development environment:
    Time for action – Publishing to our device
  5. Once downloaded (you should have a .mobileprovision file), double-click on the file on your machine. As this is a registered file type for XCode it should install it into XCode for you.

    If for some reason it doesn't, you can open up the Organizer in XCode (Window | Organizer), select the Provisioning Profiles entry in the organizer. XCode will then install the profile and it will be synchronized to all devices that can accept the profile:

    Time for action – Publishing to our device

    XCode has the ability to automatically provision devices that are configured in the iOS developer portal within XCode. This makes it easy to ensure that your profiles are added to your target devices. To do this, ensure that the Automatic Device Provisioning checkbox is checked:

    Time for action – Publishing to our device

    Once performed, XCode will communicate with the iOS developer portal and download all of your configured devices and display them in the Organizer:

    Time for action – Publishing to our device
  6. We are now able to configure Unity to publish content for this application ID on our target device. We accomplish this by entering the Bundle Identifier and setting the App ID suffix for our application. In the case of our example, it would be com.gregorypierce.chapter1:
    Time for action – Publishing to our device

    With that step completed, the hardest part of building games for Unity is over!

  7. Run this application by selecting the Build and Run option from the File menu (File | Build and Run). This time when you select "Build and Run," Unity will build a player for your content and deploy the application to the iOS device connected to the machine.

    Don't be alarmed when you see XCode open and start building your application, as this means that the process is working and very shortly you should see the sample application start on your device.

What just happened?

What Unity is doing behind the scenes is taking all of the assets and scripts from the Unity IDE and putting together a player that will be able to playback the content and all of its scenarios based on input from the user. This is a very important concept to understand as the content within the Unity IDE is largely platform agnostic and can be readily redeployed after a simple recompile within the Unity environment. This player is what becomes the actual application that is deployed to the iOS device.

We spent a large number of steps creating some artifacts within the iOS Developer Portal. These artifacts were: the certificate, the App ID, and the provisioning profile. These artifacts form a circle of trust between the developer, Apple, and the iOS devices in the hands of developers and consumers.

The certificate is a credential that is created in the Apple environment that allows content to be signed specifically by the developer, so that it is clear who authored the content. Without a certificate it is possible that someone could claim to be the developer and sign applications on his/her behalf.

The App ID is a unique identifier that allows the iOS device and the Apple services to know, without ambiguity, which application is trying to do something. Finally, the provisioning profile defines.

The provisioning profile associates the certificates, devices, and an app ID. Without a provisioning profile on your machine you will not be able to sign or deploy applications to either a device or to the application store.

Once we provided Unity the App ID, it was able to communicate with XCode and tell XCode which profile and certificates should be used to sign our application and deploy it the iOS device. On the device itself, when XCode deployed the application it transferred the provisioning profile to the device, so that the iOS device could identify that this was a device that it should run, even though the Apple App Store did not provide it.

We have just performed all of the steps necessary to setup our development environment and publish content to Unity. Further, we have built our own mini testing lab using Unity Remote so we can utilize our device yet debug the game in our development environment. This is a crucial milestone as we can now focus entirely on customizing Unity and building games.

Pop quiz – The fundamentals

  1. Which of these platforms can Unity not publish content for?
    1. Web
    2. Consoles
    3. iOS Devices
    4. Android Devices
    5. Linux
  2. Where can you go to set up an application ID for your iOS device?
    1. Apple Developer Forums
    2. XCode Organizer
    3. iTunes Connect
    4. iOS Provisioning Portal
    5. XCode SDK
  3. There remains uncertainty about whether or not Unity developed applications can be published to iOS devices within Apple's Terms of Service? (true/false)
  4. If you have the following App ID 255U952NTW.com.gregorypierce.chapter1, what should you provide to Unity as your Bundle Identifier?
    1. Chapter1
    2. com.gregorypierce.chapter1
    3. 255U952NTW
    4. 255U952NTW.com.gregorypierce.chapter1
    5. 255U952NTW.com.gregorypierce.chapter1.*
  5. You can publish an iOS application without creating a developer account? (true/false)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.77.195