Skip to content

Commit f055377

Browse files
Updating guides
1 parent 1967576 commit f055377

2 files changed

Lines changed: 171 additions & 187 deletions

File tree

programming/objectivec-swift/foundational-guide.md

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,33 @@ enableLanguageSelection: true
1818
- Supported ABI: **arm64** and **x86_64**.
1919
- Development Environment: Xcode 13 and above (Xcode 14.1+ recommended).
2020

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+
<div class="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
2244

2345
There are three ways to add the SDK into your project - **Manually**, via **CocoaPods**, or via **Swift Package Manager**.
2446

25-
### Option 1: Add the xcframeworks via Swift Package Manager
47+
#### Option 1: Add the xcframeworks via Swift Package Manager
2648

2749
1. In your Xcode project, go to **File --> AddPackages**.
2850

@@ -32,7 +54,7 @@ There are three ways to add the SDK into your project - **Manually**, via **Coco
3254

3355
4. Check all the **xcframeworks** and add.
3456

35-
### Option 2: Add the Frameworks via CocoaPods
57+
#### Option 2: Add the Frameworks via CocoaPods
3658

3759
1. Add the frameworks in your **Podfile**, replace `TargetName` with your real target name.
3860

@@ -53,7 +75,7 @@ There are three ways to add the SDK into your project - **Manually**, via **Coco
5375
pod install
5476
```
5577

56-
### Option 3: Add Local xcframeworks files
78+
#### Option 3: Add Local xcframeworks files
5779

5880
1. Download the SDK package from the <a href="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:
5981

@@ -64,33 +86,7 @@ There are three ways to add the SDK into your project - **Manually**, via **Coco
6486

6587
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**.
6688

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-
<div class="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
9490

9591
Dynamsoft Barcode Reader needs a valid license to work.
9692

@@ -149,7 +145,7 @@ Dynamsoft Barcode Reader needs a valid license to work.
149145
>- 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.
150146
>- If you download the <a href="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.
151147
152-
### Configure the Camera Enhancer
148+
### Step 4: Configure the Camera Enhancer
153149

154150
1. Import all the headers that you will need in the `ViewController` file.
155151

@@ -202,7 +198,7 @@ Dynamsoft Barcode Reader needs a valid license to work.
202198
}
203199
```
204200

205-
### Configure the Barcode Decoding Task via CaptureVisionRouter
201+
### Step 5: Configure the Barcode Decoding Task via CaptureVisionRouter
206202

207203
1. Initialize the `CaptureVisionRouter` and bind with the `CameraEnhancer` instance.
208204

@@ -310,7 +306,7 @@ Dynamsoft Barcode Reader needs a valid license to work.
310306
}
311307
```
312308

313-
### Configure viewDidLoad, viewWillAppear, viewWillDisappear
309+
### Step 6: Configure viewDidLoad, viewWillAppear, viewWillDisappear
314310

315311
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.
316312

@@ -372,11 +368,11 @@ override func viewWillDisappear(_ animated: Bool) {
372368
...
373369
```
374370

375-
### Configure Camera Permissions
371+
### Step 7: Configure Camera Permissions
376372

377373
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.
378374

379-
### Additional Steps for iOS 12 or Lower Versions
375+
### Step 8: Additional Steps for iOS 12 or Lower Versions
380376

381377
If your iOS version is less than 13, please add the following additional steps:
382378

@@ -404,7 +400,7 @@ If your iOS version is less than 13, please add the following additional steps:
404400
}
405401
```
406402

407-
### (Optional) Manually Releasing Deep Learning Models
403+
### Step 9: (Optional) Manually Releasing Deep Learning Models
408404

409405
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.
410406

@@ -426,7 +422,7 @@ deinit
426422
}
427423
```
428424

429-
### Run the Project
425+
### Step 10: Run the Project
430426

431427
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.*
432428
2. Run the project, then your app will be installed on your device.

0 commit comments

Comments
 (0)