2013-07-17 36 views
0

我正在研究比Xcode提供的更高級的CLLocationManager模擬,並且遇到了一個奇怪的問題。我有子類都CLLocationManagerCLLocationOSL上的CLLocation子類化

// foobar.h 
@interface MyLocation : CLLocation 
@end 

@interface MyLocationManager : CLLocationManager 
@end 

// foobar.m 
@implementation MyLocation 
@end 

@implementation MyLocationManager 
@end 

現在,如果我建立適用於iOS的一切項目是好的,但是當我的OS X做的一樣,我在聯得到這個錯誤:

Undefined symbols for architecture x86_64: 
    "_OBJC_METACLASS_$_CLLocation", referenced from: 
     _OBJC_METACLASS_$_MyLocation in AppDelegate.o 
    "_OBJC_METACLASS_$_CLLocationManager", referenced from: 
     _OBJC_METACLASS_$_MyLocationManager in AppDelegate.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

與此問題Error on CLLocation subclassing不同的是,我確實已經將正確的框架添加到項目中,並且正如我所說的,該設置完美地構建在iOS上,而不是爲OSX構建。

FWIW,我在iOS SDK 6.1和OSX SDK 10.8中使用Xcode 4.6.3,爲x86_64構建默認LLVM 4.2。

任何線索爲什麼會發生這種情況?

+0

我嘗試了與Xcode5 DP3和OSX SDK 10.9相同,不同之處在於它會在啓動後使用:dyld:Symbol not found:_OBJC_METACLASS _ $ _ CLLocation'進行編譯但崩潰。這很有趣:P – Lvsti

回答

0

鏈接器錯誤與框架有關。忘記在某處導入框架或將Core Location框架添加到OS X目標中。如果它適用於一個而不是另一個,那麼聽起來這兩個目標的設置是不同的。

仔細檢查。清理構建。重新啓動Xcode。

+0

我從零開始創建了一個Cocoa應用程序項目,除了將上面的代碼粘貼到appdelegate的.h和.m之外,PLUS將CoreLocation框架添加到了目標中。仍然沒有運氣。 – Lvsti

+0

大概是用'#import ' –

+0

是的,忘了把它加到我的評論中 – Lvsti