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

4

1 回答 1

9

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

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

确保为您的 .m 文件选择了 Target Membership

于 2012-05-29T00:42:42.877 回答