Introduction

Xcode is the development tool provided by Apple for creating iOS applications. In this article We are going to study some of the most important features of Xcode and the Apple Developer Portal.

2.1 Portal creation and configuration wizard http://developer.apple.com

Xcode incorporates a set of templates that allow us to quickly generate the skeleton of the types of most common applications. These types are: Master-Detail Application, Page-Based Application, Single View Application, Tabbed Application and Game.
The fundamental difference between the different types of applications is the class ViewController main.

tipo_applicacion.png

Single View Application
The ViewController class is a subclass of UIViewController. This class is the simplest and is used as base of all drivers. A common use of this type of application is to add an object to the controller of the type UIWebView to create a hybrid HTML/Objective-C application

capture_single_view.png

Master-Detail Application
The ViewController class is a subclass of UITableViewController. An example, the iOS Notes app.

captura_notes.png

Page-Based Application
The ViewController class is a subclass of UIViewController, but in this case it implements the protocol UIPageViewControllerDelegate and contains a
object of type UIPageViewController

@interfaceRootViewController : UIViewController<UIPageViewControllerDelegate>
@property (strong, nonatomic) UIPageViewController*pageViewController;
@end

News applications are an example of this typology.

capture_the_guardian.png

Tabbed Application: Example of an application that flows between multiple views using a bar lower of buttons.

capture_calendar.png

Games
This type of application is the one we select when we are going to make a video game. In this case the assistant When creating a new project, it will ask us what technology we are going to use to make the video game. We can select between four types of technologies: SceneKit, SpriteKit, OpenGL ES and Metal.

Captura de juego en dispositivo iOS

SceneKit, SpriteKit, and Metal are Apple's proprietary technologies that simplify app creation and They provide more performance as they are optimized for your hardware.

Open GL is a better option if at some point we also want to make our application on another platform.

Creation of your first project.

Once the template is selected, we are asked to fill in the necessary data to identify the application.

datos_de_aplicacion.png

The data is:

  • Product name- The name of the application.
  • Organization name: the name of our organization or company.
  • Organization identifier: is usually  “com.” concatenated with the organization name and is with which the Bundle Identifier will be built automatically.
  • Bundle Identifier: is the application identifier, usually has the syntax of an application name domain written in reverse.

Settings http://developer.apple.com.


Once we access the member center with our login, we navigate to the option Certificates, Identifiers & Profiles. In the section Identifiers/App Idswe register our application with the same data that we have used in the Xcode app creation wizard.

Captura de pantalla 2015-10-28 a las 22.39.15.png

Push notification settings

On this same page we will configure the services that we want to add to our application. Some already appear added by default. In this case we have added notifications (Push Notifications).

otros_servicio_apple_Dev.png

We have to emphasize that some of these services require subsequent configuration to be active, this is the case of Push notifications. If this additional configuration is not done, the application may be approved by Apple and yet this service will not be available.

In the case of Push configurations, it is necessary to download the certificates to send notifications in the test mode and production mode.

config_notificaciones.png

We click on Edit and in the notifications section we create and download the certificates.

descargamos_certificados.png

These certificates will be used in the back-end of our application to send the notifications.
To generate the specific certificate for our application, our certificate is necessary. developer linked to a Mac computer. On our Mac we must run Utilities\Keychain Access. In the certificates section we can export our developer certificate. If it does not appear we have to check the following:

  • 1) Start Xcode and in the Xcode\Preferences\Account option we register our Apple Id and click on the button View Details. This should generate and download the developer certificate to our keychain.
  • 2) Go to the certificates section in https://developer.apple.com and generate the certificate again

reinstalar_el_certificado.png

Returning to the Xcode wizard, on this same screen we select the programming language that we will use, we can choose between Objective C or Swift.

We will also select the destination device of the application. The available devices are iPhone, iPad and Universal.
If we select iPhone or iPad, the application will only be tested by Apple on the indicated devices. Yes We choose Universal the application will be tested on iPhone and iPad and the application should behave correctly on the two types of devices.

In the event that the application must work on iPad and iPhone, now we have to decide if we will make two different applications or if we will create a single Universal application.

If we create a Universal application we can share all the data access code and we can use the system of GUI editor restrictions for adjustments to be made to different screen sizes of the devices.  However, not everything is so magical. The restriction system is powerful enough to to adjust the design between the iPhone 4S, 5C, 5S, 6 and 6S, but it is not to adjust it between iPhone and iPad since screen resolutions are very different and the interface elements used are often different. This It implies that on many occasions we have to add classes to separately support graphical needs. of iPhone and iPad.

The code to identify the family of Apple devices is this:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
// iPad
}
else{
// iPhone or iPod
}

Swift:

if (UIDevice.current.userInterfaceIdiom == .pad) {
// iPad
}
else{
// iPhone or iPod
}

2 Main configuration screen of our application.

pantalla_principal.png

- Identity:
Here we will change the version number to make successive updates to the AppStore. We could also change the Bundle Identifier if necessary.

- Deployment Info:

Deployment target: the minimum operating system version of our application is selected. It is important remember that by default each Xcode assigns the latest version of the operating system available. Although the rhythm of update of Apple users is very high, it is never advisable to generate the application for the latest available version. In In this case, it is usual to download at least one version.

When generating applications that must run on different versions of the operating system, it is very normal to include code to be executed depending on the iOS version. The Objective-C preprocessor allows you to include blocks of type code:

#ifdef __IPHONE_8_0
// iOS 8 code
#endif

#ifdef __IPHONE_9_0
// iOS 9 code
#endif

Swift:

if#available(iOS8.0, *) {
// iOS 8 code
}

if#available(iOS9.0, *) {
// iOS 9 code
}

Devices: we can change the target device family of our application again We select in the wizard.

Device orientation: the guidance available in our application. Basically if our application will respond to orientation change events to provide portrait and vertical displays. horizontal. If an application only has the vertical orientation defined, it will look the same when the user Place your device horizontally.

Apple's graphical restrictions system allows automatic adaptation of the interface when changing between orientation. As we have commented in the case of Universal applications, this automatic adaptation is not usually sufficient and specific code is necessary for the different orientations.

Main interface: indicates the identifier of the View Controller of the storyboard that is going to be executed in first place for the application.

Status bar style: refers to whether we want them to appear in our application all the indicators (time, battery charge level, etc.) or on the contrary we do not want these to appear indicators.

App icons and Launch images: The number and definition of the icons depend on the families of target devices of our application.

iconos.png

The definition is indicated as the number of points, in the first case 29pt, multiplied by the number that appears in the icon. For example, the first icon is 58 pixels and the second is 87 pixels. The way to assign the icon is drag the .png file onto the rectangle.

Launch Screen File: indicates the storyboard that will be used as the splash screen while booting the application. In versions after iOS 8 it was simply a screen. Now it is a storyboard that allows incorporate controls such as text, images, etc.