App Development and Execution (iOS/iPadOS - Xcode)

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

This chapter was written based on the 15.0 version of Xcode.

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-based app, configure basic settings. You can create a project by accessing the below menu.

File > New > Project

Select 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 Nexacro libraries

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

The Nexacro library is provided as a compressed file with the filename, nexacro.framework.zip. First, unzip the file. Then, click the [+] button in Frameworks, Libraries, and Embedded Content and select Add Files. Then, select the file under the nexacro.framework folder to add it.

스크린샷 2023-10-24 오후 3.36.03

The default library, nexacro.xcframework, must be configured, while the rest of the items need to be added as needed based on the Device API used by the app.

Library

Required

nexacro.xcframework

Required

NXAcceleration.xcframework

NXAudioPlayer.xcframework

NXBluetoothLE.xcframework

NXCamera.xcframework

NXContact.xcframework

NXExternalAPI.xcframework

NXGeolocation.xcframework

NXLiteDB.xcframework

NXNetwork.xcframework

NXPush.xcframework

NXSms.xcframework

NXVibrator.xcframework

Added selectively depending on the Device API used by the app

project_new_03_01

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/documentation/xcode/configuring-your-app-icon

Set messages

The default messages used by the app are included in the Nexacro library. You can set your own message if you want to redefine the default messages.

To create a new file, select the project folder and select [File > New > File] from the menu.

Choose "Strings Files" from a selection of templates.

project_new_08

In the "Save As" field, make sure the file is named "Localizable.strings."

project_new_09

Modify the created Localizable.strings file as presented below.

/* 
 Localizable.strings english
 nexacro
 */

 "needupdate" = "It is need to update. \r\nIt will start after the update is completed.";
 "loadingFail" = "First loading is fail. \r\nPlease restart.";
 "updateFail" = "Update is fail. \r\nPlease restart.";
 "notexist" = "Start file is NOT exist. \r\nPlease restart.";
 "BeingUpdated" = "Being updated.";
 "ok" = "OK";
 "cancel" = "Cancel";
 "alert_title" = "";
 "checkforupdates" = "Check for updates.";
 "installforupdates" = "Install for updates.";
 "downloadingforupdates" = "Downloading for updates.";
 "new_engine_available" = "Engine update required.";

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/documentation/xcode/localization

Set Config

Set the nexacro_config.xml file to apply the functionalities provided by Nexacro 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" failpass="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.

failpass

"true" | "false"

Set whether to ignore the update errors or not

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.

AppDelegate.h

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

//
//  AppDelegate.h
//  HelloNexacro
//

#import <UIKit/UIKit.h>
#import <nexacro/NXAppDelegate.h>

@interface AppDelegate : NXAppDelegate


@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
//  HelloNexacro
//

#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application 
	didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.viewController = [[ViewController alloc] init];
    
    // Update Type: Server, Update
    self.viewController.projectUrl = @"http://[URL]/_ios_/";
    self.viewController.bootstrapUrl = @"http://[URL]/_ios_/start_ios.json";
    
    // Update Type: Local
    // self.viewController.bootstrapUrl = @"file:///ios_asset/archive/start_ios.json";
    
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@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
//  HelloNexacro
//

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

int main(int argc, char * argv[]) { 
	NSString * appDelegateClassName; 
	@autoreleasepool { 
		// Setup code that might create autoreleased objects goes here. 
		appDelegateClassName = NSStringFromClass([AppDelegate class]); 
	} 
	return UIApplicationMain(argc, argv, nil, appDelegateClassName); 
}

ViewController.h

//
//  ViewController.h
//  HelloNexacro
//

#import <UIKit/UIKit.h>
#import <nexacro/NXViewController.h>

@interface ViewController : NXViewController

@end

Other settings

Build Settings

Item

Value

Architectures > Build Active Architecture Only

Debug

No

Release

No

Apple Clang - Language - Objective-C

Objective-C Automatic Reference Counting

Yes

스크린샷 2023-10-24 오전 9.51.59

스크린샷 2023-10-24 오전 9.47.37

스크린샷 2023-10-24 오후 2.58.34

Set your app stand-alone in disconnected environments

When packing an app in Nexacro Studio, if the Update Type is set to Local or Update (Local+Server), the app can be run without a network connection. In general, the Local type is used when a network connection is not required, and the Update (Local+Server) type is used when you need to run the app with a local file after running the app while connected to the network. To enable the app to run without a network connection or independently there is a problem with the network, the files necessary to run the app must be loaded and deployed when building the app.

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.

Launch Finder and create an archive folder at the lowermost part of the Xcode project path. Then, copy the files created by [Packing (Archive&Update)] in Nexacro Studio to the archive folder.

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

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

select_device_01