Earthling
Earthling

Reputation: 293

iOS Framework - Use of undeclared identifier

I am currently trying to create my own custom iOS framework using Swift 2.3. I have a test iOS app, written in Obj-C, and it embeds + links to the custom framework.

The framework has multiple classes, two of them resembling the below:

public class Constants: NSObject
{
    private static let sharedInstance = Constants()

    override init() { }

    public static let CONST_VALUE1 = "somevalue1"

    public static let CONST_VALUE2 = "somevalue2"
}

and

public class RandomUtils: NSObject
{
    private static let sharedInstance = RandomUtils()

    override init() { }

    public static func randomFunction(someValue: String) -> String?
    {
        return someValue
    }
}

The RandomUtils class has no problems being seen and used in the test app. The Constants class however, cannot seem to be found, despite it being referenced to in the SDK-Swift.h header:

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

In my test app, I am importing the framework umbrella header file in my ViewController's header file as such:

#import <UIKit/UIKit.h>

#import <SDK/SDK-Swift.h>

@interface TestVC : UIViewController

@property (weak, nonatomic) IBOutlet UITextField *txtValue1;

@end

Attempts to use the Constants class

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

result in this error message

Use of undeclared identifier 'Constants'

Does anyone have any idea what I could be doing wrong?

Upvotes: 0

Views: 1331

Answers (1)

Earthling
Earthling

Reputation: 293

After some trial and error, I resolved the issue by placing the .framework directly into the test app folder.

Upvotes: 1

Related Questions