在混合的Objective-C / Swift库中找不到静态链接的swift模块

时间:2019-05-08 00:15:21

标签: ios objective-c swift xcode

我有一个项目,该项目在多个子项目中具有多个模块,我正在慢慢将其转换为swift和框架。现在,产品是静态链接的库。因此,可以说我有一个库A和一个库B。在B中依赖于A。在A中,我有一个基类Swift,即BaseView。在B中,我有一个扩展BaseView,SuperTerrificView的类。现在,为了在SuperTerrificView中使用BaseView,将其定义为public。为了在仍在Objective-C中的类中同时使用BaseView和SuperTerrificView,它们都标记为@objc。在实现SuperTerrificView时,我使用了@import ModuleA来导入BaseView库。最后,将SuperTerrificView get导入ModuleB中的CommonViewController中并在其中使用。问题出在为ModuleB生成的-Swift.h标头中。在为SuperTerrificView定义Objective-C接口时,它会添加一行@import ModuleA来导入BaseView,并且编译器将引发找不到ModuleA的错误。

问题是,如何告诉Objective-C编译器在哪里可以找到ModuleA?

库ModuleA

BaseView.swift-

@import UIKit
@objc public class BaseView : UIView {
}

库模块B

SuperTerrificView.swift-

@import UIKit
@import ModuleA
@objc public class SuperTerrificView: BaseView {
}

CommonViewControllerC.h-

#import <UIKit/UIKit.h>

@interface CommonViewControllerC : UIViewController {
}
@end

CommonViewController.h-

#import "CommonViewControllerC.h"
#import "ModuleA-Swift.h"
#import "ModuleB-Swift.h" //<---- error in the header, ModuleB not found

@implementation CommonViewControllerC 

@end

ModuleB-Swift.h ---

...
@import CoreGraphics;
@import ModuleA; //<--- error here
@import ObjectiveC;
...

当前,我的解决方法是禁用C和Objective-C模块,但这似乎是不必要的。

0 个答案:

没有答案
相关问题