iOS框架 - 使用未确定的标识符



我当前正在尝试使用Swift 2.3创建自己的自定义iOS框架。我有一个用OBJ-C编写的测试iOS应用程序,并嵌入 链接到自定义框架。

该框架有多个类,其中两个类似于以下:

public class Constants: NSObject
{
    private static let sharedInstance = Constants()
    override init() { }
    public static let CONST_VALUE1 = "somevalue1"
    public static let CONST_VALUE2 = "somevalue2"
}

public class RandomUtils: NSObject
{
    private static let sharedInstance = RandomUtils()
    override init() { }
    public static func randomFunction(someValue: String) -> String?
    {
        return someValue
    }
}

在测试应用程序中,随机类别的类别没有问题和使用。然而,尽管在SDK-SWIFT.H标题中引用了常数类,但似乎找不到它:

SWIFT_CLASS("_TtC6sdk9Constants")
@interface Constants : NSObject
+ (NSString * _Nonnull)CONST_VALUE1;
+ (NSString * _Nonnull)CONST_VALUE2;
@end
SWIFT_CLASS("_TtC6sdk16RandomUtils")
@interface RandomUtils : NSObject
+ (NSString * _Nonnull)randomFunction:(NSString * _Nonnull)someValue;
@end

在我的测试应用程序中,我正在在ViewController的标头文件中导入框架雨伞标头文件:

#import <UIKit/UIKit.h>
#import <SDK/SDK-Swift.h>
@interface TestVC : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *txtValue1;
@end

尝试使用常数类

NSLog(@"%@", [Constants CONST_VALUE1]);

导致此错误消息

Use of undeclared identifier 'Constants'

有人知道我做错了什么吗?

经过一定的反复试验,我通过将.framework直接放入测试应用程序文件夹解决了问题。

最新更新