[Swift] I'd like to use the ZXingObjc library to generate a barcode! I have a question.

Asked 2 years ago, Updated 2 years ago, 86 views

ZXingObjc is a library available in Objective-C.

I heard that you have to do something called Bridge Header in order to use it on Swift.

I installed ZXingObjc as CocoaPods in Swift Project.

Is there anything I need to do to use that source code on Swift?

swift header bridge

2022-09-21 18:13

1 Answers

You may have solved it by yourself at this time, but I'm leaving an answer to help you.

If you installed it with CocoaPods, there are two ways.

If you used use_frameworks! as flag in Podfile first,

//Podfile
use_frameworks!
pod 'The corresponding framework'

You don't have to use Bridging-Header separately, but you can import it right away and use it.

// You use.swift
imported installed framework

Conversely, if you did not use use_frames! as flag in Podfile

//Podfile
pod 'The corresponding framework'

The framework must be imported into Bridging-Header before it can be used.

// App name-Bridging-Header
#import" corresponding framework.h"

Please feel free to let me know if there is anything wrong. :)


2022-09-21 18:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.