“Undefined symbols for architecture i386”尝试使用iCarousel

3

我正在尝试使用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个回答

9
尽管您已将.h和.m文件添加到项目中,但似乎它们没有被编译。在“文件检查器”(位于项目左侧)中选择iCarousel.m文件,然后查看“文件检查器”中的“目标成员资格”设置。
它应该是这样的(只选择了“iCarousel.m”,而不是“AppDelegate.m”):
如图所示,请确保为您的.m文件选择了目标成员资格。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接