Using GDataXMLDocument in iPad app - iphone

I'm trying to use GDataXML library in my ipad application. I followed by instructions:
Download the gdata-objective-c client library.
Unzip the file, navigate to Source\XMLSupport, and drag the two files GDataXMLNode.h and GDataXMLNode.m into your project
In XCode, click Project\Edit Project Settings and make sure “All Configurations” are checked.
Find the Search Paths\Header Search Paths setting and add /usr/include/libxml2 to the list.
Finally, find the Linking\Other Linker Flags section and add -lxml2 to the list.
If in code i add #import "GDataXMLNode.h", all is fine. But when i try to use GDataXMLDocument class in my app
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData options:0 error:nil];
I received the following message:
Ld build/Debug-iphonesimulator/DemoApp.app/DemoApp normal i386
cd /Users/svp/Projects/DemoApp
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/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -L/Users/svp/Projects/DemoApp/build/Debug-iphonesimulator -F/Users/svp/Projects/DemoApp/build/Debug-iphonesimulator -filelist /Users/svp/Projects/DemoApp/build/DemoApp.build/Debug-iphonesimulator/DemoApp.build/Objects-normal/i386/DemoApp.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -framework MapKit -framework QuartzCore -lxml2.2 -o /Users/svp/Projects/DemoApp/build/Debug-iphonesimulator/DemoApp.app/DemoApp
Undefined symbols:
"_OBJC_CLASS_$_GDataXMLDocument", referenced from:
objc-class-ref-to-GDataXMLDocument in TwitterService.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Any thoughts?

It sounds like the GDataXMLNode.m code isn't being linked in. Is that source file really added to the target being built in Xcode?

Best thing is to leave the source code untouched and tell your project not to apply the ARC mechanism to this file.
To do so:
1- Select the build phases of your projet
2- Select the GDataXMLNode.m file
3- Add the switch: -fno-objc-arc to this file alone (by double clicking on it)
Bingo!
Hope it helps.

Check the following:
Have you copied the file into your project or just passed the reference of the file.
If you have not copied the file into your project (just passed the reference to it by drag drop or other ways), make sure that the path in "Header search Paths" is properly updated.
Its seems like you have missed to update the path from where you are referencing the file.

Related

Unit tests failing to run after app rename due to apple linker error

I recently changed the name of my app and now my unit tests are not running, I am getting an Apple linker error.
Any idea how to fix this? If I expand my 'Products' folder in Xcode there are 2 files:
MyApp.app
MyAppTests.octest [which appears red]
Update: Deleted all the build folders (derived data) still doesn't work!
Ld
/Users/my/Library/Developer/Xcode/DerivedData/srStudio-bdkguonwasdiazelguppliitkdox/Build/Products/Debug-iphonesimulator/companyDesignerTests.octest/companyDesignerTests
normal i386
cd /Users/my/Documents/Working/companyDesigner
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 -bundle -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk
-L/Users/my/Library/Developer/Xcode/DerivedData/srStudio-bdkguonwasdiazelguppliitkdox/Build/Products/Debug-iphonesimulator
-F/Users/my/Library/Developer/Xcode/DerivedData/srStudio-bdkguonwasdiazelguppliitkdox/Build/Products/Debug-iphonesimulator
-F/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/Library/Frameworks
-F/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/Library/Frameworks
-filelist /Users/my/Library/Developer/Xcode/DerivedData/srStudio-bdkguonwasdiazelguppliitkdox/Build/Intermediates/srStudio.build/Debug-iphonesimulator/companyDesignerTests.build/Objects-normal/i386/companyDesignerTests.LinkFileList
-mmacosx-version-min=10.6 -bundle_loader "/Users/my/Library/Developer/Xcode/DerivedData/srStudio-bdkguonwasdiazelguppliitkdox/Build/Products/Debug-iphonesimulator/s
& r.app" -Xlinker -objc_abi_version -Xlinker 2 -lxml2 -Xlinker
-no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework CoreData -framework CoreGraphics -framework Foundation -framework UIKit -framework SenTestingKit -o /Users/my/Library/Developer/Xcode/DerivedData/srStudio-bdkguonwasdiazelguppliitkdox/Build/Products/Debug-iphonesimulator/companyDesignerTests.octest/companyDesignerTests
ld: in
/Users/my/Library/Developer/Xcode/DerivedData/srStudio-bdkguonwasdiazelguppliitkdox/Build/Products/Debug-iphonesimulator/s
& r.app, can't map file, errno=22 for architecture i386 Command
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang
failed with exit code 1
The following solution works for me:
-> Select your project
-> Select your projectTest file from TARGETS
-> In Host Application, select your project if it shows custom
I don't know if this would help you solve your problem but you could try going to the organizer and under Projects tab hit remove for all Derived Data
In my case, I had the similar issue after performing app rename. I'm running Xcode 8.x and what I did was:
1) Project -> Targets -> xxTests -> General -> Enable 'Allow testing Host Application APIs'.
2) Perform clean & rebuild
3) In [Simulator], reset it: Simulator -> Reset Content and Settings...
I faced similar issues when renaming my app. You should try with a fresh clean build. Make sure that you remove all build folders (performing a clean in XCode sometimes is not enough).
For the current version of Xcode, you just need to click on the project, then change the name in the file inspector. Or you can right-click on project, and there will be a "Renaming a project" in the help dialog.
I've worked out a resolution to this issue which I've shared here: https://stackoverflow.com/a/30508062/233602
I have filed this as http://www.openradar.me/21139630 and rdar://21139630 with Apple. Feel free to dupe if you also experience this issue.

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.

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

Three20 issue: _OBJC_METACLASS_$_TTURLRequestModel undefined?

Being new to iPhone development I was wanting to take it to the next level and use the Three20 library for a photo gallery I am building.
http://www.raywenderlich.com/1430/how-to-use-the-three20-photo-viewer
Everything seemed to go smoothly up to the point I tried testing the app and I got this error.
"_OBJC_METACLASS_$_TTURLRequestModel", referenced from:
Ld build/Debug-iphonesimulator/PhotoGallery.app/PhotoGallery normal i386
cd /Users/company/Documents/PhotoGallery
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/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk -L/Users/company/Documents/PhotoGallery/build/Debug-iphonesimulator -F/Users/company/Documents/PhotoGallery/build/Debug-iphonesimulator -filelist /Users/company/Documents/PhotoGallery/build/PhotoGallery.build/Debug-iphonesimulator/PhotoGallery.build/Objects-normal/i386/PhotoGallery.LinkFileList -mmacosx-version-min=10.6 -ObjC -all_load -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -framework CFNetwork -framework SystemConfiguration -framework MobileCoreServices -lz.1.2.3 -framework CoreLocation -framework QuartzCore /Users/company/Documents/opensource/three20/Build/Products/Debug-iphonesimulator/libThree20.a -framework CoreData -o /Users/company/Documents/PhotoGallery/build/Debug-iphonesimulator/PhotoGallery.app/PhotoGallery
Undefined symbols:
"_OBJC_METACLASS_$_TTURLRequestModel", referenced from:
_OBJC_METACLASS_$_PhotoSet in PhotoSet.o
"_OBJC_CLASS_$_TTURLRequestModel", referenced from:
_OBJC_CLASS_$_PhotoSet in PhotoSet.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Anyone
While I included the Three20 static library I didn't include the other dependencies in the same library such as Three20UINavigator.xcodeproj etc.
Sudo was pretty close. While I did include the proper libraries it was simply that they were not activated; I don't know the proper term :P
Basically, we should keep in mind that just because I dragged the Three20.xcodeproj into my project doesn't suffice when other extensions are needed as well. Simply drag all of the xcodeproj files necessary in (wherever you are keeping three20)/three20/src/(name of particular extension)/(name of particular file).xcodeproj into your projects "group and files" Then click on each extension and select the (name of particular file).a and check the checkbox on the far right of the file preview section. This is what I didn't do for all the extensions that seemed to resolve the problem even though I had previously included them all.

gcc-4.2 failed with exit code 1 Error

i downloaded a project and i want to try it, but when i'm trying to compile it i get always this error:
Build TuneIn Radio of project TuneInRadio with configuration Release
Ld "build/Release-iphonesimulator/TuneIn Radio.app/TuneIn Radio" normal i386
cd /Users/marco/Downloads/projects
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/iPhoneSimulator4.2.sdk -L/Users/marco/Downloads/projects/build/Release-iphonesimulator -L/Users/marco/Downloads/projects -L/Users/marco/Downloads/projects/TuneInRadio-iphonesimulator -L/Users/marco/Downloads/projects/MMS/build/Release-iphonesimulator -L/Users/marco/Downloads/projects/ffmpeg/build/Release-iphonesimulator -F/Users/marco/Downloads/projects/build/Release-iphonesimulator -F/Users/marco/Downloads/projects -filelist "/Users/marco/Downloads/projects/build/TuneInRadio.build/Release-iphonesimulator/TuneIn Radio.build/Objects-normal/i386/TuneIn Radio.LinkFileList" -lTuneInRadio -llibmms -lffmpegLib -ObjC -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework CoreGraphics -framework QuartzCore -framework CoreFoundation -framework AudioToolbox -framework MediaPlayer -framework CoreLocation -framework UIKit -lz.1 -framework SystemConfiguration -framework MapKit -o "/Users/marco/Downloads/projects/build/Release-iphonesimulator/TuneIn Radio.app/TuneIn Radio"
ld: warning: directory '/Users/marco/Downloads/projects/TuneInRadio-iphonesimulator' following -L not found
ld: warning: directory '/Users/marco/Downloads/projects/MMS/build/Release-iphonesimulator' following -L not found
ld: library not found for -lTuneInRadio
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
Any advice on what kind of steps i can follow to reach the error ?
Thank's
The error indicates the problem:
ld: library not found for -lTuneInRadio
this means that your build/make is trying to find a library (called libTuneInRadio) to compile this program you're trying to build but it can't find it in the paths (the default ones + the ones described by the '-L' options on gcc call).
Not knowing any more about what you're compiling/building makes it impossible to say precisely what's happening other than you're missing this library.
Given the name of the library, it sounds like it should be part of the project you're trying to build (or maybe there is a related TuneInRadio-lib project), so I would suggest reading the README or BUILDING or similarly named file that might have come with the project to determine how to successfully compile this program.
I had the same problem compiling the project for iOS simulator, the problem is that the source code you downloaded does not contain the libTuneRadio.a library for TuneInRadio-iphonesimulator, so first create that folder and second move the libTuneRadio.a from TuneInRadio-iphoneos to the recently created folder. That should make it.
My application compiled successfully but it crashes as it cannot find any CasseteAudioPlayer class, so i guess there is still something wrong.