Error with iOS 5.1 when i use ASIHTTPRequest and SBJSON - objective-c

i am getting this error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ASIHTTPRequest", referenced from:
objc-class-ref in FirstViewController.o
"_OBJC_CLASS_$_SBJsonParser", referenced from:
objc-class-ref in FirstViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Note i have added the frameworks core graphics,system configuration,mobile core services,libz.dylib,libz.1.2.5.dylib,CF Network,UI Kit and Foundation.
I have searched all the forums and spend almost 4 days but just don't find the cause.
When i comment my ASIHTTPRequest and SBJSON code lines,it works fine.
I have added all the classes for ASIHTTPRequest and SBJSON and checked thrice.
Could anyone suggest what am i doing wrong?

I would take a look at the Build Phases section in your Target. Under "Compile Sources", make sure you see the .m files for ASIHTTPRequest and for SBJson. Sometimes when you drag external classes into a project, even if you check the box to copy the files into your project, they don't make it into these compile sources. When you drag a file into Xcode, there is a check box to add the file to the target. If this isn't checked, the file won't make it into the Compile Sources. Delete the files and re-add them, ensuring this file is checked (or you can add the .m files manually if you'd like).

For ASIHTTP Request add the following frameworks:
libz.1.2.5.dylib
SystemConfiguration
UIKit
Foundation
CoreGraphics
MobileCoreServices
CFNetworks
If you are using ASIHttp classes in iOS 5 or later, you need to turn ARC off for the ASIHttpRequest classes in Project-> Build Phases -> Compile Sources by using -fno-objc-arc for the ASI API classes.
Hope it solves the problem.

i had this same problem , but when i included the following frame-work
its working fine now..Don't forget to include -fno-objc-arc in the compile source
Best Wishes.......

For the ASIHTTPRequest error, it sounds like you've not added ASIHTTPRequest.m to your project.
(Or you have added ASIHTTPRequest.m, but have forgotten to mention the 4 billion errors xcode is emitting about ARC - see Why are my ASIHTTPRequest files showing ARC errors? )

Related

_OBJC_CLASS_$_KeyboardViewController", referenced from:objc-class-ref in KeyboardPreferencesController.o

I am totally stuck with an error I am getting when trying to test project on the simulator.
Error looks like:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_KeyboardViewController", referenced from:
objc-class-ref in KeyboardPreferencesController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am building custom keyboard using keyboard extension and what I am trying to do is that in main application I am implementing settings view to modify keyboard like font change... so of course, it needs to be linked to extension header file KeyboardViewController.h
I have tried to add Other Linker Flags -> $(inherited) in both debug and release, also tried to switch Build Active Architecture Only -> YES but it also does not worked for me.
So is there any other solution for this because I can not find anything what will work for me.
Thanks in advance!
You need to compile and link the implementation file (KeyboardViewController.m?) into your target.
Use Xcode's File Inspector to make sure target membership is turned on. Look at the build phases to make sure the implementation file is included.
If those things are correct, look at the KeyboardViewController.m to make sure it actually has a #implementation section.

Removed/Re-Added file, now I get Undefined symbols for architecture arm64:

In my app, I removed then re-added a class. The target membership for the .m file is checked and it appears under Build Phases->Compile Sources. "Build Active Architecture Only" is set to "No", and the "Valid Architectures" are "arm64 armv7 armv7s". I also tried clearing out the DerivedData folder. What other ways are there to fix this issue?
This worked for me:
ios sdk 9.3
into your build setting of app.xcodeproj valid architecture: armv7 armv7s Build Active architecture : No
Clean and build.
Pretty crazy stuff. Figured it out. Turns out the specific class I added calls some C++ functions, so I needed to change its file type to Objective-C++ in the Identity Inspector.

Calling Objective-C from Swift class causing linker errors

I'm trying to use RFDuino Objective-C library in Swift. It all sounds simple, I have called Objective-C from Swift classes before, no problem. This time however I hit the brick wall.
Created header file. Added header files to it. Swift can see the classes no problem. Project compiles fine.
The problem during build appears just after I try to call any of Objective classes
for example:
override func viewDidLoad() {
super.viewDidLoad()
let rfDuinoManager: RFduinoManager = RFduinoManager.sharedRFduinoManager()
}
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RFduinoManager", referenced from:
__TMaCSo14RFduinoManager in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Im not sure what Im missing here.
Link to the project here.
https://www.dropbox.com/s/rza1ce01g4q5lp6/SmartHomeHub-stackoverflow.zip?dl=0
Thanks in advance for help. Honestly loosing hope now and considering rewrite whole library to Swift
The problem is how the rfduino folder was added to the project. So
Remove rfduino folder (selecting rfduino folder in the project navigator panel on left and hit delete button, but when it asks to move it to the trash or just remove references, choose "remove references".
Your bridging header has an absolute path reference, I'd suggest removing that altogether by selecting it in build settings and hitting delete button:
Re-add rfduino files back to the project, this time, under "added folders" option, choose "create groups" rather than "create folder references". If you want it to prompt to create proper bridging header for you, don't select folder, but select the individual files:
Also make sure that SmartHomeHub is checked below.
If you do that properly it will ask you to create bridging header automatically:
Go to this new bridging header and add your import lines again:
This is a linker error, not a compiler error. Are you sure the RFduino class (source or library) is included in your project (open the project membership panel on the right in Xcode and make sure the box is checked to include the library in your target).
If it is included, make sure it has x86_64 code compiled into it. It might be an iOS library and is just compiled for ARM. You can check by finding the binary and running lipo on it from the command line.
lipo -info [name of RFduinolibrary.a(dylib,whatever)]
it should show x86_64 as an architecture, ala:
Architectures in the file are: i386 x86_64
"The OPN [Debug] target overrides the OTHER_LDFLAGS build setting". This was the main issue. After adding $(inherited) in new line in other linker flags solved my issue.
For me, Removing all the files in 'derived dir', removing reference to the frameworks in my project and connect again and etc didn't work anymore. Only worked to me is to set 'Build Active Architecture Only' to 'YES'.

Xcode5: unit test linking errors

I seem to get this strange issue when testing an XCTestCase. I created a unit testing bundle, and set my main app as the "target"; now I can write tests against my Core Data NSManagedObjects just fine, but if I include anything else in my app that isn't an NSManagedObject, I get linking errors:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_iCloudListener", referenced from:
objc-class-ref in SLTestToDoWithRepeatInterval.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This only happens with non-NSManagedObjects. And iCloudListener is definitely in the Compiled Sources for the main app target. The problem is that though I can go and add this particular iCloudListener class into the test target -> Build Phases -> Compile Sources list, and that will make this particular linking error go away, but it introduces new ones since it starts giving linking errors about all the header files from the iCLoudListener class; and if I start adding those, they require more and more files, to the point where I have to include pretty much all of my code into the test target "Compile Sources" section.
Is there something I'm doing wrong here? Is there a setting which might be causing Xcode to ignore the non-NSManagedObject classes?
It's because the project inserted the core data's xcdatamodeld file in compile sources. Select your project -> Build Phases -> Compile Sources and delete projectName.xcdatamodeld file.
And also check if you have imported .m file instead of .h file, it also gives the same linker error.
Check all the #import codes.
And check if you have added core data frame work in library and imported core data .h file. Check for creation of NSManagedObject and import it's file.
Just try it and reply me if still any error.

Issues including C++ files with Objective C on iOS

I'm trying to include several different items from AudioCore, in particular, AQRecorder. This does, however, have dependencies on c++ code. Normally this is not an issue as I just rename my view controller to have the extension .mm and everything is great. But in this case, my dependency on AQRecorder.h indirectly goes to my main.m which is causing me great pain.
I've tried several different things including the following:
1) Changing all .m and .cpp files -> .mm files
Everything compiles perfectly, however, it can't deploy to my iOS device or simulator as I get this error when deploying to the device:
"Choose a destination with a supported architecture in order to run on
this device."
I'm using XCode 4.6 and my valid architectures are armv7 & armv7s (I've played with these but with no luck).
2) Tried using opaque pointers such as that in this guide:
http://philjordan.eu/article/mixing-objective-c-c++-and-objective-c++
I still run into the same issue where it won't compile.
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_AQWrappedRecorder", referenced from:
objc-class-ref in RTPPacketSender.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My dependencies are as follows:
AQRecorder.h -> RTPPacketSender.h -> ActiveConversationViewController.h -> ConversationViewController.h -> AppDelegate.h -> main.m
Can anybody else recommend anything to try. I've quite literally spent all day debugging this issue with no luck.
Vince