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
+34-38Lines changed: 34 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,11 +18,33 @@ enableLanguageSelection: true
18
18
- Supported ABI: **arm64** and **x86_64**.
19
19
- Development Environment: Xcode 13 and above (Xcode 14.1+ recommended).
20
20
21
-
## Add the SDK
21
+
## Build Your First Application
22
+
23
+
In this section, let's create a **HelloWorld** app for reading barcodes from camera video input.
24
+
25
+
<divclass="blockquote-note"></div>
26
+
>
27
+
>- XCode 14.2 is used here in this guide.
28
+
>- 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"}
29
+
>- 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.
30
+
31
+
### Step 1: Create a New Project
32
+
33
+
1. Open Xcode and select create a new project.
34
+
35
+
2. Select **iOS > App** for your application.
36
+
37
+
3. Input your product name (DBRHelloworld), interface (StoryBoard) and select the language (Objective-C/Swift).
38
+
39
+
4. Click on the **Next** button and select the location to save the project.
40
+
41
+
5. Click on the **Create** button to finish.
42
+
43
+
### Step 2: Add the SDK
22
44
23
45
There are three ways to add the SDK into your project - **Manually**, via **CocoaPods**, or via **Swift Package Manager**.
24
46
25
-
### Option 1: Add the xcframeworks via Swift Package Manager
47
+
####Option 1: Add the xcframeworks via Swift Package Manager
26
48
27
49
1. In your Xcode project, go to **File --> AddPackages**.
28
50
@@ -32,7 +54,7 @@ There are three ways to add the SDK into your project - **Manually**, via **Coco
32
54
33
55
4. Check all the **xcframeworks** and add.
34
56
35
-
### Option 2: Add the Frameworks via CocoaPods
57
+
####Option 2: Add the Frameworks via CocoaPods
36
58
37
59
1. Add the frameworks in your **Podfile**, replace `TargetName` with your real target name.
38
60
@@ -53,7 +75,7 @@ There are three ways to add the SDK into your project - **Manually**, via **Coco
53
75
pod install
54
76
```
55
77
56
-
### Option 3: Add Local xcframeworks files
78
+
####Option 3: Add Local xcframeworks files
57
79
58
80
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
81
@@ -64,33 +86,7 @@ There are three ways to add the SDK into your project - **Manually**, via **Coco
64
86
65
87
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
88
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
89
+
### Step 3: Initialize the License
94
90
95
91
Dynamsoft Barcode Reader needs a valid license to work.
96
92
@@ -149,7 +145,7 @@ Dynamsoft Barcode Reader needs a valid license to work.
149
145
>- 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
146
>- 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
147
152
-
### Configure the Camera Enhancer
148
+
### Step 4: Configure the Camera Enhancer
153
149
154
150
1. Import all the headers that you will need in the `ViewController` file.
155
151
@@ -202,7 +198,7 @@ Dynamsoft Barcode Reader needs a valid license to work.
202
198
}
203
199
```
204
200
205
-
### Configure the Barcode Decoding Task via CaptureVisionRouter
201
+
### Step 5: Configure the Barcode Decoding Task via CaptureVisionRouter
206
202
207
203
1. Initialize the `CaptureVisionRouter` and bind with the `CameraEnhancer` instance.
208
204
@@ -310,7 +306,7 @@ Dynamsoft Barcode Reader needs a valid license to work.
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.
378
374
379
-
### Additional Steps for iOS 12 or Lower Versions
375
+
### Step 8: Additional Steps for iOS 12 or Lower Versions
380
376
381
377
If your iOS version is less than 13, please add the following additional steps:
382
378
@@ -404,7 +400,7 @@ If your iOS version is less than 13, please add the following additional steps:
404
400
}
405
401
```
406
402
407
-
### (Optional) Manually Releasing Deep Learning Models
403
+
### Step 9: (Optional) Manually Releasing Deep Learning Models
408
404
409
405
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.
410
406
@@ -426,7 +422,7 @@ deinit
426
422
}
427
423
```
428
424
429
-
### Run the Project
425
+
### Step 10: Run the Project
430
426
431
427
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.*
432
428
2. Run the project, then your app will be installed on your device.
0 commit comments