You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Build and Run the Project](#build-and-run-the-project)
25
+
26
+
## Requirements
27
+
28
+
- Supported OS: iOS 11 or higher (iOS 13 and higher recommended).
29
+
- Supported ABI: arm64 and x86_64.
30
+
- Development Environment: Xcode 13 and above (Xcode 14.1+ recommended).
31
+
32
+
## Add the xcframeworks
33
+
34
+
The Dynamsoft Code Parser (DCP) iOS SDK comes with four libraries:
35
+
36
+
| File | Description |
37
+
|---------|-------------|
38
+
|`DynamsoftCodeParser.xcframework`| The Dynamsoft Code Parser library, which includes code parsing logic and related APIs. |
39
+
|`DynamsoftCore.xcframework`| The core library, which includes common basic structures and intermediate result related APIs. |
40
+
|`DynamsoftLicense.xcframework`| The license library, which includes license related APIs. |
41
+
|`DynamsoftCodeParserDedicator.xcframework`| The code parser helper library, which includes some validation functions used by the SDK. |
42
+
43
+
There are two ways to add the libraries into your project - **Manually** and **Via the CocaPods**.
44
+
45
+
### Add the xcframeworks Manually
46
+
47
+
1. Download the SDK package from the <ahref="https://www.dynamsoft.com/survey/dlr/?utm_source=docs"target="_blank">Dynamsoft website</a>. After unzipping, four **xcframework** files can be found in the **Dynamsoft\Frameworks** directory:
48
+
49
+
-**DynamsoftCodeParser.xcframework**
50
+
-**DynamsoftCore.xcframework**
51
+
-**DynamsoftLicense.xcframework**
52
+
-**DynamsoftCodeParserDedicator.xcframework**
53
+
54
+
2. Drag and drop the above **xcframeworks** into your Xcode project. Make sure to check Copy items if needed and create groups to copy the **xcframeworks** into your project's folder.
55
+
56
+
3. Click on the project settings then go to **General –> Frameworks, Libraries, and Embedded Content**. Set the **Embed** field to **Embed & Sign** for all the **xcframeworks**.
57
+
58
+
### Add the xcframeworks via CocoaPods
59
+
60
+
1. Add the frameworks in your **Podfile**, replace `TargetName` with your real target name.
61
+
62
+
```pod
63
+
target '{Your project name}'do
64
+
use_frameworks!
65
+
66
+
pod 'DynamsoftCodeParser','2.0.20'
67
+
68
+
end
69
+
```
70
+
71
+
2. Execute the pod command to install the frameworks and generate workspace(**{TargetName}.xcworkspace**):
72
+
73
+
```bash
74
+
pod install
75
+
```
76
+
77
+
## Build Your First Application
78
+
79
+
The following sample will demonstrate how to create a simple `HelloWorld` app for parsing text or bytes.
80
+
81
+
>Note:
82
+
>
83
+
>- The following steps are completed in XCode 14.2
84
+
>- View the entire Swift source code from [HelloWorld(Swift) sample](https://github.com/Dynamsoft/code-parser-mobile-samples/blob/main/ios/HelloWorld/)
85
+
86
+
### Create a New Project
87
+
88
+
1. Open XCode and select New Project… in the File > New > New Project… menu to create a new project.
89
+
90
+
2. Select **iOS -> App** for your application.
91
+
92
+
3. Input your product name (HelloWorld), interface (StoryBoard) and language (Objective-C/Swift)
93
+
94
+
4. Click on the **Next** button and select the location to save the project.
95
+
96
+
5. Click on the **Create** button to finish.
97
+
98
+
### Include the Library
99
+
100
+
Add the SDK to your new project. Please read [Add the xcframeworks](#add-the-xcframeworks) section for more details.
101
+
102
+
### Initialize the License
103
+
104
+
1. Use the `LicenseManager` class and initialize the license in the file **AppDelegate**.
>- Network connection isrequiredfor the license to work.
124
+
>- The license string here will grant you a time-limited trial license.
125
+
>- If the license has expired, you can go to the <a href="https://www.dynamsoft.com/customer/license/trialLicense?utm_source=docs&product=dcp&package=mobile" target="_blank">customer portal</a> to request for an extension.
126
+
127
+
### Initialize Code Parser And Parse the Code Bytes
128
+
129
+
1. Import and initialize the `CodeParser`.
130
+
131
+
```swift
132
+
import UIKit
133
+
import CodeParser
134
+
class ViewController: UIViewController {
135
+
privatelet codeParser =CodeParser()
136
+
137
+
}
138
+
```
139
+
140
+
2. Add a "Parse" button on the UI.
141
+
142
+
```swift
143
+
classViewController: UIViewController {
144
+
...
145
+
lazyvar parseButton: UIButton = {
146
+
let left =120.0
147
+
let width = UIScreen.main.bounds.size.width-2* left
148
+
let height =50.0
149
+
let top = UIScreen.main.bounds.size.height-50.0- height
150
+
let button =UIButton(frame: CGRectMake(left, top, width, height))
let passportMRZStr ="P<D<<ADENAUER<<KONRAD<HERMANN<JOSEPH<<<<<<<<1234567897D<<7601059M6704115<<<<<<<<<<<<<<<2"
174
+
175
+
let data = passportMRZStr.data(using: String.Encoding(rawValue: NSUTF8StringEncoding))
176
+
177
+
guard data !=nilelse {return}
178
+
179
+
let dcpResultItem =try?self.codeParser.parse(data!, taskSettingName: "")
180
+
181
+
showResults(dcpResultItem)
182
+
}
183
+
}
184
+
```
185
+
186
+
>Note:
187
+
>- Check out the complete <a href="https://www.dynamsoft.com/code-parser/docs/core/code-types/" target="_blank">supported code types and fields </a>for details.
188
+
189
+
### Display Parsed Results
190
+
191
+
1. Display the parsed result(s) in an alert dialog box.
0 commit comments