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
Copy file name to clipboardExpand all lines: programming/objectivec-swift/foundational-guide.md
+79-98Lines changed: 79 additions & 98 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,6 @@ keywords: user guide, objective-c, oc, swift
6
6
needAutoGenerateSidebar: true
7
7
needGenerateH3Content: true
8
8
noTitleIndex: true
9
-
multiProgrammingLanguage: true
10
-
enableLanguageSelection: true
11
9
---
12
10
13
11
# Build Your App with Foundational APIs
@@ -18,11 +16,33 @@ enableLanguageSelection: true
18
16
- Supported ABI: **arm64** and **x86_64**.
19
17
- Development Environment: Xcode 13 and above (Xcode 14.1+ recommended).
20
18
21
-
## Add the SDK
19
+
## Build Your First Application
20
+
21
+
In this section, let's create a **HelloWorld** app for reading barcodes from camera video input.
22
+
23
+
<divclass="blockquote-note"></div>
24
+
>
25
+
>- XCode 14.2 is used here in this guide.
26
+
>- You can download the complete Swift source code from [DecodeWithCameraEnhancer Sample](https://github.com/Dynamsoft/barcode-reader-mobile-samples/tree/main/ios/FoundationalAPISamples/DecodeWithCameraEnhancer){:target="_blank"}
27
+
>- DCE is used for camera capture in this guide below. If you use the iOS AVFoundation framework for camera capture, check [DecodeWithAVCaptureSession sample](https://github.com/Dynamsoft/barcode-reader-mobile-samples/tree/main/ios/FoundationalAPISamples/DecodeWithAVCaptureSession){:target="_blank"} on how to add barcode scanning to your app.
28
+
29
+
### Step 1: Create a New Project
30
+
31
+
1. Open Xcode and select create a new project.
32
+
33
+
2. Select **iOS > App** for your application.
34
+
35
+
3. Input your product name (DBRHelloworld), interface (StoryBoard) and select the language (Objective-C/Swift).
36
+
37
+
4. Click on the **Next** button and select the location to save the project.
38
+
39
+
5. Click on the **Create** button to finish.
40
+
41
+
### Step 2: Add the SDK
22
42
23
43
There are three ways to add the SDK into your project - **Manually**, via **CocoaPods**, or via **Swift Package Manager**.
24
44
25
-
### Option 1: Add the xcframeworks via Swift Package Manager
45
+
####Option 1: Add the xcframeworks via Swift Package Manager
26
46
27
47
1. In your Xcode project, go to **File --> AddPackages**.
28
48
@@ -32,7 +52,7 @@ There are three ways to add the SDK into your project - **Manually**, via **Coco
32
52
33
53
4. Check all the **xcframeworks** and add.
34
54
35
-
### Option 2: Add the Frameworks via CocoaPods
55
+
####Option 2: Add the Frameworks via CocoaPods
36
56
37
57
1. Add the frameworks in your **Podfile**, replace `TargetName` with your real target name.
38
58
@@ -53,7 +73,7 @@ There are three ways to add the SDK into your project - **Manually**, via **Coco
53
73
pod install
54
74
```
55
75
56
-
### Option 3: Add Local xcframeworks files
76
+
####Option 3: Add Local xcframeworks files
57
77
58
78
1. Download the SDK package from the <ahref="https://www.dynamsoft.com/barcode-reader/downloads/?utm_source=docs#mobile"target="_blank">Dynamsoft Website</a>. After unzipping, you can find the following **xcframeworks** under the **Dynamsoft\Frameworks** directory:
59
79
@@ -64,33 +84,7 @@ There are three ways to add the SDK into your project - **Manually**, via **Coco
64
84
65
85
3. Click on the project settings then go to **General –> Frameworks, Libraries, and Embedded Content**. Set the **Embed** field to **Embed & Sign** for all above **xcframeworks**.
66
86
67
-
## Build Your First Application
68
-
69
-
In this section, let's create a **HelloWorld** app for reading barcodes from camera video input.
70
-
71
-
<divclass="blockquote-note"></div>
72
-
>
73
-
>- XCode 14.2 is used here in this guide.
74
-
>- You can download the complete Swift source code from [DecodeWithCameraEnhancer Sample](https://github.com/Dynamsoft/barcode-reader-mobile-samples/tree/main/ios/FoundationalAPISamples/DecodeWithCameraEnhancer){:target="_blank"}
75
-
>- DCE is used for camera capture in this guide below. If you use the iOS AVFoundation framework for camera capture, check [DecodeWithAVCaptureSession sample](https://github.com/Dynamsoft/barcode-reader-mobile-samples/tree/main/ios/FoundationalAPISamples/DecodeWithAVCaptureSession){:target="_blank"} on how to add barcode scanning to your app.
76
-
77
-
### Create a New Project
78
-
79
-
1. Open Xcode and select create a new project.
80
-
81
-
2. Select **iOS > App** for your application.
82
-
83
-
3. Input your product name (DBRHelloworld), interface (StoryBoard) and select the language (Objective-C/Swift).
84
-
85
-
4. Click on the **Next** button and select the location to save the project.
86
-
87
-
5. Click on the **Create** button to finish.
88
-
89
-
### Include the Frameworks
90
-
91
-
Add the SDK to your new project. There are several ways to do this, all of which are explained in [this section](#add-the-sdk) for more details.
92
-
93
-
### Initialize the License
87
+
### Step 3: Initialize the License
94
88
95
89
Dynamsoft Barcode Reader needs a valid license to work.
96
90
@@ -102,12 +96,14 @@ Dynamsoft Barcode Reader needs a valid license to work.
@@ -149,62 +147,45 @@ Dynamsoft Barcode Reader needs a valid license to work.
149
147
>- You can request a 30-day trial license via the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=guide&package=ios){:target="_blank"} link.
150
148
>- If you download the <ahref="https://www.dynamsoft.com/barcode-reader/downloads/?utm_source=docs#mobile"target="_blank">Installation Package</a>, it comes with a 30-day trial license by default.
151
149
152
-
### Configure the Camera Enhancer
150
+
### Step 4: Configure the Camera Enhancer
153
151
154
-
1. Import all the headers that you will need in the `ViewController` file.
152
+
Initialize `CameraEnhancer` and `CameraView` and add configurations for the `CameraEnhancer`.
Now that all of the main functions are defined and configured, let's finish things off on the code side of things by completing the `viewDidLoad`, `viewWillAppear`, and `viewWillDisappear` functions.
Add **Privacy - Camera Usage Description** to the `info.plist` of your project to request camera permission. An easy way to do this is to access your project settings, go to *Info* and then add this Privacy property to the iOS target properties list.
380
361
381
-
### Additional Steps for iOS 12 or Lower Versions
362
+
### Step 8: Additional Steps for iOS 12 or Lower Versions
382
363
383
364
If your iOS version is less than 13, please add the following additional steps:
384
365
@@ -406,7 +387,7 @@ If your iOS version is less than 13, please add the following additional steps:
406
387
}
407
388
```
408
389
409
-
### (Optional) Manually Releasing Deep Learning Models
390
+
### Step 9: (Optional) Manually Releasing Deep Learning Models
410
391
411
392
Starting from v11.2.1000, Dynamsoft Barcode Reader integrates deep learning models to enhance decoding ability. Once initialized, these models remain cached in memory until they are explicitly released. If the decoding task has finished, call `clearDLModelBuffers` to free the associated memory.
412
393
@@ -417,7 +398,7 @@ Starting from v11.2.1000, Dynamsoft Barcode Reader integrates deep learning mode
417
398
>1.
418
399
```objc
419
400
- (void)dealloc {
420
-
[CaptureVisionRouter clearDLModelBuffers];
401
+
[DSCaptureVisionRouter clearDLModelBuffers];
421
402
}
422
403
```
423
404
2.
@@ -428,7 +409,7 @@ deinit
428
409
}
429
410
```
430
411
431
-
### Run the Project
412
+
### Step 10: Run the Project
432
413
433
414
1. Select the device that you want to run your app on. **Please note that you will require a physical device to run the application on.** If you run the app on a simulator, you will experience some errors at runtime as a physical camera component is required. *If you have an M1 Macbook (or a later model) you can run the app on your Macbook directly as it has the same architecture as your iPhone/iPad.*
434
415
2. Run the project, then your app will be installed on your device.
0 commit comments