Apple Mach-O Linker Error when Run simulator with Facebook SDK - objective-c

I have added Facebook SDK Framework into my Xcode 6.
Then I import it to my AppDelegate.h file.
Then I put this code [FBLoginView class]; into this function
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
And when I clicked on Run Simulator I get this:
I'm a newbie and so confuse about what the error is. Please give me solutions.

This error usually occurs either when you don't have the correct frameworks (might be missing one) or when you don't have the right thing in linker flags.
Go to the main page for the app (on the navigation thing on the left click on your apps name or the top section) -> Build Settings and under Linker Flags, make sure there is nothing in your Other Linker Flags. I had this same error when I had -ObjC in my other Linker Flags.
Good luck

Related

Unable to add opencv2-2 framework to iOS project

I'm trying to add the opencv2-2 (the latest release) framework to my iOS project, but I am encountering this error when I build.
ld: framework not found opencv2-2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The opencv2-2 framework appears in the Link Binary with Libraries section of the Build Phases tab. If it's relevant, this is my import statement in ViewController.m:
#ifdef __cplusplus
#import <opencv2-2/core.hpp>
#endif
Here's a screenshot:
What am I doing wrong?
Your framework file should be named opencv2.framework and your import statement should be #import <opencv2/core.hpp>.
I'm not sure where you got the incorrect name opencv2-2. Maybe you downloaded opencv2.framework twice and Mac automatically renamed the second copy to opencv2-2.framework.
I had the same error, I changed the framework name from opencv2-2.framework in opencv2.framework and it works

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'.

Duplicate symbol _OBJC_CLASS_$_Facebook

I'm building an ARC iphone app, and about to integrate the addThis ios library.
I get the following error:
ld: duplicate symbol _OBJC_CLASS_$_Facebook in /Users/mars/Desktop/Pst/trunk/Pst/ThirdPartyLibs/FBConnect/FacebookSDK/FacebookSDK.framework/FacebookSDK(Facebook.o) and /Users/mars/Library/Developer/Xcode/DerivedData/Pst-bqmphjiqldalzsankfvxugsurcdj/Build/Intermediates/Pst.build/Debug-iphonesimulator/Pst.build/Objects-normal/i386/Facebook.o for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've double checked with my Compile Resource, and only 1 facebook.m is present.
I've also put "-fno-objc-arc" in my compiler flags for those library files because they are built without ARC
Any help would be really appreciated!!
I've got the same error when followed the instruction to drag ThirdPartyLibs to my project. It had added both FBConnect and FacebookSDK to my project.
If you open the AddThisDemo project, which comes with the library, you will see that only FacebookSDK and DeprecatedHeaders were added (not entire FBConnect). I have recreated this structure in my project and that had solved my issue.
Hope that helps!
For anyone with this issue but these answers are not helping: if you created one custom class and called it Facebook.h/.m, just change its name and after it, no more linkage errors.
You have a #import "facebook.m" in one of your files where you should have put #import "facebook.h".

Crash when tapping cell in GMGridView

i'm trying to use the GMGridView library, everything works but when i tap in a cell the app crash in a method of the library with this error: [UILongPressGestureRecognizer hasRecognizedValidGesture]: unrecognized selector sent to instance...
I've tried to add "-ObjC -all_load" tho Other Linker Flags section but this give me an error with another library (MWPhotoBrowser).
There is someone who have resolved this?
Thank you
You should specify the linker flags:
-ObjC -all_load
(source).
If you are using Xcode 4.2 and LLVM 3.0, only -ObjC is needed.
For an explanation of why this is necessary, have a look at this S.O. thread.
Look here for steps to set linker flags in Xcode 3. In Xcode 4, you have to select your targets, and then the Build Settings tab in the right pane.

Error with iOS 5.1 when i use ASIHTTPRequest and SBJSON

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