How to import Swift code into an Objective-C project?
Hello everyone! I'm developing an app in Objective-C, but I want to gradually start transitioning to Swift. I've run into a problem: I can't figure out how to properly import Swift classes into Objective-C files.
I have a simple Swift class:
```swift
import Foundation
class MySwiftClass {
var name: String = "Swift"
func sayHello() -> String {
return "Hello from Swift!"
}
}
```
I want to use this class in my Objective-C controller:
```objc
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// How do I use MySwiftClass here?
MySwiftClass *swiftObj = [[MySwiftClass alloc] init];
NSLog(@"%@", [swiftObj sayHello]);
}
@end
```
Xcode gives an error