2
votes

On a fresh install of Xcode 3.1.2, I'm trying to use the iPhone MoviePlayer as shown in the sample code at http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html#INITIATE_VIDEO_PLAYBACK_IN_MY_CODE

However, Xcode reports the following linker errors when I try to build-n-go:

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)
3

3 Answers

2
votes

that is right. Another way to do it is by adding the MediaPlayer to the Project Target by selecting TARGETS->Build Phases->Link Binary with Libraries (here add MediaPlayer)

1
votes

Yes, if your code calls into a framework, you have to add that framework to your target and link against it.

Make sure the framework is "Relative to Current SDK" (select the framework > Get Info > General tab) so that when you build for the device, it links against the device's version, not the simulator's.

0
votes

Found the problem. I haven't read all the docs, but there are a lot of them...

Anyway, I fixed this by dragging the directory

/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/MediaPlayer.framework/

into the Frameworks folder in XCode and clicking OK on the import dialog.