2017-08-17 120 views
1

我有兩個目標爲手錶操作系統和不帶手錶。 我必須輸入briding header as。消息util已被添加到兩個目標。但它給編譯器錯誤在多個目標之間導入不同的橋接標頭

「使用未聲明的標識符MessageUtil」。

#import "SomeClass.h" 

#ifdef TARGET_OS_WATCH 
#import "Watch-Header.h" 
#import "With_Watch-Swift.h" 
#elif TARGET_OS_IOS 
#import "Without_Watch-Header.h" 
#import "Without_Watch-Swift.h" 
#endif 

@implementation SomeClass 

-(id)init { 
    self = [super init]; 
    if(self) { 
     self.message = [MessageUtil messageOne];//MessageUtil is swift class. 
    } 
    return self; } 

@end 
+0

什麼設置爲'SomeClass'的目標是什麼? – nayem

+0

ComeClass有多個目標。 – boom

+0

嘗試從'#ifdef'到'#endif'中刪除所有內容,並導入''WithUWatch-Swift.h''和''Without_Watch-Swift''中的'MessageUtil'所在的任何一個。 – nayem

回答

0

您可以創建其他目標額外​​,然後只需在Build Settings -> Objective-C Bridging Header指定新創建的橋接報頭位置。

enter image description here

相關問題