App Development and Execution (iOS)

Establish App Development Environment

iOS apps are developed with Xcode and the iOS SDK, which both can run not in Windows computers but in Mac computers. Moreover, you need an Apple developer account to download Xcode, develop an app and test it.

Basically, you should follow the below steps to establish the environment for developing an iOS app. The detailed process may vary according to the updates on the developer site.

  1. Create an Apple developer account

  2. Install Xcode and the iOS SDK

  3. Necessary tasks for distribution

Create an Apple developer account

If you have an Apple ID already, you can download Xcode and use free services without obtaining a developer license only by registering your ID. In iOS, furthermore, you can test your app with the simulator.

If you use the simulator, there is no need for separate verification. If you use an actual device, however, you should get a developer license to pass an additional verification process.

Create an Apple ID

If you want to get an Apple developer account, you must create an Apple ID in advance. That is, you have to register your existing Apple ID as an developer account rather than creating a separate developer account.

Click on the below link to go to the web page for creating an Apple ID. Your e-mail account used in the sign-in process will be used as your Apple ID. Skip this step if you already have an Apple ID.

https://developer.apple.com/account/

Obtain a developer license

If you conduct a simulation test only without any connection with a device, click on the below link to register your Apple ID as a developer account.

https://developer.apple.com/register

However, you should enroll in the iOS Developer Program if you want to be provided with necessary services for development, test and deployment. This enrollment lasts for a year and incurs a separate cost. Click on the below link to learn what services you can be provided with from the Apple Developer Program.

https://developer.apple.com/programs/

You can enter the enrollment process by clicking the Enroll button at the top of the web page. A developer account is issued to an individual or organization.

apple_developer_program_page

If you enroll as an organization, you need a D-U-N-S (Data Universal Numbering System) number. This number is a type of a code that is used worldwide as a standard business identifier. You can obtain a D-U-N-S number from the Apple's official website free of charge. After you apply for a number at the Apple's website, the issuer agency will contact you by phone to ask you to send necessary document. A number will be issued eventually after your document is received and accepted.

https://developer.apple.com/ios/enroll/dunsLookupForm.action

https://developer.apple.com/support/D-U-N-S/

Once your D-U-N-S number is registered, a person at Apple will review your application and call you to confirm your information. Unless there is any problem, Apple will send you an e-mail to inform you that the enrollment process has finished. In the e-mail, you can click a link to agree on the license terms and buy a one-year developer account from the store.

Once you have been through up to the purchase of an account, you will receive an activation code through an e-mail. When you enter your activation code in the verification page, the entire enrollment process finishes finally.

You will see the iOS Developer Program menu added to the right hand side of the iOS Dev Center.

Install Xcode and the iOS SDK

Xcode is an integrated development environment for macOS containing a suite of software development tools. Even if you have Xcode already installed in your computer, you may need an update because the required version of Xcode varies according to the versions of the iOS SDK installed in the devices to be connected for test.

You can check the latest version of Xcode you can download by clicking on the below links. You can also download Xcode directly from the App Store. The installation file of Xcode includes the iOS SDK and Mac SDK.

https://developer.apple.com/xcode/

https://developer.apple.com/download/

xcode_download_page

If you need another version of Xcode, you can download it from the below link.

https://developer.apple.com/download/more/

Necessary tasks for distribution

To test your app by using actual devices, you are subject to several verification processes. To this end, you must join the Apple Developer Program.

Click on the below link to learn the tasks you need to do to distribute your app.

https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/Introduction/Introduction.html

Develop App Project

Follow the below steps to work on an iOS app project in Xcode. Before entering an app project, you should find the archive files that you built in Nexacro Studio and locate them in the designated directory.

Create a project

After creating an iOS project that will contain your Nexacro Platform-based app, configure basic settings. You can create a project by accessing the below menu.

File > New > Project

Select Single View App as a template for the created project.

project_new_01

After deciding on the options for your new project such as the product's name, click the Next button to open a pop-up. Click the Create button in the pop-up after designating the location of the new project and then you will finally see the new project created.

project_new_02_01

A project may be created in a different way depending on the versions of Xcode.

If you use iPhone X, you should add a Launch Storyboard to your project to prevent blanks at the top and bottom of the screen.

Click on the below links for the detailed information.

https://developer.apple.com/ios/update-apps-for-iphone-x/

https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/launch-screen/

Set iOS libraries and frameworks

Set the libraries and frameworks necessary for using the APIs provided by iOS. If you select a target in your project, you will see the General tab at the top of the Xcode screen. In the tab, you can add libraries and frameworks in the 'Linked Frameworks and Libraries' section.

project_new_03_01

Click the + button at the bottom of the section and add the below 19 items.

AddressBookUI.fremawork

AddressBook.fremawork

AudioToolbox.framework

AVFoundation.fremawork

CFNetwork.fremawork

CoreLocation.fremawork

MediaPlayer.fremawork

QuartzCore.fremawork

MobileCoreServices.framework

CoreMedia.framework

Security.framework

SystemConfiguration.framework

MessageUI.fremawork

CoreBluetooth.framework

UIKit.framework

libc++.tbd

libxml2.tbd

libz.1.2.5.tbd

libsqlite3.0.tbd

When you add a library or framework for the first time, the Frameworks group is automatically created in the project navigator. Since this is a logical group, it does not appear in the actual project folder.

Sometimes added libraries and frameworks are seen only in the navigator on the left side but not in "Linked Frameworks and Libraries" on the right side. In this case, you should drag those libraries and frameworks from the navigator and drop them on 'Linked Frameworks and Libraries' to add them. Otherwise, an error will occur in the build process.

Set Nexacro Platform libraries

Add Nexacro Platform libraries to your iOS project to establish an optimal environment for Nexacro Platform.

Nexacro Platform libraries are provided in the form of a compressed file named nexacro17.ios.framework.zip. Decompress the zipped file and drag the libraries into the Frameworks group in your project.

nexacro_library_추가_자름

Set resources

In this stage, you can set launch images, icons, messages and layouts applied to your app. You can adjust those options according to projects.

Set images

A project in Xcode created with a template contains an empty asset catalog, which is used to manage resources. You can add app icons, launch images, etc. to the catalog.

You can individually set the app icons and launch screen images used in an iOS app. Moreover, you can bring images that are made already.

You must use images that are designed appropriately for the iOS devices you target. Assume that you set an image whose size does not fit target devices or set an image with a property incompatible with target devices. In those cases, an error will occur in the build process or your app will not work properly even if it is built.

Click on the below link to visit the Apple developer web page that provides the details on the settings of icons and images.

https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/image-size-and-resolution/

You can set icons and images in the project configuration. If you select a target in your project, you will see the General tab at the top of the Xcode screen. In the tab, go to the "App Icons and Launch Images" section.

appicon_launch_image_설정_01

By clicking the arrow beside the "App Icons Source" option, you can set app icons at the asset catalog, as illustrated below. Drag and drop icon images into the slots appropriate for each device and use.

appicon_launch_image_설정_02

Click "Use Asset Catalog..." beside the "Launch Images Source" option to open the pop-up illustrated below. If you create your project by using a template, a basic asset will be given to you. In that case, choose "Assets" from the selector in the pop-up and click the Migrate button.

appicon_launch_image_설정_03

Once the migration is done, the launch images included in the asset catalog are seen on the left side while on the right side you can set launch images appropriate for each device and use. Drag and drop launch images from the left pane onto appropriate slots on the right pane.

appicon_launch_image_설정_05

Set messages

You can create a separate file to save messages that can be used in your app.

To create a new file, select a project folder and choose "New File" from the context menu.

project_new_07

Choose "Strings Files" from a selection of templates.

project_new_08

Name the file "Localizable" in the Save As field.

project_new_09

Modify the created Localizable.strings file as presented below.

/* 
  Localizable.strings
  HelloiOS
*/
"needupdate" = "It needs an update.";
"loadingFail" = "First loading fails.  \r\nPlease restart.";
"updateFail" = "Update fails.  \r\nPlease restart.";
"notexist" = "Start file does NOT exist.  \r\nPlease restart.";
"BeingUpdated" = "Being updated.";
"wantreplace" = "There is a file of the same name. Do you want to replace? ";
"ok" = "OK";
"cancel" = "Cancel";
"move" = "Move";
"upper" = "Upper";
"filter" = "Filter";
"home" = "Home";
"nofilename" = "No File Name.";
"checkforupdates" = "Check for update.";
"installforupdates" = "Install update.";
"downloadingforupdates" = "Downloading update.";
"force_close" = "Update is Completed.";

In the Utilities pane on the right side of the Xcode screen, click "Localize..." button in the Localization section to select the language for your app. If you do not add another language in advance in the project's settings, the language will be English by default.

Localization_01

To support languages other than English, navigate to the menu [PROJECT > Info > Localizations] and click + button to add another language.

Localization_02

Click on the below link to visit the Apple developer web page that provides the details on localization.

https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPInternational/Introduction/Introduction.html

Set Config

Set the nexacro_config.xml file to apply the functionalities provided by Nexacro Platform to your app. You can activate features including app updating, notification and error processing. You should create the nexacro_config.xml file by yourself and locate the file under the folder [{Asset} > data]. This file should be included in the project when your app is built in Xcode.

Even if the nexacro_config.xml file does not exist, there will be no problem in running your app because the default configuration will be applied instead.

The nexacro_config.xml file is in the XML format and written like the below sample.

<?xml version="1.0" encoding="utf-8"?>
<nexacro-config>
  <application dialog-position="top" use-wkwebview="true" file-logging="true" />
  <notification enable="true" handler="DefaultNotificationManagerHandler"/>
  <updator force="false" cancelable="false" quiet="true" errormsg="true"/>
  <xpush-server request-missing-message="true" />
</nexacro-config>

The below table shows the features that you can set in nexacro_config.xml.

Features

Property

Value

Description

application

dialog-position

"top" | "center" | "bottom"

This property sets the position of a pop-up for showing the progress of app updating.

file-logging

"true" | "false"

This property determines whether to log loading errors in the form of a file.

You can check the log file through iTunes.

updator

force

"true" | "false"

This property determines whether to display a pop-up for announcing the existence of an update, contained in start_ios.json.

If "true", updating will be conducted automatically without pop-up announcement.

cancelable

"true" | "false"

This property determines whether to display a "Cancel Update" button in a pop-up for announcing the existence of an update.

If you click the "Cancel" button, the updating will not be conducted and the app will be closed.

errormsg

"true" | "false"

This property determines whether to display a pop-up for showing the error information when the loading of the app fails.

quiet

"true" | "false"

This property determines whether to display a pop-up that asks you whether to update the app.

Even if you specify "true", the progress of app updating will be displayed when there is an update file.

xpush-server

request-missing-message

"true" | "false"

This property determines whether to automatically request reliable messaging messages that you have not received from an XPush server.

notification

enable

"true" | "false"

This property determines whether to use the notification feature.

handler

"[class name]"

This property sets the class to define a handler for processing notification.

The default value is “DefaultNotificationManagerHandler”.

Set build environment

You should modify AppDelegate.h, AppDelegate.m and main.m—default files created in the process of creating an iOS project—in a way that suits Nexacro Platform.

AppDelegate.h

Modify the created AppDelegate.h file as below so that the file inherits the Nexacro Platform's AppDelegate class. Then, the nexacro17 framework will work properly.

//
//  AppDelegate.h
//  HelloiOS
//

#import <UIKit/UIKit.h>
#import <nexacro17/NexacroAppDelegate.h>
#import <nexacro17/NexacroMainViewController.h>

@interface AppViewController : NexacroMainViewController
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end

@interface AppDelegate : NexacroAppDelegate <UIApplicationDelegate>
-(NexacroMainViewController*)initializeMainViewController;
@end

AppDelegate.m

In the AppDelegate.m file, you should specify the URL of the start_ios.json file located in the server. The JSON file is created with Nexacro Studio. Replace the portion written in bold in the below code listings with something appropriate for your settings.

//
//  AppDelegate.m
//  HelloiOS
//

#import "AppDelegate.h"

@implementation AppViewController
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
@end

@implementation AppDelegate
- (NexacroMainViewController*)initializeMainViewController
{
    NSString *bootstrapUrl = @"http://[URL]/start_ios.json";
    
    [[NexacroResourceManager sharedResourceManager] setBootstrapURL:bootstrapUrl isDirect:NO];
    AppViewController* controller = [[AppViewController alloc] initWithFullScreen:NO];
    
    return controller;
}
@end

main.m

UIApplicationMain is a default function provided by the UIKit framework, serving as a starting point of an app. This function gets the app ready to receive inputs from the user by preparing for the operation of the app and setting up the main event loop.

After checking whether the main.m file is written as below, modify the file if different.

//
//  main.m
//  HelloiOS
//

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

Other settings

You need to change some options in "Build Settings".

Build Settings > Architectures > Build Active Architecture Only

Debug: No
Release: No
Build Settings > Apple LLVM 9.0 - Language - Object C > Objective-C Automatic Reference Counting

Yes

Set your app stand-alone in disconnected environments

You can run your app without a network connection if you set the update type to "Local" or "Update (Local+Server)" when packing the app in Nexacro Studio. Normally, the Local type is appropriate for users who do not need a network connection while the Update (Local+Server) type suits users who usually maintain communications with servers but still need to operate apps even when networking is in trouble. To make your app stand-alone, you should prepare files necessary for execution and load them onto the app in the building process.

The files necessary for executing an app include modules, sources, resources, Run.zip and start_ios.json, which are all obtained through the Packing (Archive&Update) process of Nexacro Studio. If you load those files onto the "archive" folder in your Xcode project before building an app, you can run the app without a network connection.

Even if you set the update type to "Local" in the Packing (Archive&Update) process of Nexacro Studio, you must specify a bootstrap URL in the AppDelegate.m file of your Xcode project.

For example, you can specify a random URL like the below one, which is either virtual or unused actually.

NSString *bootstrapUrl = @"http://192.168.0.1/_ios_/start_ios.json";

1

Create an "archive" folder in Finder and copy module, source and resource files to the folder.

Open Finder and create an "archive" folder under your Xcode project. Then, find the files created through the Packing (Archive&Update) process of Nexacro Studio and copy them to the archive folder, as illustrated below.

01_Finder에_폴더생성및파일복사

2

Add the archive folder to your Xcode project.

Click the plus (+) button at the bottom of Xcode's project navigator and select Add Files to "project name".

02_Xcode_파일추가

Select the archive folder and choose "Create folder references" as an "Added folders" option. Then, click the Add button.

03_Xcode_파일추가2

3

Check whether the folder and files have been added to your project successfully.

Go to the project navigator of Xcode and check whether the archive folder and the files under the folder have been added successfully.

04_Xcode_확인

Folders in Xcode's project navigator are displayed in either yellow or blue. Yellow folders are nonexistent since they are just logical groups that serve as an indicator of the project's organization. By contrast, blue ones are actual Finder folders. After an app is built, files in yellow folders are included in the app's root directory while files in blue folders are contained in their respective folders with the folder structure unchanged.

Test App

You can test your app by connecting an iOS device to your PC using a USB cable or by using a simulator. If you use a physical device, you should install an appropriate profile on the device.

  1. As seen below, access the Scheme menu at the top of the Xcode screen and choose a destination—a connected iOS device or an iOS simulator where your app will be tested.

select_device_01

select_device_02_01

  1. Run your app by clicking the Run button at the top of the Xcode screen or accessing the Run menu.

select_device_01

Product > Run

project_new_13_resize