Rob: Good afternoon. Welcome to Session number 414, Building, Archiving, and Submitting Your App. Youâ€™ve probably spent most of this week learning how to take advantage of the great new features in iOS 6 and Mountain Lion while developing your application. We thought that this afternoon we would do something completely different and talk about distribution, how you can get your software product into your customerâ€™s hands.
Since I realize that I am all that stands between you and free food, weâ€™re going to keep it to three things. Distributing your application outside of the app store using a new technology called Developer ID. Then weâ€™re going to talk about how you can take your application and distribute it in the app store, taking advantage of all the features and technologies available to both you and your customers. Then weâ€™ll talk about some best practices on iOS, as well as some new features that are available in the app store this year in iOS 6.
Letâ€™s get started by talking about how to distribute your application outside the app store. The app store offers you the opportunity to take advantage of a number of incredible technologies that exist on our platforms. One of them is security. We donâ€™t think that should be something that you can only take advantage of in the app store. To that end, weâ€™ve introduced a new technology called Gatekeeper.
Customers of the app store have the advantage of knowing that the software that they receive from the app store comes directly from you. With Gatekeeper and Developer ID, they can do the same with your software that comes from outside the app store.
Gatekeeper is turned on by default in Mountain Lion and itâ€™s designed to protect your users from malicious applications. This sounds a little scary but in reality, this is actually a problem. Anyone with access to your web server can modify an application that you created and do whatever they want on your userâ€™s systems and thatâ€™s bad.
Gatekeeper allows you to make sure that the application your customer is running is exactly what you intended it to be. By default, Gatekeeper allows you to run applications that were obtained either from the Mac app store or they were signed with a Developer ID. If neither of those is true, your customer will see something like this. How do you make sure your customer doesnâ€™t see something like this? You take advantage of what weâ€™ve been talking about, Developer ID. What is it?
A Developer ID identifies you as being someone whoâ€™s trusted by Apple. By virtue of the fact that youâ€™re trusted by Apple, the OS trusts you and your software can run freely. Unlike other technologies and for distribution it has built-in support in Xcode so you can share your application with your customers right from the IDA.
Now weâ€™re going to talk about how to take advantage of this when youâ€™re ready to distribute your app, starting with how to obtain a Developer ID. If you previously had experienced distributing your software through app stores, this will be something thatâ€™s similar but weâ€™re going to run through it now in case you havenâ€™t.
From the organizer, you can choose this option from the editor menu which is to refresh from the developer portal. Once you do that, Xcode will communicate with the developer portal, figure out all the assets that youâ€™re entitled to based on what teams youâ€™re a member of, and ask you if you want to download them.
Naturally weâ€™ll say yes. Once you do, itâ€™ll ask if you want to export them. This is something thatâ€™s actually very important because your Developer ID is like your social security number. Anyone who has it can pretend to be you and if you donâ€™t have it, you canâ€™t prove that you are you. Itâ€™s important to make sure you have a copy of it somewhere thatâ€™s kept safe and secure.
As an added convenience if you want to set up a second Mac for development, your exported developer identity and profile is a single document that you can open inside of Xcode and get up and running. No need to go to keychain access. No need to download things from the portal. You can just double-click it and go.
Once youâ€™ve got that, you can take a look at what youâ€™ve actually obtained. These are the identities that are associated with your team. They come in, for Mac developers, two categories, those that begin with Mac which you would use for your Mac app store submissions, and those that begin with Developer ID which is what Iâ€™m going to talk about right now.
There are two flavors: Developer ID application, this is an identity that you use to sign your data .apps, either that you distribute in an archive or on a disc image; and then Developer ID installer which is what you use to sign the installer thatâ€™s used to give your customers their .apps.
Itâ€™s important to realize this because installers are actually executable code so thereâ€™s a possibility for tampering there. Itâ€™s important to make sure that thatâ€™s signed. Once you have these, itâ€™s often useful to take advantage of them while developing your application. Itâ€™s useful to test what your customers are actually going to receive by code signing your application during development and working with and under the bugger.
Similarly, code signed applications are treated differently by the OS in a few circumstances like when they actually are launched. Itâ€™s often useful to profile your application as if it was code signed.
To actually produce this, what you can do is go to your project editor and the summary panel offers you the option to code sign the application. Checking this box will cause the Xcode to automatically select the appropriate identity for your application. Usually this is correct. However, if youâ€™re in a bunch of teams or youâ€™re doing something special you can actually override this yourself inside of the build settings editor just by going to the code signing identity build setting and choosing a different one.
When youâ€™re ready to distribute your application, you can produce something called an archive from within Xcode. This is a really fundamental and powerful feature that we introduce with Xcode 4. It lets you package up your application, its symbols, and some information that Xcode knows how to read into a single bundle that the organizer can deal with. From that archive, youâ€™re ready to distribute it, submit it to the stores, validate it to make sure itâ€™s ready to go to the stores. These are all things weâ€™ll talk about later but you can do them all from an archive from within the organizer.
Once weâ€™ve created one of these archives which weâ€™re going to show you how to do in a minute, you can chose to distribute it. To distribute it in this case weâ€™re going to choose to distribute it as a Developer ID signed application. Once we do, weâ€™re prompted to save it some place on the file system and then we can distribute it to our customers however we chose.
Thatâ€™s one security feature thatâ€™s available to customers of the Mac app store. As I said earlier, we donâ€™t want those to be features that are unique to the store. To talk about two other features related to security present in the Mac app store that are available to your Developer ID signed applications, Iâ€™d like to introduce up Yevgeny.
Yevgeny: Good afternoon. As Mac and iOS users, we love to brag that our platforms are really secure. As developers, we really want to make sure that our products donâ€™t contain any security vulnerabilities on these platforms. A really good way to do that is to take advantage of a technology that we have called application sandboxing.
The word sandbox is actually really appropriate here because it means that your app has the freedom to do what it wants in its own little space but itâ€™s walled off from doing anything malicious or damaging to the system in case it misbehaves.
When you launch an app with sandboxing enabled, the security framework prevents it from doing a few things. You canâ€™t access the file system outside of your own sandbox directory. You canâ€™t connect to or host any network servers. You canâ€™t access devices such as the camera, microphone, USB devices, or printers. You canâ€™t access the userâ€™s personal data like contacts, calendars, and location services.
What this means is that itâ€™s a great benefit to our users because even if a bug is found at some point in your software that creates an exploitable vulnerability, then the potential for damage is limited to just the files that are created by the user in your app.
Xcode makes it simple for you to take advantage of app sandboxing. All you have to do is go into your appâ€™s target editor, click in the summary pane, and enable entitlements. Then click enable app sandboxing. Of course, as soon as you do that, youâ€™re soon likely to run into the situation where you want to do something that sandboxing wonâ€™t let you do. Letâ€™s say you want to use the microphone or the camera.
Fortunately, sandboxing isnâ€™t an all-or-nothing proposition. You can take advantage of something called entitlements to allow fine-grained access to system resources. An entitlement is just a permission to use a resource in a system like the microphone or location services. In this way, you can take advantage of the principle of least privilege meaning that your app only has permission what it needs to do in order to get its job done and itâ€™s not allowed to touch anything else.
You can take advantage of entitlements in Xcode just as easily by going back to the target editor. When you enable sandboxing, youâ€™ll notice that there are checkboxes and dropdowns to select which entitlements your app wants to use. Once you make those changes, then Xcode will create a property list file called the entitlements file. Itâ€™ll populate it with those cues and then package it into your app bundle. Then when the app is launched, the security framework will read it and grant your app access to those entitlements. Thatâ€™s how easy it is to add a whole layer of security into your app.
Now, how do we create an app thatâ€™s signed by Developer ID? There are four steps to this. The first is to actually obtain the Developer ID from Apple. Once you have it, you want to configure your project to use code signing. Then enable sandboxing and entitlements in your app and finally, build and distribute it.
Letâ€™s actually see this in action. Iâ€™d like to show you a demo of how we can sign an app with Developer ID. Letâ€™s say weâ€™ve already got an app thatâ€™s prebuilt. My app happens to be a recipe viewer. I want to open the app and take a quick look at it. Weâ€™ll go ahead and run it. There it is.
On my left here Iâ€™ve got a side bar with all of my recipes. I can click through them and I can take a look. I can see the description for how to make it, and Iâ€™ve got a nice image of how the food is supposed to turn out if I make it properly. This app looks great to me. I want to package it up and I want to ship it to developers. Right away, there are already a couple of problems with this.
If I take the app that Xcode just built, I put it on a website and have people download it, then anybody can download it and modify. They could tamper with it. They could inject malicious code into it and then redistribute it to unsuspecting users. Whatâ€™s worse is that the users wonâ€™t know what happened. They wonâ€™t know theyâ€™re even running this malware.
At best, theyâ€™ll get a panel on Lion and in older systems that says â€œThis app has been downloaded from the internet. Are you sure you want to launch it?â€ Most users will end up clicking â€œYes.â€ On Mountain Lion, weâ€™ve gotten more strict with Gatekeeper. Your second problem is that by default, if a user tries to launch an app on Mountain Lion, the system just wonâ€™t let it run. Itâ€™ll deny it. Itâ€™ll pop up a panel that Rob showed you.
Thatâ€™s great news from a security standpoint but itâ€™s not so great from usability standpoint. Whatâ€™s the solution? Well, you just have to use Developer IDs on your app. I want to show you how to use Developer ID right now. Letâ€™s close up our app.
The first step is going to be to request the ID from Apple. You do that from the organizer. In the devices tab, click on provisioning profiles. Now if youâ€™ve already made a developer account, thatâ€™s great. You need to have one to use this. If not, go and sign up for a developer account. Letâ€™s say youâ€™ve already got one.
Now what you can do is go to the editor menu and click refresh from developer portal. You sign in. Save your password. Then Xcode will connect to the portal and check for which developer identities youâ€™re eligible. If it finds that there are certain identities that you havenâ€™t yet downloaded Xcode will offer to download and install them for you and thatâ€™s what itâ€™s doing here right now.
There are a few different kinds of developer identities. Xcode will ask me once for each kind. These include the Developer ID application and installer, identities that Rob mentioned earlier, as well as Mac app store submission, installer, and development identities that weâ€™re going to talk about later.
Xcode here is asking me once for each type of identity. Iâ€™m just going to go ahead and say yes. Submit the request. Once thatâ€™s done, Xcode is being really helpful here and offering to export my developer profile. The developer profile is a way to package up all of your provisioning profiles and development identities and private keys into one file. The reason you want to that is so that you can back it all up into a secure location.
Itâ€™s really important that you hang on to these credentials and donâ€™t let anybody else have them because if you lose them, itâ€™ll be really painful for you. Youâ€™re going to have to start up a new Developer ID. You wonâ€™t have access to your old one. You wonâ€™t be able to your old one. You wonâ€™t be able to submit new apps under it. Itâ€™ll be painful for both you and your customers.
We really want to stress that you should export your profile and keep it safe and secure. Iâ€™m going to do this now. Iâ€™d give it a nice name, save it to my desktop, and give it a password. Again, make sure that the password is secure because if anybody gets access to your profile, they can have your identity which means they can do anything in the app store that you can and thatâ€™s bad. Hereâ€™s itâ€™s saved on my desktop.
If you ever want to do this again in the future, you can go ahead in the organizer. In the sidebar, click on your team. Go to the editor menu. Under developer profile, choose export developer profile. As long as weâ€™re here, I want to point out a couple of things that youâ€™re seeing. When you click on your team in the organizer, itâ€™ll show you a list of all the identities which youâ€™ve downloaded from this team.
Notice that only one of these identities has my name on it. Thatâ€™s because this is the only identity thatâ€™s tied to me personally. The other identities are shared by the team at large. Also notice that there is a green check mark or badge next to each identity. That means that this identity is valid and you can use it to code sign. If you ever encounter a situation where thatâ€™s not the case, where there is no badge, it means there is no private key installed and that identity canâ€™t be used to code sign.
Some of you might have this situation where none of your identities have a badge. This usually happens when you have a couple of machines that youâ€™re developing on. Youâ€™ll start a project on one machine. Youâ€™ll submit your code to a repository, download your Developer ID, and submit apps. No problem. As soon as you take that code and download it to another machine, you could forget to move your private key onto it. Then for some reason youâ€™ll find that youâ€™re unable to sign. Well, Iâ€™m telling you now that thatâ€™s because you probably just forgot your private key and so go ahead and put it on your other machine.
Anyway, letâ€™s get back to our app. We now have our Developer ID. Itâ€™s been downloaded. We could, if we wanted to, sign the app with it and distribute it. If we did that, weâ€™d be releasing a product thatâ€™s not been tested. Itâ€™s a different product than weâ€™ve been developing because a Developer ID will sign your app. Itâ€™ll code sign your binary whereas by default, your development binary will not be code signed. To the system, these appear different. When youâ€™re testing, debugging, and developing, you really want to be running the same thing youâ€™re going to be shipping. We suggest that you enable code signing while youâ€™re developing.
You can do that in the next code by going to your target editor summary pane and clicking on code sign application. Now I want you to take a moment and ask yourself â€œWell, why do I want to use a Developer ID in the first place?â€ The answer is you want to create a product thatâ€™s secure and that gives your users confidence that youâ€™re protecting their data.
More and more everyday weâ€™re seeing users being more concerned about security. They expect that developers will be taking these concerns very seriously, that they are protecting their date a hundred percent of the time. As I mentioned, sandboxing is a great way to add a whole layer to add security to your app. We strongly encourage all of you to enable it. Iâ€™ll show you how thatâ€™s done.
Back in your target editor, enable entitlements. When you do that, Xcode will helpfully enable sandboxing as well. Also notice that the entitlements file has been created for us in the project navigator. I can click on it and examine its contents. Here I see itâ€™s just an ordinary property list. Itâ€™s got the key for sandboxing already in there. I go back to my target editor. I notice that there are all these options for entitlements.
Letâ€™s say that I want to add a couple of features to my app where I use the camera for example to take photos of my great recipes after I finish cooking them. I also want to enable printing so that I can give a copy of my recipe to my grandmother who refuses to get internet access. I can do that by clicking the appropriate check boxes. Now the app is ready to be shipped. Itâ€™s got the security layer of sandboxing. Itâ€™s got the appropriate entitlements. Weâ€™ve tested it with code signing. Now itâ€™s totally ready to be shipped.
Finally letâ€™s distribute it with the Developer ID. We do that by going to the product menu and choosing archive. The app will compile and build. Itâ€™ll appear in my organizer. I can now click distribute. Iâ€™ll choose export Developer ID signed application.
On the next page, Iâ€™ll choose the Developer ID that Iâ€™m using for my team. If it doesnâ€™t appear here, just click refresh Developer ID. Finally, on the next page, Iâ€™ll be able to save it. Before I save it, Xcode actually needs to code sign my binary with the private key that Iâ€™m using. Since itâ€™s the first time that Iâ€™m using this key, the key chain is going to ask me to confirm that I really want to use it. Iâ€™m going to go ahead and allow Xcode to use it.
We save the app to our desktop. There it is. Itâ€™s ready to go. Itâ€™s fully signed and fully authenticated. People can go and download it and feel really safe and secure. Thatâ€™s how easy it is to distribute an app using Developer ID.
Now Iâ€™d like to invite my colleague Rob back to talk about how to distribute an people using the Mac app store.
Rob: Thatâ€™s how to distribute an application outside of the App Store. Like I said earlier there are tons of great features that you can take advantage of and provide to your customers if your application is in the store. Things like iCloud, Apple Push Notification Service for responding to things happening while your application is running, and Game Center so that if you have a game your customers can actually play with their friends regardless of where they are, and in that purchase if you like to provide additional content in your application to your customers.
Submitting to the app store is a process thatâ€™s well integrated in Xcode and used by thousands of developers everyday. While Gatekeeper works out of the box for applications distributed through the app store were signed with Developer ID, users of the OS can actually tighten the security threshold and say, â€œI only want applications that are coming from the Mac app store.â€ Distributing here is the way to guarantee that your software will run on all of your customersâ€™ systems.
We just built an application. What would it take to get it in the App Store? Well, weâ€™re going to talk about three things today: The appâ€™s bundle ID and how it relates to the app ID you set up when creating an application in the portal; sandboxing and some entitlements that we use for app storeâ€™s specific technologies; and how to make sure your application is technically ready and all set up to be submitted to the store.
Letâ€™s start off by talking about your bundle ID. This is represented by your applicationâ€™s Info.plist as the CF bundle identifier key. By convention, itâ€™s something that we wanted unique throughout the system. A lot of our APIs expect that. It should match your app ID that you created in your provisioning profile.
If you have an application that you distribute outside the app store and have turned down sandboxing for it, itâ€™s a really great thing for your customers if you have the same bundle ID for your application that comes from both the app store and from outside the app store. If theyâ€™re buying two copies of your app, this guarantees that they can share data between them.
If we talk about sandboxing, sandboxing is required for distribution through the app store. When we go back and think about the technologies that are available to our customers through the app store, one of them is iCloud. There are some entitlements you can set up for that for using either the key value store or for custom document and data containers.
Submitting your app is something that you want to take seriously. It will be nice to know that youâ€™ve actually set up your project in a way that it will be accepted and appear on the store. Xcode has a workflow to help you make sure that thatâ€™s the case. We call it validation. It makes sure that things like your applicationâ€™s copyright string is set properly that you have a category specified for your app, and things that are essential for being listed on the store as well as enforcing some other policies that are specific to the Mac app store or to the iOS app store.
We actually update these over the web to make sure that they are exactly what you will be tested against once you submit. To do that, once youâ€™ve created an archive, you can actually validate it from right within the organizer. Itâ€™s the button right on top of distribute. You can choose to validate against the Mac app storeâ€™s requirements. Now, if you donâ€™t pass validation, Xcode will tell you about it and you can go and fix up the warning or the error, revalidate, and then submit.
To talk about some of the technologies that are available only in the Mac app store and how you can take advantage of them in your app, Iâ€™d now like to invite up Itai.
Itai: Thanks, Rob. Good afternoon everybody. As Rob mentioned, when you choose to distribute your app on the app store, you get to take advantage of some great technologies, iCloud, Game Center, in-app purchase, and push notifications are services that customers love. If you take advantage of them in your apps, then customers will love your apps even more than they already do. Before I move on, I want to point out that everything Iâ€™ll be talking about is applicable to both the iOS and Mac app stores with a few exceptions that Iâ€™ll point out as I go along.
Here is a brief overview of what Iâ€™ll be talking about. Now when you set down a path of building an app store app, one of the things you should know about is provisioning profiles. Iâ€™ll tell you a little bit about what they are and how to create and use them.
In addition, one of the big new changes in Xcode is the addition of support for in-app purchase content. With the new version of Xcode, you can create, package, and submit in-app purchase content from directly within the ID. If youâ€™ve used in-app purchase before, youâ€™ll find this greatly streamlines your workflow.
A lot of what Iâ€™m going to show you involving provisioning profiles involves performing administrative tasks like creating provisioning profiles, registering devices, and app IDs. Depending on how your team is set up, you may not necessarily have every team member have access to perform these administrative tasks. There are three roles that you can assign to each individual on your team: member, admin, and agent.
Now most of the people on your team will probably be members. This is typically all of the developing engineers or testers on your team. People who are assigned the member role can download provisioning profiles, request certificates, and also obtain software assets like pre-release of the case and beta releases of the tools.
If you think of your team with the file system analogy, team members essentially have read-only access. They can download and use your development assets but they canâ€™t create them themselves. In order to do most of what Iâ€™m going to show you, youâ€™ll have to be an admin. Now, admins can manage your teamâ€™s membership. They create and approve certificates for your team members. They create provisioning profiles and also register hardware and app IDs.
Finally, the team agent is the individual who is the primary contact for your team and theyâ€™re responsible for your teamâ€™s membership in the developing program. Most importantly, theyâ€™re also the only individuals who can submit applications and can generate distribution certificates and distribution provisioning profiles. Now if you stop and think about this for a moment, that makes a lot of sense because any software distributed using these assets reflects on your organizationâ€™s identity and reputation. You want to make sure that only responsible individuals can actually do this.
What is a provisioning profile? Now this is a great topic to talk about just before the beer bash. I take no responsibility if this drives you to over-indulge tonight. Iâ€™m going to try to make provisioning profiles as simple to understand as possible. Theyâ€™re really not that complicated. I like to think of a provisioning profile as a big blue box. Okay. Thatâ€™s it. Letâ€™s move on. Just kidding.
Provisioning profiles contain three things that you need to know about. The first one is an app ID. Now the app ID as Rob mentioned is roughly analogous to a bundle identifier. Iâ€™ll talk about it in a little bit more detail in a couple more slides but right now all you need to know is this is a string that identifies an app developed by your team. They also contain a list of certificates.
Earlier, Yevgeny showed you how to generate certificates in Xcode, and these are essentially the public-facing half of each of your developerâ€™s identities. Each developer also has a private key, which they should keep to themselves and not share with anybody, thatâ€™s why itâ€™s called a private key. The certificate is the public, shareable half of that, and each provisioning profile you create will contain a list of the developerâ€™s inner team, essentially. Finally, a list of device ideas. This is probably the most straightforward one. Every device that your team uses in the development process should be registered on the portal, all of your Macs and iOS devices have hardware IDs, and when you create a provision profile, it specifies a list of these. What do you get once you put all of these in a box?
Essentially, you get a provisioning profile which tells the operating system that an app signed by the following people may run on the following devices. That’s essentially the most basic thing a provisioning profile does. It tells the operating system under which circumstances you’re app can launch. It does do a couple additional things, most importantly, it tells the operating system which services your app should have access to, and things like iCloud, and the way it does that is we have the app ID. Let’s talk about app IDs a little bit. There are two kinds. The first one is called an Explicit App ID, and this is probably the simplest one to understand. It looks just like a bundle identifier. The one you could see on the screen is com.apple.Recipes. Thatâ€™s the bundle identifier for the recipes up that Yevgeny showed you earlier. Thatâ€™s an Explicit app ID.
It matches one specific application developed by our team, and we can create these on the developer portal. We can make as many as we want. Each Explicit app ID needs to be unique, and if youâ€™re going to use In-App Purchase, Game Center, or Push Notifications, you actually have to create one of these on the portal before you could use those. The other kind of app ID is called a Wildcard app ID, and believe it or not, itâ€™s called that because at the end of the screen is the Wildcard character. I’m sure you didnâ€™t see that coming. The example you see on the screen com.apple.* essentially will match any application developed by our team whose bundle identifiers starts with com.apple, so com.apple.Recipes would match. Come.apple.Recipes beta would match, anything like that.
Xcode creates one of these automatically for you. You may not actually need to create one yourself, and these tend to be useful when you start developing new apps. You can get off the ground very quickly without having to configure anything on the developer portal. Also, if youâ€™re not using any App Store-specific technologies, or youâ€™re only using iCloud, then you can probably do all of your development using a Wildcard app ID. Keep that in mind. Okay, letâ€™s say youâ€™ve decided you need to create your own app ID, how do you actually do that? You start by logging into the developer portal, this is actually the version for the Mac, the iOS one is very similar. You choose to register a new app ID, and all you have to do is fill in these two fields.
You type in the description so you remember what this app ID is actually for, and you also type in your bundle ID search string. In this case, com.apple.Recipes. Remember this one because I’m going to actually use this a little bit later. Once youâ€™ve done that, you can enable your app ID for additional services. On the Mac, youâ€™ll see checkboxes for iCloud, Game Center, and Push Notifications. This is one difference from iOS, for iOS, if you want to use In-App Purchase, you actually have to check a fourth box for that on the Mac as long as youâ€™re using an Explicit app ID, you can use an app purchase in your application. In this case, Iâ€™ve enabled iCloud. Thatâ€™s all there is to know about app IDs, really. A few other details about provisioning profiles that you should be aware of are that Xcode creates these team provisioning profiles for you and youâ€™ve probably seen them.
If youâ€™re developing for iOS, thereâ€™s an iOS team provisioning profile. If youâ€™re developing for the Mac, thereâ€™s a Mac team provisioning profile. These are essentially generic profiles that Xcode creates for you. It maintains them for you, and theyâ€™ll automatically contain all of the devices and certificates that your team uses. Theyâ€™ll also use a Wildcard app ID that matches any app developed by your team. Again, you can use these when youâ€™re developing new apps, get off the ground very quickly, and for some apps, this is really all you need. If you need to create a provision profile with an Explicit app ID, you can do that in Xcode, and Iâ€™ll show you how to do that in a little bit, and finally, when itâ€™s time to distribute your app on the app store, you need to use something called a production provisioning profile on the Mac or a distribution provisioning profile on iOS, and again, only your team agent can create and use these.
Changing gears a little bit, In-App Purchase. In the new version of Xcode, weâ€™ve added project templates for both Mac and iOS so that you can create In-App Purchase Content directly in the ID. All you have to do is create a new project or add a target to an existing project, drag in your resources, and you can archive, package, and submit your In-App Purchase Content directly from a thin Xcode, and Iâ€™ll show you how to do that actually. In just a moment, Iâ€™ll head over to the demo machine and show you a few things, including how to enable iCloud, how to create a provisioning profile, and then how to submit an app and In-App Purchase Content to the App Store. Letâ€™s take a look at that.
Here we are looking at the Recipes app that Yevgeny showed you earlier. Now, what you might not know is that this app uses the iCloud key value store. Before I can actually submit this app to the App Store, I need to do a little bit of work in order to enable that. If I look at the Debug Log from last time Yevgeny ran the app, youâ€™ll see, thereâ€™s a somewhat scary-looking error message, but all it really says is that we havenâ€™t enabled iCloud for app and weâ€™re trying to use iCloud. How do we do that? Thereâ€™s a couple steps. Iâ€™ll go back to the target editor and show you the first one.
The first step involves turning on the entitlement within our app, and I can do that simply by checking this iCloud key value store check box in the target editor. Thatâ€™s half of what I need to do and that was pretty easy. Now, the second half actually involves creating a provisioning profile. If youâ€™ll recall, there are three things that you need to have in a provisioning profile. One is an app ID. I already created an app ID, it was the one I showed you in the slides. Thatâ€™s all done, and itâ€™s enabled for iCloud. The second one is a development certificate. Yevgeny created that in his demo so I already have that. The third one is a device ID. I need to register my device on the portal before I can create a profile. Letâ€™s do that.
You can do that within Xcodeâ€™s organizer. Iâ€™ll click on the organizer button here on the corner, click over to the deviceâ€™s tab, and select My Mac in the side bar, and all I have to do to register My Mac on the portal is click this at the portal button on the one with the window. Now My Mac has been registered and I can create a provisioning profile that refers to it, so letâ€™s do that. In order to do that, I can click on the provisioning profileâ€™s item, and click New on the bottom of the window. Now, all I have to do to create a profile is fill out this sheet. Iâ€™ll type in a name, this should be something descriptive so that you know what this profile is used for especially if you need to update your app six or 12 months down the line. Itâ€™s useful to actually know which profile youâ€™re using.
Iâ€™ll click on Mac since this is for a Mac app, and now I need to select Mac ID. Iâ€™ll choose the one I created earlier which is already enabled for iCloud. Next, I need to choose the list of devices and certificates that I want to include in the profile. Now, if youâ€™re in a larger team, of course youâ€™ll see a lot more devices and certificates in this list, and you can select just the ones you want, or you can select all of them. In this case, I’m a one person team with one device, so Iâ€™ll just choose everything and click Finish. Youâ€™ll see that Xcode has created a profile for me on the portal, and download it to my Mac. In order to use this profile, I need to first install it on my Mac, and I can do that simply by dragging it on to my Mac in the sidebar, and now if I click on provisioning profiles under my Mac, youâ€™ll see that itâ€™s installed.
Great, now itâ€™s ready to be used. Letâ€™s go back to my project and configure it to use my profile. The way to do that is we had the code signing identity Build Setting that Rob showed you. Iâ€™ll click on Build Settings for my target, and letâ€™s take a look at the code signing identity build setting. You can see here that the automatic profile selector has actually already chosen the correct identity for me. I want to use my Johnny Appleseed identity and itâ€™s also using my Recipes development profile which I just created, but in case thatâ€™s not choosing the right thing, you can also see further down in the list that Xcode lists all the provisioning profiles that Iâ€™ve installed, and all of the identities that are included in those provisioning profiles, and I can just choose the one that I want to use.
Now I’m ready to build and run my app. An iCloud should be enabled. If I go look at the Debug Log again, youâ€™ll see no scary error message this time, everything is working. Okay, now I’m ready to submit my app to the App Store. Everything looks great so Iâ€™ll start by archiving it just like we did for Developer ID, and the archive will appear in the organizer. As Rob mentioned, one practice that we really recommend you to do is to validate your app before you submit it, and you should do this frequently throughout your development cycle so that you donâ€™t get a nasty surprise when itâ€™s time to submit your app to the App Store.
Letâ€™s start off by validating, and I can do that by clicking the Validate button, selecting Mac App Store, and hitting next. In order to validate, Xcode needs to connect to iTunes Connect and download all of the application records that Iâ€™ve already set up. Iâ€™ll type in my iTunes Connect credentials, hit Next, and now youâ€™ll see that Xcode has downloaded all of my application records. If you donâ€™t see any here, it might mean that you havenâ€™t actually created one yet. You want to go do that, and I can select the code signing identity that I want to sign this with, and hit Next.
Now, Xcode is going to code sign my application, and upload it for validation, and once again, I’m being asked for access because this is the first time I’m using my Mac App Store distribution identity. Since this is an application developed by some great Apple engineers, there shouldnâ€™t be any validation errors, right? But it looks like we do have one, and the important thing to keep in mind when this happens is that this is definitely Yevgenyâ€™s fault. Usually, what I do at this point is type up an angry email and send it to Yevgeny and his manager, but since I want to actually show you how to submit an app to the App Store, letâ€™s go ahead and fix it.
In this case, it looks like weâ€™re missing an application category, and this is actually really common if youâ€™re taking a pre-existing app, and you want to submit it to the App Store, you might not already have a category set up because you distributed it through your website previously. Itâ€™s also very easy to fix. Letâ€™s click finish and go back to the project to fix it. Iâ€™ll select my project and return to the target summary editor, and youâ€™ll see at the very top, thereâ€™s a pop up from which you can select a category. All I have to do is choose the one that looks right, in this case, Lifestyle, and build a new archive because Iâ€™ve modified my applicationâ€™s info P list so I need a new archive. Now I should be ready to submit to the App Store. To do that, all I do is click distribute, select submit to the Mac App Store, hit next.
Once again, Xcode will want my iTunes Connect credentials. This is the same as before. Again, if youâ€™re not seeing your app record here, you might have forgotten to create it or you might have forgotten to mark it as ready for upload. Iâ€™ll hit Next, and now my application again is being code signed and uploaded to the store, and once this is done, I should see a very nice message that says my app has been submitted. Letâ€™s just give it a few moments, and there we are. Thatâ€™s how easy it is to submit an app from Xcode.
Thatâ€™s great, now my app is available for my customers. I was able to submit it from Xcode very easily. Now Iâ€™d like to add some additional values so that my customers enjoy using my app even more and keep coming back. I can do that by creating In-App Purchase Content, and now with the new version of Xcode, I can do it very easily. Let me show you how to do that. Iâ€™ll go back to my project and hit the Add Target button. When I select Other here under OS X, Iâ€™ll see that I have a new In-App Purchase Content template. All I have to do is hit Next and give it a name and click Finish, and now Xcode has created a new target in my project for my In-App Purchase Content. Youâ€™ll see, we have a custom target summary editor for it so I can choose to rename my In-App Purchase Content if I like, change its identifier, or change its content version.
I can also drag some additional files into this group thatâ€™s been created in my project, but in this case, I think this is all I need to do so Iâ€™ll go ahead and archive, and submit this to the store. The first thing I need to do in order to do that is to select the correct scheme. When I added the target to my project, Xcode added a new scheme for me. Iâ€™ll choose that and archive. The archive appears in the organizer, I can click distribute, choose Submit In-App Purchase Content, click Next. Again, Xcode needs to log in to iTunes Connect and download any records that Iâ€™ve created because thereâ€™s a separate type of record for In-App Purchase Content. You can see here, my application record is listed, and the record I created for my In-App Purchase Content is available.
Now, all I have to do is click Next and Xcode will upload my content to the App Store. Thatâ€™s all you have to do to submit In-App Purchase Content now, you can do it all from a thin Xcode and weâ€™re done. Now, weâ€™ve shown you how to distribute applications outside of the App Store and in the App Store, and Iâ€™d like to invite my colleague, Rob Marini back on to the stage to show you some iOS Application Best Practices.
Rob: Thanks, Itai. Most of what we just showed you applies equally to iOS and to Mac OS X, but right now, weâ€™re going to focus exclusively on iOS beginning with the new feature in the App Store for iOS 6, Application Deltas. This is something that weâ€™ve actually had in the Mac App Store since Lion. In fact, earlier this week, we released an update to Xcode 4.3 that was just 97 megabytes. Gone are the days of needing to download 4-gigabyte installers just to get an updated SDK. Application update deltas are fantastic, from the perspective of your customers. The good news is, theyâ€™re also fantastic for you.
Deltas are generated from your application based on each fileâ€™s contents, and theyâ€™re managed entirely by the store. It keeps track of which versions to publish and which ones to give to your customers based on what version of the apps they have installed, and the store takes care of generating them for you. All you need to do is submit your application as normal, but thereâ€™s some things you can do to make sure your application update delta is as small as possible. For instance, if you were to change the name of a file, the entire file would be included in the delta. If you were to change the name of the directory, the entire directoryâ€™s contents would be included in the delta and would take that much longer for your customers to download the update, and if you were to change your applicationâ€™s name on disc, all of the applicationâ€™s contents would end up in the delta, which will probably lead to some unhappy customers.
That only really applies once youâ€™re ready to submit an update to the store. How do you actually know youâ€™re ready to go live with your update? For that, we have a process we call Ad Hoc Distribution, which most commonly is used for producing a beta of your application to provide to your customers to test. A lot of you work in small teams, maybe one or two people, and you donâ€™t have a dedicated, quality staff. Doing a beta test allows you to make sure that the customers that matter to you are satisfied with the state of your applicationâ€™s quality. It lets you interact directly with them, obtain feedback and respond to them in a rapid fashion, and it lets your customers feel like theyâ€™re directly influencing the direction of your product.
As a bonus, it lets you â€¦ before your app actually goes live on the store, identify whatâ€™s the weak points and strong points of it are so you can start planning your next update. Today, weâ€™re going to talk about some best practices for doing this, and itâ€™s important to know that we donâ€™t want to do a lot of work. We have fantastic tools and we want Xcode to do the work for us. Weâ€™re going to explore how to take advantage of the Xcode Build System to set up our application beta, and then weâ€™re going to talk about how to get our beta into our customerâ€™s hands easily and quickly. Specifically, we have some goals. The first is we want our application to co-exist on our customerâ€™s devices alongside the version chipping in the store, and to do that, weâ€™re going to take advantage of the appâ€™s bundle ID.
As it turns out, iOS deviceâ€™s unique installed applications on the home screen via the bundle ID. Weâ€™re going provide a different one for our beta application. Second, we want our beta to be something that can be quickly identified alongside our shipping application by our customers. To do that, weâ€™re going to provide a separate icon, and keeping in mind our earlier goal of doing less, we want Xcode to figure out which one to produce for us, and then of course, we actually want our customers to test our product. We want to make sure we can provide them with our application in a way that they can quickly and easily install wirelessly, and in fact, you can do that from Xcode.
Once youâ€™ve produced an archive of your application, you can distribute it in a way that allows you to save it for what we call Ad Hoc or Enterprise Deployment, and when you do this, youâ€™ll be prompted to provide some additional information to Xcode, and it can produce one of these installer manifests for you. The things youâ€™ll need are a URL where you plan to host the .ipa file that Xcode will save out, as well as the title of your app, and then you can give it some artwork or some additional text, and itâ€™ll show that when it provides the installer UI on the device, and once you save this out, Xcode will give you not only your IPA, but a property list file thatâ€™s pretty sure to look something like this, and for those of you who like to do their property list in the source code editor, it would look like this, and if you were to host this on a website alongside the .ipa, if you browse through it in Safari, and your device is listed in the provisioning profile for you application, your device will offer to install it. Itâ€™s great.
Now, I think I’m going to show you how to do that. I’m going ahead and close this because I’m working on an iOS app, and I’m hoping Yevgeny hasnâ€™t touched it. I have a copy of it here and I’m going ahead and open it, and since I know that you really donâ€™t want to see me type, Iâ€™ve done ahead and written out some text already that I’m going to use. Specifically, if I take a look at my project in the project editor, I’m taking advantage of a feature of Xcode called Configurations. Iâ€™ve created a new configuration from my application called a beta, and I did so by just hitting this plus button, and what I would like to do is tell Xcode that when I building for the beta configuration, I want to take certain things into account, and those things are Build System Settings. Iâ€™ve defined those in my target, and if I go to the Build Settings editor, I’m going to hide this inspector, go to the bottom, you can see, Iâ€™ve defined two Build Settings in the user defined section. One of which is Recipe_bundle_ID_suffix because Build Systems really like underbars.
Iâ€™ve provided a value for that, only for the beta configuration, which is .beta, and this is going to allow me to provide the Xcode Build System the context that says, when this string appears in something that weâ€™re going to pre-process, replace it with .beta, and similarly, I specified one from my Recipe icon name, and in my project, I actually have two icons, one of which is Recipe, and one of which is Recipe Beta. Where weâ€™re going to use these Build Settings is in our applications in [inaudible 00:51:20] list. For the bundle identifier, Iâ€™ve actually â€¦ at the end of this string, up ended Recipe bundle ID suffix, and for our icon, I specified Recipe icon name suffix.
Now, when I build my application as normal debug or release, those two Build Settings are going to evaluate to an empty string and everything will be left alone, but when I build it for the beta setting, theyâ€™ll actually be real values. I’m going to go ahead and actually build my application for this simulator in its normal configuration to show you what it looks like, to make sure thereâ€™s no tricks here. Hereâ€™s the app, and if I go to the home screen, there it is, as you can see, itâ€™s the standard application, standard icon. What I like to do now is to actually provide the iPhone simulator the beta configuration of it.
To do that, I’m going to manage my schemes, and Iâ€™ll actually duplicate this Recipe scheme, and what I want to do is tell it what I’m building is the beta configuration, and similarly, I want to provide this to my customers. When I’m archiving, use the beta configuration, hit OK, and now, I’m going to run again on the iPhone simulator. My application is still running so Iâ€™ll stop that, and now Iâ€™ll run again on the iPhone simulator, and here we are. Hereâ€™s the application, hit the Home button, you can see, there it is alongside a regular version has the new icon. Great. Now I want to provide it to my customers. I’m going to archive this application, but before I do that, I want to actually provide them with the device version so Iâ€™ll choose that as our active device, and now Iâ€™ll archive the application.
Now, Xcode is going to show me this inside of the Xcode organizer, and I can distribute it in the same fashion as weâ€™ve been seeing all day, but I can distribute it for Enterprise or Ad Hoc Deployment, and if I choose that, Xcode asks me for a code signing identity. My secret alias is actually Johnny Appleseed so Iâ€™ll hit Next, and when itâ€™s done, itâ€™s going to prompt me to save this somewhere, and I’m going to choose this Save for Enterprise Distribution flag, and at this point, I’m going to tell Xcode where my IPA is going to be hosted, since those recipes look pretty good naturally, this is will be right on Apple.com, typing on stage is a lot harder than it might seem. Interesting fact about WWDC, and then Iâ€™ll give it a title.
Now, Iâ€™ve chosen to save out an IPA of my app to my desktop along with this Install manifest, which is a property list that contains the URL to the IPA. Iâ€™ll go ahead and save that, and if I go back to Finder and take a look on my desktop, thereâ€™s the IPA and thereâ€™s the property list. Iâ€™ll open that next code for a second, and you could just see what its contents are, and if I put this property list on a web server as I said, and browsed it with a device, it will prompt me to install. I’m going to go ahead and close that. Now weâ€™ll switch back to slides. Letâ€™s talk about what we went over today.
First, how to distribute your application outside of the App Store in a way that ensures that itâ€™s available to your customers running Mountain Lion, as well as providing them with a sense of security and confidence in the quality of your application and its security. We also talked about how to take advantage of technologies available through the Mac App Store and how to submit your application to the Mac App Store and the iOS App Store, and in iOS, we talked about how to provide your customers with a pre-released copy of your application, distributed Ad Hoc in the form of a beta as well as some new features in the App Store in the form of deltas and how to make sure that your delta is as small as possible.
For more information, please feel free to contact Michael Jurewitz, our Evangelist, youâ€™ve probably seen him around this week. Heâ€™s the guy in the suit with the big camera. Thereâ€™s also some documentation in the form of the Tools Workflow Guides for Mac and for iOS, and if you have any questions, weâ€™re available on the Dev Forums. If youâ€™re interested in the OS X Application Sandbox, or taking advantage of Gatekeeper and Developer ID, there were some sessions about that earlier in the week, it would be available on video. Thereâ€™s also a session on how to take advantage of some new features in iTunes Connect for those of you managing a lot of In-App Purchase Content. Thank you.