Linker error when trying to use MPMoviePlayer - iphone

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)

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)

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.

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.

Related

HessianKit linking failure

I am trying to link HessianKit with a simple Xcode iOS test project.
I tried different build configurations.
I added the -ObjC switch to both the linker command line for the library project and for my main project.
This is the command line from the main project:
Ld /Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Products/Debug-iphonesimulator/MatthiasSimpleTest.app/MatthiasSimpleTest normal i386
cd /Users/wuttke/Documents/MatthiasSimpleTest
setenv MACOSX_DEPLOYMENT_TARGET 10.6
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/clang -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Products/Debug-iphonesimulator -L/Users/wuttke/Documents/MatthiasSimpleTest/MatthiasSimpleTest -L/Users/wuttke/Documents/MatthiasSimpleTest -F/Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Products/Debug-iphonesimulator -F/Users/wuttke/Documents/MatthiasSimpleTest -filelist /Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Intermediates/MatthiasSimpleTest.build/Debug-iphonesimulator/MatthiasSimpleTest.build/Objects-normal/i386/MatthiasSimpleTest.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework UIKit -framework Foundation -framework CoreGraphics -framework HessianKit -o /Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Products/Debug-iphonesimulator/MatthiasSimpleTest.app/MatthiasSimpleTest
This the error message from the linker:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CWHessianConnection", referenced from:
objc-class-ref in MainWindowController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I attached a screenshot showing the project (it contains the HessianKit.framework, we build for i386/MacOS, iOS 5.0).
This is some output showing the contents of the library to be linked:
Tobiass-MacBook-Pro:HessianKit.framework wuttke$ pwd
/Users/wuttke/Documents/MatthiasSimpleTest/HessianKit.framework
Tobiass-MacBook-Pro:HessianKit.framework wuttke$ ls
Headers HessianKit Resources Versions
Tobiass-MacBook-Pro:HessianKit.framework wuttke$ nm -arch i386 HessianKit | grep CWHessianConnection
000010a0 t +[CWHessianConnection proxyWithURL:protocol:]
00001020 t -[CWHessianConnection initWithHessianVersion:]
000011a0 t -[CWHessianConnection proxyWithURL:protocol:]
00001260 t -[CWHessianConnection setVersion:]
00001240 t -[CWHessianConnection version]
0000d000 S .objc_class_name_CWHessianConnection
I found the suggestion to try to include the HessianKit files directly with the project. This gives compile errors because of the ARC.
Have you got any suggestions I could try? Thanks a lot in advance.
Matthias
I am very new to Xcode and was able to solve this issue. I was trying to use HessianKit in a project I'm developing.
The solution to the problem is described in this post: https://stackoverflow.com/a/7866167/1366367
Apparently the iPhone simulator requires libraries to built for the i386 architecture not armv7.
This worked for me:
Open Project HessianKit (downloaded from sourceforge)
Set Base SDK on HessianKit target to iphonesimulator
Clear Base SDK for StaticHessianKit target (should default to iphonesimulator)
Run Build
Find libStaticHessianKit.a in ~/Library/Developer/Xcode/DerivedData/*/Build/Products/Debug-iphonesimulator folder
Drag libStaticHessianKit.a into your project. This should automatically set up library search paths.
Drag HessianKit framework folder to your project as well.
Make sure you import this where you are using HessianKit:
#import <HessianKit/HessianKit.h>
Good luck.

iPhone voice recognition "Vocalkit by KingOFBrian" compile error

i'm using last version of VocalKit for iPhone https://github.com/KingOfBrian/VocalKit
I followed all instructions to add in new project as specified on github,
but on compile time i getting these errors:
Ld build/Debug-iphonesimulator/Voice.app/Voice normal i386
cd /Users/asd/Desktop/Voice
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer-old/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer-old/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer-old/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer-old/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/asd/Desktop/Voice/build/Debug-iphonesimulator -F/Users/asd/Desktop/Voice/build/Debug-iphonesimulator -filelist /Users/asd/Desktop/Voice/build/Voice.build/Debug-iphonesimulator/Voice.build/Objects-normal/i386/Voice.LinkFileList -mmacosx-version-min=10.6 -all_load -ObjC -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics "/Users/asd/Downloads/KingOfBrian-VocalKit-a25e5f3 2/build/Debug-iphonesimulator/libVocalKit.a" -framework AudioToolbox -liconv -o /Users/asd/Desktop/Voice/build/Debug-iphonesimulator/Voice.app/Voice
Undefined symbols:
"_ssymm_", referenced from:
_matrixmultiply in libVocalKit.a(matrix.o)
"_spotrf_", referenced from:
_determinant in libVocalKit.a(matrix.o)
"_sposv_", referenced from:
_invert in libVocalKit.a(matrix.o)
_solve in libVocalKit.a(matrix.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
what can i do?
What's the cause of these problems?
I tried to import in xcode3 and xcode4, but it's the same.
My sdk version is 4.3.
thanks.
from the readme file on the github page...
I no longer advise using VocalKit, as a much better project, Open Ears has come out. http://www.politepix.com/openears/
Maybe check out openears?
Thanks all,
but I solved using google chrome speech.
Speech recognition framework for iOS that supports Spanish
Using chromium src: src.chromium.org/viewvc/chrome/trunk/src/content/browser/speech/

Strange error in Apple Core Data tutorial

I was doing the Apple Core Data Tutorial, and on the first occasion I was suggested to build the project, I got this error:
Ld /Users/user/Library/Developer/Xcode/DerivedData/Locations-fajvunxiruohofbhzimrgekrpnqh/Build/Products/Debug-iphonesimulator/Locations.app/Locations normal i386
cd "/Users/user/Documents/xcode projects/Locations"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
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/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/user/Library/Developer/Xcode/DerivedData/Locations-fajvunxiruohofbhzimrgekrpnqh/Build/Products/Debug-iphonesimulator -F/Users/user/Library/Developer/Xcode/DerivedData/Locations-fajvunxiruohofbhzimrgekrpnqh/Build/Products/Debug-iphonesimulator -filelist /Users/user/Library/Developer/Xcode/DerivedData/Locations-fajvunxiruohofbhzimrgekrpnqh/Build/Intermediates/Locations.build/Debug-iphonesimulator/Locations.build/Objects-normal/i386/Locations.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework UIKit -framework Foundation -framework CoreGraphics -framework CoreData -o /Users/user/Library/Developer/Xcode/DerivedData/Locations-fajvunxiruohofbhzimrgekrpnqh/Build/Products/Debug-iphonesimulator/Locations.app/Locations
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CLLocationManager", referenced from:
objc-class-ref in RootViewController.o
"_kCLLocationAccuracyNearestTenMeters", referenced from:
-[RootViewController locationManager] in RootViewController.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
I use XCode 4.0.2, Mac OS X 10.6.8. What can be the cause of this? I followed the tutorial step-by-step and have absolutely no idea what could go wrong.
You need to import the CoreLocation framework. This can be done by going to the Project - Build Phases - Link Binary with Libraries
Looks like you need to add the CoreLocation framework to the linked frameworks of the project.
In the project settings, select the application target and under "Build Phases" add it to the "Link Binary With Libraries" step.
When you started the project did you select "Use Core Data For Storage"? I think it adds a framework you need.
click on your project in the navigation pane (apple + 1)
targets -> your project-> build phases -> link binaries with libraries -> +
then select CoreData.framework and add.
Sometimes the .m file is dropped out of the 'Compiled sources' list in XCode. You need to add the .m file manually:
Build phases > Compiled sources > (check for if your .m file is indeed missing) > Add .m file > Build

GameKit / GameCenter - I386

I'm having some hard time with the iOS GameCenter
I'm following some tutorials on youtube
but as soon as I finish the code I get this error:
Ld /Users/fgringo/Library/Developer/Xcode/DerivedData/Game-Center-Test-aggpqkxrazgvnseohuityqvchrnm/Build/Products/Debug-iphonesimulator/Game-Center-Test.app/Game-Center-Test normal i386
cd /Users/fgringo/Documents/DEVELOPER/Game-Center-Test
setenv MACOSX_DEPLOYMENT_TARGET 10.6
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/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/fgringo/Library/Developer/Xcode/DerivedData/Game-Center-Test-aggpqkxrazgvnseohuityqvchrnm/Build/Products/Debug-iphonesimulator -F/Users/fgringo/Library/Developer/Xcode/DerivedData/Game-Center-Test-aggpqkxrazgvnseohuityqvchrnm/Build/Products/Debug-iphonesimulator -F/Users/fgringo/Documents/DEVELOPER/Game-Center-Test -filelist /Users/fgringo/Library/Developer/Xcode/DerivedData/Game-Center-Test-aggpqkxrazgvnseohuityqvchrnm/Build/Intermediates/Game-Center-Test.build/Debug-iphonesimulator/Game-Center-Test.build/Objects-normal/i386/Game-Center-Test.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework UIKit -framework Foundation -framework CoreGraphics -framework GameKit -framework MediaPlayer -o /Users/fgringo/Library/Developer/Xcode/DerivedData/Game-Center-Test-aggpqkxrazgvnseohuityqvchrnm/Build/Products/Debug-iphonesimulator/Game-Center-Test.app/Game-Center-Test
ld: warning: ignoring file /Users/fgringo/Documents/DEVELOPER/Game-Center-Test/GameKit.framework/GameKit, missing required architecture i386 in file
ld: warning: ignoring file /Users/fgringo/Documents/DEVELOPER/Game-Center-Test/MediaPlayer.framework/MediaPlayer, missing required architecture i386 in file
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_GKLocalPlayer", referenced from:
objc-class-ref in GameCenterManager.o
"_OBJC_CLASS_$_GKLeaderboard", referenced from:
objc-class-ref in GameCenterManager.o
"_OBJC_CLASS_$_GKScore", referenced from:
objc-class-ref in GameCenterManager.o
"_OBJC_CLASS_$_GKAchievement", referenced from:
objc-class-ref in GameCenterManager.o
"_OBJC_CLASS_$_GKPlayer", referenced from:
objc-class-ref in GameCenterManager.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
It looks like you haven't added the GameKit framework to your project.
If your using Xcode 3.2.x:
Right click the Frameworks group/folder in the file tree (on the left of the xcode window)
Press Add, and then select Existing Frameworks...
Scroll to GameKit.framework and double click it
If your using Xcode 4:
In the file tree, click on the project (the item at the top)
Select your target
Go to the Build Phases tab on the main panel
Expand the Link Binary with Libraries
Press the + button
Scroll to the GameKit.framework and double click it.
Did you add the GameKit.framework to your project?

stuck on current location - iphone sdk

I'm trying to get the current location using the iphone sdk. Here is the code:
http://pastie.org/572062
here is the error on build:
Building target “Send2iPhone” of project “Send2iPhone” with configuration “Release” — (2 errors)
cd /Users/pswenson/dev/send2iphone/iphone_code/Send2iPhone
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.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk -L/Users/pswenson/dev/send2iphone/iphone_code/Send2iPhone/build/Release-iphonesimulator -F/Users/pswenson/dev/send2iphone/iphone_code/Send2iPhone/build/Release-iphonesimulator -filelist /Users/pswenson/dev/send2iphone/iphone_code/Send2iPhone/build/Send2iPhone.build/Release-iphonesimulator/Send2iPhone.build/Objects-normal/i386/Send2iPhone.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/pswenson/dev/send2iphone/iphone_code/Send2iPhone/build/Release-iphonesimulator/Send2iPhone.app/Send2iPhone
Undefined symbols:
".objc_class_name_CLLocationManager", referenced from:
literal-pointer#__OBJC#__cls_refs#CLLocationManager in DetailViewController.o
"_kCLLocationAccuracyNearestTenMeters", referenced from:
_kCLLocationAccuracyNearestTenMeters$non_lazy_ptr in DetailViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
".objc_class_name_CLLocationManager", referenced from:
literal-pointer#__OBJC#__cls_refs#CLLocationManager in DetailViewController.o
"_kCLLocationAccuracyNearestTenMeters", referenced from:
_kCLLocationAccuracyNearestTenMeters$non_lazy_ptr in DetailViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Build failed (2 errors)
I'm clueless.... any ideas?
Have you added the CoreLocation library to your project? Looks like your having problems linking, which usually means you don't have all the libraries your project needs.