i want to write a Cocoa Touch Framework in Swift and want to use it in different projects. As far as everything works fine.
Now I would like to extend my framework with constants which I can use outside of the framework. My problem is that i can't use the constant from the Swift-Framework in my Objective-C project.
For example: MyFramework.swift
public struct Constants{
public static let constant = "myConstant"
}
and
public class MyClass : NSObject {
public func myFunc(){
doSomeThing
}
}
In a Swift-Project i can access everything (MyClass and Constants). So this i what i want to do in Swift and Objective-C:
import MyFramework
class ClassWithImport{
var xC = Constant.constant
}
But how can i make this in Objective-C?? At the moment i've in my MyFramework.h:
#import "MyFramework-Swift.h"
and this in the Class where I want to use the constants for example. After the import you can see i get access to MyClass, but i can't access the struct Constans.
#import <MyFramework.framework/Headers/MyFramework.h>
@implementation ClassWitheImport
- (void)funcOC
{
MyClass *test;
test.myFunc;
}
@end
Do I have to do that with the constants in a different way? The idea to make it this way, I came after I saw this link: Global constants file in Swift