2015-10-15 33 views
0

我有一個使用CocoaPods的Obj-C項目。現在我需要使用用Swift編寫的DDMathParser。但無法正確導入DDMathParser。當我將新的Swift文件添加到項目中時,它工作正常。即使在我創建的swift文件中,DDMathParser也無法正常工作。這是我的一些代碼:DDMathParser不能在使用CocoaPods的Obj-C項目中工作

#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 

我必須做些什麼才能使它工作?

P.S.橋接頭創建和工作。在構建設置「模塊定義」設置爲YES

的CocoaPods文件:

pod 'AFNetworking' 
pod 'DDMathParser' 
use_frameworks! 
+0

請添加您的Cocoapods文件。 –

+0

請也描述「不起作用」的含義。它構建失敗嗎?如果是這樣,那麼構建失敗是什麼?它在運行時是否失敗?如果是這樣,那麼運行時錯誤是什麼?等 –

+0

它無法建立。看起來像DDMathParser的類尚未導入 – Rost

回答

1
pod 'DDMathParser' 

這意味着你使用DDMathParser,這是最近重新寫在斯威夫特的3.0版本,並在其中方法numberByEvaluatingString不存在。它更名爲evaluate

+0

它不起作用。我認爲從CocoaPods導入DDMathParser存在問題,而不是使用它 – Rost

相關問題