Duplicate symbol _OBJC_CLASS_$_Facebook - objective-c

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

Related

Undefined symbol: _OBJC_CLASS_$_FIRApp

I m trying to add Firebase Analytic and Firebase Crashlytics using Swift package manager here is a link of git for firebase SDK
https://github.com/firebase/firebase-ios-sdk
after that I add this two line in my AppDelegate file
#import <FirebaseCore/FIRApp.h>
#import <Firebase.h>
All fine until when I add this [FIRApp configure]; getting error
Undefined symbols for architecture arm64:
"OBJC_CLASS$_FIRApp", referenced from:
objc-class-ref in HWOFAppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I go thought every link of stack-overflow for similar problem try every solution but nothing help me like change Other Linker Flag etc...
Please help me..I really appreciate...I m using Xcode 12.1 with Objective-C
here is a screenshot of error which i m getting
And screenshot of added dependency
After so much searched I solved issue. Solution is
"$(inherited)" In Other Linker Flags
Build Active Architecture Only value to "Yes"
Add Run Script for firebase SPM is "${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
Clean project
Build Project
I got the same issue while integrating MLKit in my recent work. The app was running fine on simulator as well as device but when I tried to archive the build it started throwing me error below-:
Undefined symbol: _OBJC_CLASS_$_MLKFaceDetector
I am using the MLKFaceDetector object in my files.
Resolution:-
Go to Build Settings -> Architectures -> Replace standard architectures with arm64. Also, make sure there is no space between arm & 64.
Reason what I understood is MLKit only supports 64 bit not 32 bit and since we are using standard architectures targeting both 32 and 64 bit, so Xcode while archiving for 32 bit is unable to find MLKit files. So we are explicitly saying Xcode to Archive only for 64 bit and not 32 bit.
Cons - It will not support some of the older iOS devices.
Finally I found the solution for this
For me changing ios deployment target to higher version than before workd.Mine was 9.0 I changed it to 13 .
Target-general- deployment info
Can try this it Will help,
Change Linking -> Mach-O Type to Dynamic Library, for the frameworks you used, then it works fine.

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

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

Trouble when I try to run Archive command in XCode

I'm making an app with Facebook validation. It is working fine on simulator and in the device.
But, when I try to "Archive" (Product => Archive), I get this error:
ld: library not found for -lfacebook_ios_sdk
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The libraries are okay, otherwise it would not compile on simulator/device.
I don't know if this information is relevant, but my project is an ARC project.
Does anyone know what this error could mean?
I solved the problem by just removing the "libfacebook_ios_sdk.a" reference from my Link Binary Libraries and adding it again.
I dont know why it worked, but worked!