Como importar código Swift em um projeto Objective-C?
Olá a todos! Estou desenvolvendo um aplicativo em Objective-C, mas quero começar a migrar gradualmente para Swift. Encontrei um problema: não consigo entender como importar corretamente classes Swift para arquivos Objective-C.
Eu tenho uma classe Swift simples:
```swift
import Foundation
class MySwiftClass {
var name: String = "Swift"
func sayHello() -> String {
return "Hello from Swift!"
}
}
```
Quero usar essa classe no meu controller Objective-C:
```objc
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Como eu uso MySwiftClass aqui?
MySwiftClass *swiftObj = [[MySwiftClass alloc] init];
NSLog(@"%@", [swiftObj sayHello]);
}
@end
```
O Xcode exibe o erro "Use of undeclared identifier 'MySwiftClass'". Já adicionei o arquivo Swift ao projeto, mas nada funciona. Tentei pesquisar no Google, mas as dicas são dispersas. Por favor, me digam o que estou fazendo de errado e como