How to Upgrade
From Version 9.x to 10.x
Dynamsoft Barcode Reader SDK has been refactored to integrate with DynamsoftCaptureVision (DCV)
architecture. To upgrade from version 9.x or earlier to 10.x, we recommend you to follow the User Guide and re-write your codes.
Update the Libraries
The Dynamsoft Barcode Reader SDK has been split into multiple libraries from the previous single library, and the dependency of the xcframeworks need to be updated.
Option 1: Add the xcframeworks via Swift Package Manager
-
In your Xcode project, go to File –> AddPackages.
-
In the top-right section of the window, search “https://github.com/Dynamsoft/barcode-reader-spm”
-
Select
barcode-reader-spm
, chooseUp to Next Major Version
, then click Add Package. -
Check all the xcframeworks and add.
Option 2: Add the Frameworks via CocoaPods
-
Add the frameworks in your Podfile, replace
TargetName
with your real target name.target 'ScanSingleBarcode' do use_frameworks! pod 'DynamsoftBarcodeReaderBundle','{version-number}' end
Note: Please view user guide for the correct version number.
-
Execute the pod command to install the frameworks and generate workspace([TargetName].xcworkspace):
pod install
Option 3: Add Local xcframeworks files
-
Download the SDK package from the Dynamsoft Website. After unzipping, you will find a collection of xcframework files under the Dynamsoft\Frameworks directory.
- 📄 DynamsoftBarcodeReaderBundle.xcframework
- 📄 DynamsoftCaptureVisionRouter.xcframework
- 📄 DynamsoftCameraEnhancer.xcframework
- 📄 DynamsoftBarcodeReader.xcframework
- 📄 DynamsoftCore.xcframework
- 📄 DynamsoftLicense.xcframework
- 📄 DynamsoftImageProcessing.xcframework
- 📄 DynamsoftUtility.xcframework
-
Drag and drop the xcframework files into your Xcode project. Make sure to check
Copy items if needed
andCreate groups
to copy the framework into your project’s folder. -
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.
Update the Template File
The template system is upgraded. The template you used for the previous version can’t be directly recognized by the new version. Please download the TemplateConverter tool or contact us to upgrade your template.
Update your code
You have 2 Options when updating your code.
- Update to New APIs with the foundational SDK
- Quick start a new project with BarcodeScanner Component
Option 1. Update to New APIs with the foundational SDK
Update the License Activation Code
Starting from 10.0, we have unified the API for setting licenses across different Dynamsoft products.
Old APIs | New APIs |
---|---|
BarcodeReader.initLicense |
DSLicenseManager.initLicense |
- Code in 9.x:
- Objective-C
- Swift
[DynamsoftBarcodeReader initLicense:@"YOUR-LICENSE-KEY" verificationDelegate:self]; - (void)DBRLicenseVerificationCallback:(bool)isSuccess error:(NSError *)error { // Add your code for license verification. }
DynamsoftBarcodeReader.initLicense("YOUR-LICENSE-KEY", verificationDelegate: self) func dbrLicenseVerificationCallback(_ isSuccess: Bool, error: Error?) { // Add your code for license verification. }
- Code in 10.x:
- Objective-C
- Swift
[DSLicenseManager initLicense:@"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" verificationDelegate:self]; - (void)onLicenseVerified:(BOOL)isSuccess error:(nullable NSError *)error { if (!isSuccess && error != nil) { NSLog(@"error: %@", error); } }
LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", verificationDelegate: self) func onLicenseVerified(_ isSuccess: Bool, error: Error?) { if !isSuccess { if let error = error { print("\(error.localizedDescription)") } } }
Update Single Image Decoding APIs
The APIs for decoding single image has been adjusted as follows:
Old APIs | New APIs |
---|---|
BarcodeReader.decodeFile |
DSCaptureVisionRouter.captureFromFile |
BarcodeReader.decodeFileInMemory |
DSCaptureVisionRouter.captureFromFileBytes |
BarcodeReader.decodeBuffer |
DSCaptureVisionRouter.captureFromBuffer |
BarcodeReader.decodeBufferedImage |
DSCaptureVisionRouter.captureFromImage |
class TextResult |
class BarcodeResultItem |
BarcodeReader.decodeBase64String |
Currently not available. |
Update Video Streaming Decoding APIs
The APIs for decoding video frames has been adjusted as follows:
Old APIs | New APIs |
---|---|
BarcodeReader.setImageSource |
DSCaptureVisionRouter.setInput |
BarcodeReader.startScanning |
DSCaptureVisionRouter.startCapturing |
BarcodeReader.stopScanning |
DSCaptureVisionRouter.stopCapturing |
BarcodeReader.setTextResultListener |
DSCaptureVisionRouter.addResultReceiver |
BarcodeReader.setIntermediateResultListener |
DSCaptureVisionRouter.IntermediateResultManager.addResultReceiver |
BarcodeReader.set/getMinImageReadingInterval |
SimplifiedCaptureVisionSettings.minImageCaptureInterval |
BarcodeReader.enableResultVerification |
DSMultiFrameResultCrossFilter.enableResultCrossVerification |
BarcodeReader.enableDuplicateFilter |
DSMultiFrameResultCrossFilter.enableResultDeduplication |
Protocol ImageSource |
Class DSImageSourceAdapter |
Protocol TextResultListener |
Protocol DSCapturedResultReceiver |
Protocol IntermediateResultListener |
Protocol DSIntermediateResultReceiver |
class TextResult |
class DSBarcodeResultItem |
Migrate Your Templates
The template-based APIs have been updated as follows:
Old APIs | New APIs |
---|---|
BarcodeReader.initRuntimeSettingsWithFile |
DSCaptureVisionRouter.initSettingsFromFile |
BarcodeReader.initRuntimeSettingsWithString |
DSCaptureVisionRouter.initSettings |
BarcodeReader.outputSettingsToFile |
DSCaptureVisionRouter.outputSettingsToFile |
BarcodeReader.outputSettingsToString |
DSCaptureVisionRouter.outputSettings |
BarcodeReader.resetRuntimeSettings |
DSCaptureVisionRouter.resetSettings |
BarcodeReader.appendTplFileToRuntimeSettings |
Not available. |
BarcodeReader.appendTplStringToRuntimeSettings |
Not available. |
Migrate Your PublicRuntimeSettings
The class PublicRuntimeSettings
has been refactored. It retains commonly used properties while removing the previously complex property settings, which are now exclusively supported through templates.
The APIs for accessing and updating PublicRuntimeSettings
has been adjusted as follows:
Old APIs | New APIs |
---|---|
BarcodeReader.getRuntimeSettings |
DSCaptureVisionRouter.getSimplifiedSettings |
BarcodeReader.updateRuntimeSettings |
DSCaptureVisionRouter.updateSettings |
Migrate to SimplifiedCaptureVisionSettings
The following properties are replaced by similar properties under DSSimplifiedCaptureVisionSettings
. They can also be set via a template file(String).
PublicRuntimeSettings Property | SimplifiedCaptureVisionSettings Property | Template File Parameter |
---|---|---|
region |
roi & roiMeasuredInPercentage |
TargetROIDef.Location.Offset |
timeout |
timeout |
CaptureVisionTemplates.Timeout |
Migrate to SimplifiedBarcodeReaderSettings
The following properties are replaced by similar properties under DSSimplifiedBarcodeReaderSettings
. The majority of them can also be set via a template file(String).
PublicRuntimeSettings Property | SimplifiedBarcodeReaderSettings Property | Template File Parameter |
---|---|---|
minBarcodeTextLength |
minBarcodeTextLength |
BarcodeFormatSpecification.BarcodeTextLengthRangeArray |
minResultConfidence |
minResultConfidence |
BarcodeFormatSpecification.MinResultConfidence |
localizationModes |
localizationModes |
BarcodeReaderTaskSetting.LocationModes |
expectedBarcodesCount |
expectedBarcodesCount |
BarcodeReaderTaskSetting.ExpectedBarcodesCount |
barcodeFormatIds |
barcodeFormatIds |
BarcodeReaderTaskSetting.BarcodeFormatIds |
barcodeFormatIds_2 |
barcodeFormatIds |
BarcodeReaderTaskSetting.BarcodeFormatIds |
deblurModes |
deblurModes |
BarcodeReaderTaskSetting.DeblurModes |
deblurLevel |
deblurModes |
BarcodeReaderTaskSetting.DeblurModes |
maxAlgorithmThreadCount |
maxThreadsInOneTask |
BarcodeReaderTaskSetting.MaxThreadsInOneTask |
Remarks:
- The 2 groups of barcode formats are merged.
DeblurLevel
is deprecated. You can useDeblurModes
instead.
FurtherModes Property | SimplifiedBarcodeReaderSettings Property | Template File Parameter |
---|---|---|
grayscaleTransformationModes |
grayscaleTransformationModes |
ImageParameter.GrayscaleTransformationModes |
imagePreprocessingModes |
grayscaleEnhancementModes |
ImageParameter.GrayscaleEnhancementModes |
scaleDownThreshold |
scaleDownThreshold |
ImageParameter.ScaleDownThreshold |
Remarks: The mode
IPM_MORPHOLOGY
ofimagePreprocessingModes
is migrated toBinarizationModes
. The mode argumentsMorphOperation
,MorphOperationKernelSizeX
,MorphOperationKernelSizeY
,MorphShape
are now available for all modes ofBinarizationModes
.
Migrate to Template File
The following properties can only be set via a template file. Please contact us so that we can help you to transform your current settings to a new template file.
PublicRuntimeSettings Property | Template File Parameter |
---|---|
binarizationModes |
ImageParameter.BinarizationModes |
textResultOrderModes |
BarcodeReaderTaskSetting.TextResultOrderModes |
returnBarcodeZoneClarity |
BarcodeReaderTaskSetting.ReturnBarcodeZoneClarity |
scaleUpModes |
ImageParameter.ScaleUpModes |
barcodeZoneMinDistanceToImageBorders |
BarcodeFormatSpecification.BarcodeZoneMinDistanceToImageBorders |
terminatePhase |
BarcodeReaderTaskSetting.TerminateSettings |
PublicRuntimeSettings.furtherModes Property | Template File Parameter |
---|---|
colourConversionModes |
ImageParameter.ColourConversionModes |
regionPredetectionModes |
ImageParameter.RegionPredetectionModes |
textureDetectionModes |
ImageParameter.TextureDetectionModes |
textFilterModes |
ImageParameter.TextDetectionMode & ImageParameter.IfEraseTextZone |
dpmCodeReadingModes |
BarcodeReaderTaskSetting.DPMCodeReadingModes |
deformationResistingModes |
BarcodeReaderTaskSetting.DeformationResistingModes |
barcodeComplementModes |
BarcodeReaderTaskSetting.BarcodeComplementModes |
barcodeColourModes |
BarcodeReaderTaskSetting.BarcodeColourModes |
Migrate to Other APIs
The Intermediate Result
system is redesigned and the following properties are deprecated.
PublicRuntimeSettings Property |
---|
intermediateResultTypes |
intermediateResultSavingMode |
Removed
The following properties are removed.
PublicRuntimeSettings Property |
---|
resultCoordinateType |
FurtherModes Property |
---|
colourClusteringModes |
Option 2. Quick start a new project with BarcodeScanner Component
BarcodeScanner
is a ready-to-use component that allows developers to quickly set up a barcode scanning app. With the built-in BarcodeScannerViewController
, it streamlines the integration of barcode scanning functionality into any application.