Avatar ·

How to call Objective-C code from Swift: step-by-step guide

Hi everyone! I'm new to iOS development (learning Swift for about a month), and I've run into a problem. I'm working on a project where I need to use an old library written in Objective-C. I'm writing all the new logic in Swift, but I can't figure out how to properly call Objective-C code from Swift.\n\nI have an Objective-C class named `LegacyCalculator`, which is in the files `LegacyCalculator.h` and `LegacyCalculator.m`. Here's the example code:\n\n```objective-c\n// LegacyCalculator.h\n#import \n\n@interface LegacyCalculator : NSObject\n\n- (NSInteger)addNumber:(NSInteger)a toNumber:(NSInteger)b;\n- (NSString *)greetWithName:(NSString *)name;\n\n@end\n```\n\n```objective-c\n// LegacyCalculator.m\n#import "LegacyCalculator.h"\n\n@implementation LegacyCalculator\n\n- (NSInteg