Issues when installing th json framework on xcode4 - iphone

Hello
I am trying to install json framework. According to installation instructions I have to copy all the classes from json-framwork/classes in my project! I did that and I am getting this error:
ld: duplicate symbol
_OBJC_METACLASS_$_SBJsonParser in /Users/user/Library/Developer/Xcode/DerivedData/testhttp-eavsbuatbfoagsgbqfnevfpjxxfc/Build/Intermediates/testhttp.build/Debug-iphonesimulator/testhttp.build/Objects-normal/i386/SBJsonParser-4254E5B76E32172.o
and
/Users/user/Library/Developer/Xcode/DerivedData/testhttp-eavsbuatbfoagsgbqfnevfpjxxfc/Build/Intermediates/testhttp.build/Debug-iphonesimulator/testhttp.build/Objects-normal/i386/SBJsonParser-46310C881BFA9776.o
for architecture i386 collect2: ld
returned 1 exit status Command
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2
failed with exit code 1
What I am doing wrong here?

Please have a look at:
iPhone: Duplicate Symbol Error?
Select the project navigator in the right sidebar. Double click your project(top element).
Now open the build phases tab. There is a section which is called Compile Sources. Open it an check if there is a duplice entry of the file which the error refers to.
My Installation of the json-framework
Just added these files to my project
Each .m file is here only once
In the class I need JSON parsing I'll just import:
#import "JSON.h"

I just erase the .m and .h files from JSON Framework wich the compilator was giving me errors, at the end I just keep from the JSON Framework: NSObject+SBJSON, NSSTring+SBJSON .h and m.
This worked for me, I hope it helps :D

Related

Duplicate Symbol in _main

Can someone tell me why I am getting this error. I have tried cleaning and building several times . But still I am getting this error.
duplicate symbol _main in:
/Users/outthinkingindiapvtltd/Library/Developer/Xcode/DerivedData/PatternTest- axdlojadtjwkbvdioeiumrzlovix/Build/Intermediates/PatternTest.build/Debug-iphoneos/PatternTest.build/Objects-normal/armv7/main-EC3660AC7D58737D.o
/Users/outthinkingindiapvtltd/Library/Developer/Xcode/DerivedData/PatternTest-axdlojadtjwkbvdioeiumrzlovix/Build/Intermediates/PatternTest.build/Debug-iphoneos/PatternTest.build/Objects-normal/armv7/main-6C8789F4078B135A.o
ld: 1 duplicate symbol for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This means, you have a file twice in your Xcode Project. Check the Project folder, You will find a file in two different groups or folders with the same name.
It seems you have multiple entries under Targets/Compiled Sources. removed them and the problem is solved.
It might be possible you have imported an .m file instead of .h, like:
#import "DemoView.m"
Just check the extensions of the file you recently imported, after which you are getting this error.

Correct way to use a private library in objective c?

I downloaded a collection of private libraries from this link. When I click download I get all frameworks. So these are only header files not the .framework files that are available in Xcode. So I linked them by the usual method of going to build phases, in it I go to link binary with libraries click on + and choose the header files from a framework (preferences framework in my case). After these files are added to my project I try to make an object from one of the libraries and try to call their instance methods. When I try to execute this program I get this error. I get this whether I run it on the device or simulator.
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_DevicePINController", referenced from:
objc-class-ref in UAViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1
(use -v to see invocation)
DevicePinController is a part of a private framework preferences.h.I am trying to make an object of it UA
EDIT: I tried using other framework headers such as bluetooth and I get this error in all.
EDIT: I tried adding the entire framework to the project instead of adding individual header files.Now the error is
d: framework not found BluetoothManager
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You'll need to actually build the framework. You can't just link against a header file; that doesn't make sense.
Try adding all the .m files in the Preferences folder as Compile Sources, and remove the header file from Link Binary with Libraries.
Added: I realize now this answer is incorrect. The files OP is trying to use are not a library, but header files from Apple's private frameworks. Here's a related answer: https://stackoverflow.com/a/13388225/893113

Error running Simulator: duplicate symbol for architecture i386

I added ShareKit framework to try and here is the error running it in Simulator:
duplicate symbol _LFHRReadStreamClientCallBack in
.../Xcode/DerivedData/....build/Objects-normal/i386/LFHTTPRequest-8C6F35228BA446B9.o
and
.../Xcode/DerivedData/....build/Objects-normal/i386/LFHTTPRequest-8ACF920D803FDCA6.o
for architecture i386
I looked at previous posts Build Error - missing required architecture i386 in file and tried to edit project.pbxproj commenting FRAMEWORK_SEARCH_PATHS lines out as well as looking for .framework files accidently added to my project but with no luck.
What else can I try?
You've included LFHTTPRequest in your project twice. It's possible that another library (such as sharekit) included it for you, doublecheck the files sharekit includes and remove one copy of LFHTTPRequest and things should compile.
This can also happen if you move coredata-generated classes into a group, like "Models" and then regenerate the NSManagedObjectModel subclasses. The generated files will be placed in the project root and added into the build twice.
I got the same error when working with TessBaseAPI. I had two c++ files and both had the following declaration:
namespace tesseract {
class TessBaseAPI;
};
tesseract::TessBaseAPI *tesseract1;
uint32_t *pixels;
The I read the full error message. I got a line there:
duplicate symbol _tesseract1 in
And later, which files contains the duplicate also included (the file name).
So, I changed the instance name as follows:
namespace tesseract {
class TessBaseAPI;
};
tesseract::TessBaseAPI *tesseractNew;
uint32_t *pixelsNew;
That solved my problem.

How to add the library for OAuth

I am facing this error, what will be poosible reason for that error
ld: library not found for -lOAuth
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
thanks for any help.
if you are using twitter+oAuth then you need to drag libOAuth.a lib in your project you are missing that.
you can find libOAuth.a in your sample code folder
This Error occur when you use two file's with the same name, or you use, two same name of variable into two different .m files. So check that out.
When you miss one or more file, you will get this error. Check out for that missing file.

Iphone-exif 0.91 not working when I add it to my project, gives error ".objc_class_name_EXFJpeg", referenced from:

When I add libiphone-exif.a to snapandrun in objectiveflickr I get this error:
".objc_class_name_EXFJpeg", referenced from:
literal-pointer#__OBJC#__cls_refs#EXFJpeg in SnapAndRunViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I do not know what this means, I follow the guide to add it, add all of the .h files and the libiphone-exif.a
Is there something special I have to do?
It sounds like you didn't add the library properly. It is a static library, not an Objective C or data file, so simply adding it to the project isn't enough. All that will happen is that it gets copied into the application bundle, when it needs to be statically linked into the executable. You have to open your targets and add the .a file under "Link Binary With Libraries".
I downloaded the source from the svn project from google and drag and drop into my project.
Clicking the target and marking the static lib as "weak" type instead of "required" made no difference.