【问题标题】:DDMathParser not working in Obj-C project using CocoaPodsDDMathParser 在使用 CocoaPods 的 Obj-C 项目中不起作用
【发布时间】:2015-10-15 12:55:46
【问题描述】:

我有一个带有 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

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

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

CocoaPods 文件:

pod 'AFNetworking'
pod 'DDMathParser'
use_frameworks!

【问题讨论】:

  • 请添加您的 Cocoapods 文件。
  • 还请描述“不起作用”的含义。它无法构建吗?如果是这样,构建失败是什么?它在运行时会失败吗?如果是这样,运行时错误是什么?等等。
  • 构建失败。看起来 DDMathParser 的类还没有导入

标签: objective-c xcode swift cocoapods ddmathparser


【解决方案1】:
pod 'DDMathParser'

这意味着您使用的是 DDMathParser 的 3.0 版,该版本最近用 Swift 重新编写,其中方法 numberByEvaluatingString 不存在。已重命名为evaluate

【讨论】:

  • 也不行。我认为从 CocoaPods 导入 DDMathParser 有问题,而不是使用它
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-01
  • 1970-01-01
  • 2015-02-22
  • 1970-01-01
相关资源
最近更新 更多