iOS OC call Swift

It takes four steps to call Swift from iOS OC

first step

Build Settings->Defines Module is set to YES

MOdule Name Configure project name

Second step

Drag swift into the project, you will be prompted whether to create a bridge file, select Create

Non-drag-in, there is no prompt to manually create and select the header file

Name XXXX-Bridging-Header [XXXX represents the name of the project]

third step

Build Settings->Bridging

Drag the bridge file into the path

the fourth step

Build Settings-> Swift Language Version select the version (the version depends on which version of swift you are)

Introduce in classes that need to use Swift methods

#import “XXXX-Swift.h" [XXXX represents the project name]

Welcome to follow the official account [Swift Community]:

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_36478920/article/details/102610946