在全新安装Xcode 3.1.2时,我正在尝试使用iPhone MoviePlayer,如http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html#INITIATE_VIDEO_PLAYBACK_IN_MY_CODE
中的示例代码所示但是,当我尝试构建-n-go时,Xcode会报告以下链接器错误:
Building target “EOY” of project “EOY” with configuration “Debug” — (2 errors) cd /Users/ed/dev/EOY setenv MACOSX_DEPLOYMENT_TARGET 10.5 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk -L/Users/ed/dev/EOY/build/Debug-iphonesimulator -F/Users/ed/dev/EOY/build/Debug-iphonesimulator -filelist /Users/ed/dev/EOY/build/EOY.build/Debug-iphonesimulator/EOY.build/Objects-normal/i386/EOY.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/ed/dev/EOY/build/Debug-iphonesimulator/EOY.app/EOY Undefined symbols: ".objc_class_name_MPMoviePlayerController", referenced from: literal-pointer@__OBJC@__cls_refs@MPMoviePlayerController in MediaSupport.o "_MPMoviePlayerPlaybackDidFinishNotification", referenced from: _MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr in MediaSupport.o ld: symbol(s) not found collect2: ld returned 1 exit status ".objc_class_name_MPMoviePlayerController", referenced from: literal-pointer@__OBJC@__cls_refs@MPMoviePlayerController in MediaSupport.o "_MPMoviePlayerPlaybackDidFinishNotification", referenced from: _MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr in MediaSupport.o ld: symbol(s) not found collect2: ld returned 1 exit status Build failed (2 errors)
答案 0 :(得分:2)
这是对的。另一种方法是通过选择TARGETS-> Build Phases-> Link Binary with Libraries(这里添加MediaPlayer)将MediaPlayer添加到Project Target
答案 1 :(得分:1)
是的,如果你的代码调用了一个框架,你必须将该框架添加到你的目标并链接它。
确保框架是“相对于当前SDK”(选择框架>获取信息>常规选项卡),以便在为设备构建时,它链接设备的版本,而不是模拟器的。
答案 2 :(得分:0)
发现问题。我没有阅读所有文档,但有很多文档...
无论如何,我通过拖动目录
来解决这个问题 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/MediaPlayer.framework/
进入XCode中的Frameworks文件夹,然后在导入对话框中单击“确定”。