Swift Framework & # 8596; Collaboration ObjC

I have a dylib framework with some UIView subclasses done in swift, which I made to use the new @IBDesignable and @IBInspectable .

So, let's say I have a subclass of UITextField called MyTextField.swift as follows:

MyTextField.swift

 @IBDesignable class MyTextField: UITextField { // some properties etc. // content is irrelevant } 

Now it compiles and works well in InterfaceBuilder, so good. But what I need to do is import this special subclass into my implementation of the Objective-C controller to set the property in the code at runtime.

The structure (named myViews ) has a header called myViews.h , which I can import into the controller header as follows:

MyViewController.h:

 @import myViews; #import <UIKit/UIKit.h> #import "myViews.h" @interface MyViewController : UIViewController @property(weak, nonatomic) IBOutlet MyTextField *txtName; // <-- This is the problem! @end 

That's where I am stuck! Thus, the MyTextField class MyTextField unknown from the imported headers. myViews.h was automatically generated. I tried to import the bridge headers there without success.

myViews.h:

 #import <UIKit/UIKit.h> //! Project version number for myViews. FOUNDATION_EXPORT double myViewsVersionNumber; //! Project version string for myViews. FOUNDATION_EXPORT const unsigned char myViewsVersionString[]; // In this header, you should import all the public headers of your framework // using statements like #import <myViews/PublicHeader.h> #import <myViews/MyTextField-Swift.h> // <-- This is what I've tried to import here which doesn't work as well. 

Hope someone can help me. Thanks in advance.

+5
source share
1 answer

In your objective-c class, try importing your quick module as follows:

#import "<ModuleName>-Swift.h"

Where ModuleName is the name of the module containing the fast code.

0
source

Source: https://habr.com/ru/post/1202254/


All Articles