how to use Objective-C project in my Swift project

后端 未结 3 1224
闹比i
闹比i 2021-02-08 15:50

Note: I know How to call Objective-C code from Swift, but I don\'t know below,

I want to use this EsptouchForIOS\'s Demo in my project. The demo is write in OC, it has a

3条回答
  •  青春惊慌失措
    2021-02-08 16:48

    So according to your question, you have added an objective C bridge in your swift project using How to call Objective-C code from Swift.

    Now, import all headers (.h) files of your objective-c source code (demo project) that you want to direct use in swift file.

    For example, your demo project has EsptouchForIOS following header (file with extension .h) files in project source code.

    ESPAppDelegate.h, ESPDataCode.h, ESPTouchDelegate.h

    import a header file in your bridge, which you want to use in your swift code. Suppose in your swift code you want touch delegate ESPTouchDelegate then write,

    #import "ESPTouchDelegate.h"
    

    Here is snapshot of your demo integration in my Test Swift project with bridge

    and import statements.

    Now, there is function/method in an objective C file getValue

    which is used/accessed in swift project/file.

    Similarly, you can import as many files (source headers) as you want in bridge and use the same files (source code) in swift.

提交回复
热议问题