“i386架构的未定义符号”试图使用iCarousel

时间:2012-05-29 00:21:47

标签: ios xcode4

我正在尝试使用iCarousel(https://github.com/nicklockwood/iCarousel)并添加了iCarousel.h& iCarousel.m到我的项目(使用Xcode 4.3.1)。

但是我在尝试分配iCarousel的实例时遇到链接器错误(iCarousel继承自UIView):

self.carousel = [[iCarousel alloc]initWithFrame:self.view.bounds];

完整的链接器错误是:

Ld "/Users/Me/Library/Developer/Xcode/DerivedData/IMS-eyffphshuxtblseccxpfluamxudo/Build/Products/Debug-iphonesimulator/MyApp.app/MyApp" normal i386
cd /Users/Me/Desktop/IMS/3.2
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -L/Users/Me/Library/Developer/Xcode/DerivedData/IMS-eyffphshuxtblseccxpfluamxudo/Build/Products/Debug-iphonesimulator -F/Users/Me/Library/Developer/Xcode/DerivedData/IMS-eyffphshuxtblseccxpfluamxudo/Build/Products/Debug-iphonesimulator -filelist "/Users/Me/Library/Developer/Xcode/DerivedData/IMS-eyffphshuxtblseccxpfluamxudo/Build/Intermediates/IMS.build/Debug-iphonesimulator/MyApp.build/Objects-normal/i386/MyApp.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -framework AssetsLibrary -framework SystemConfiguration -framework MessageUI -framework EventKit -framework MapKit -framework QuartzCore -framework AddressBook -framework UIKit -framework Foundation -framework CoreGraphics -o "/Users/Me/Library/Developer/Xcode/DerivedData/IMS-eyffphshuxtblseccxpfluamxudo/Build/Products/Debug-iphonesimulator/MyApp.app/MyApp"

Undefined symbols for architecture i386:
"_OBJC_CLASS_$_iCarousel", referenced from:
objc-class-ref in IMSCarouselViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

有一些示例项目演示了iCarousel的使用,这些编译很好。我认为我的项目和示例项目之间必定存在一些构建设置差异,但我不知道它们可能是什么,也不知道如何查找。是否有任何技巧可以解密链接器消息以找出问题所在?

(我使用与示例项目中相同的框架/库)

TIA

1 个答案:

答案 0 :(得分:9)

即使你有.h& .m文件添加到您的项目中,听起来好像他们没有被编译。在File Inspector中选择iCarousel.m文件(在项目的左侧),然后在File Inspector中查看“Target Membership”设置。

它看起来像这样(只选择“iCarousel.m”,而不是“AppDelegate.m”):

Make sure Target Membership is selected for your .m file