Getting Error Receiver for class message is a forward declaration

前端 未结 1 2038
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 11:58

I\'m working on creating my own framework, I added objective c files and its working fine after that I needed to add some swift file after adding swift file xcode is not giving

1条回答
  •  别跟我提以往
    2021-02-05 12:33

    Finally I got solution. I did following changes. Here below is to do list in your Framework.

    Swift classes usage in Objective C classes

    • Use Open Keyword before class name in Swift
    • Use @objc Keyword before Open Keyword of Swift class
    • Import all header of objective c classes in Umbrella file YourProject.h those are consuming Swift Classes.
    • Use #import in Objective c

    I followed Apple's Mix and Match approach.

    Note: sometimes the file can not be imported into headers, but only into .m files. FYI, this file is created automatically by the compiler. If you search your project for it, you won't be able to find it, but if you ⌘ click on it (as a file imported in your code) in a file that is in your target, Xcode will (should) open it and show you all the Objective-C class interfaces for your Swift classes. To see the name for the Swift -> Objective-C module header, go to your target's Build Settings and search for $(SWIFT_MODULE_NAME)-Swift.h or simply -Swift.

    0 讨论(0)
提交回复
热议问题