我正在尝试使用iCarousel (https://github.com/nicklockwood/iCarousel),并已将iCarousel.h & iCarousel.m添加到我的项目中(使用Xcode4.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的用法,这些项目可以很好地编译。我假设在我的项目和示例项目之间一定存在一些构建设置差异,但我不知道它们可能是什么,也不知道如何找出它们。有什么技巧可以破译链接器消息来找出问题所在吗?
(我使用的框架/库与示例项目中的相同)
提亚
发布于 2012-05-29 08:42:43
尽管您已经将.h & .m文件添加到您的项目中,但听起来它们并没有被编译。在文件检查器(位于项目左侧)中选择iCarousel.m文件,然后查看文件检查器中的"Target Membership“设置。
它看起来像这样(只有"iCarousel.m“会被选中,而不是"AppDelegate.m"):

https://stackoverflow.com/questions/10791735
复制相似问题