0

我有一个带有 CocoaPods 的 Obj-C 项目。现在我需要使用 Swift 编写的 DDMathParser。但无法正确导入 DDMathParser。当我将新的 Swift 文件添加到项目中时,它工作正常。即使在我创建的 swift 文件中,DDMathParser 也无法正常工作。这是我的一些代码:

#import "ViewController.h"
#import "test-Swift.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    SwiftTest *test = [[SwiftTest alloc] init];
    [test run];

    NSLog(@"%@", [@"5 + 5" numberByEvaluatingString]);

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

我必须做什么才能让它发挥作用?

PS 桥接头已创建并正常工作。在构建设置“定义模块”设置为 YES

CocoaPods 文件:

pod 'AFNetworking'
pod 'DDMathParser'
use_frameworks!
4

1 回答 1

1
pod 'DDMathParser'

这意味着您正在使用 3.0 版的 DDMathParser,它最近用 Swift 重新编写,并且其中numberByEvaluatingString不存在该方法。它被重命名为evaluate.

于 2015-10-17T00:54:25.873 回答