# iOS Native

## Learn how to

1. Add iOS Viewer library to your project
2. Connect to the server, open iOS viewer, and load an e-Form in your storyboard.
3. Trigger the e-Form submit button from an action button

## Preparations

### Required skills/experiences

* iOS native App development experience with Xcode

### XCode

* Here we use Xcode ver. 12.1

### OZ products

* e-Form Server installed on the WAS server
* iOS Viewer library

  Download **ozrv80\_ios\_version.number.tar.gz** from 👉 [Product Downloads](/product-downloads.md)

## Sample project

Create a new iOS App project ("app") with Objective-C and Storyboard.

### Add iOS viewer library to the project

1. Create a folder (ex: **ozviewer**) under your project folder.
2. Add the license file to **ozviewer** (Your instructor will provide the license file).
3. Copy **custom\_ui** and **Framework** folder into **ozviewer** from extracted files.
4. Remove the **Device** folder from **Framework** (We will run the app on the simulator).

   If you want to run the app on your device, remove the **Framework** folder.
5. Remove the **optional** folder from **Simulator** ( We don't need optional features for now).
6. Right-click your project folder > **Add Files to "app"** > select the **ozviewer** folder > **Add**
7. Right-click the target, go to the **Build Phases** tab, and add more libraries and frameworks:

   libc++.tbd\
   libxml2.tbd\
   libiconv.tbd\
   UIKit.framework\
   Foundation.framework\
   CoreText.framework\
   CoreGraphics.framework
8. And in the **Copy Files**, add the **OZRViewer.framework**.

![](/files/x7SNPxCPd9ohvBxeI8Vm)

### Storyboard

#### Add a view for OZ viewer

![](/files/E2545A9S75FuF7OroBd5)

#### Add a button for Submit

![](/files/bJ7wjuBjgNbGbsPV0NS5)

#### ViewController.h

```objectivec
//  ViewController.h
//  app
//
//  Created by John Kim on 2021/10/27.
//
 
#import <UIKit/UIKit.h>
#import <OZRViewer/OZReportViewer.h>
@interface ViewController : UIViewController <OZReportCommandListener> {
}
@property (weak, nonatomic) IBOutlet UIButton *SubmitBtn;
@property (nonatomic, retain) OZReportViewer* viewer;
@property (nonatomic, retain) IBOutlet UIView *OZViewer;
@end
```

#### ViewerController.m

```objectivec
//  ViewController.m
//  app
//
//  Created by John Kim on 2021/10/27.
//
 
#import "ViewController.h"
#import <OZRViewer/OZReportAPI.h>
 
@interface ViewController ()
 
@end
 
@implementation ViewController
@synthesize viewer, OZViewer;
 
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
 
    [self performSelector:@selector(createViewer) withObject:nil afterDelay:0.1];
 
}
 
-(void)createViewer{
    NSString* ozserverUrl = @"http://oz.ozeform.io/oz/server";
    NSString* ozrFileName = @"demo/customer.ozr";
 
    NSString* paramStr = [NSString stringWithFormat:@"connection.servlet=%@\n", ozserverUrl];
    paramStr = [NSString stringWithFormat:@"%@connection.reportname=%@", paramStr, ozrFileName];
 
    OZReportViewer* newViewer = [OZReportAPI createViewer:self view:self.OZViewer listener:self param:paramStr closeButton:nil];
    self.viewer = newViewer;
}
 
- (IBAction)Submit:(id)sender {
    NSString* validity = [self.viewer GetInformation:@"INPUT_CHECK_VALIDITY"];
    if ([validity isEqualToString:@"valid"]) {
        NSString* inputData = [self.viewer GetInformation:@"INPUT_JSON_ALL"];
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Input data" message:inputData preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleCancel handler:nil];
        [alert addAction:closeAction];
        [self presentViewController:alert animated:YES completion:nil];
    }
}
 
@end
```

#### Info.plist

App Transport Security Settings > Allow Arbitrary Loads > **YES**

### Run the app

![](/files/FHvlhT6Zf2SX6qv0US1K)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://edu.ozeform.io/mobile-developer/ios-native.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
