linker command failed in react native app, using react-native-firebase - xcode

I developed a react native app using react-native-firebase library.
I want to set my app icon, so I used this library:npm install -g yo generator-rn-toolbox from here.
When I try to build the project I receive this error:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_RCTSRWebSocket", referenced from:
objc-class-ref in libReact.a(RCTInspectorPackagerConnection.o)
"_OBJC_CLASS_$_RCTReconnectingWebSocket", referenced from:
objc-class-ref in libReact.a(RCTPackagerConnection.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How do I fix this ?

I fixed it by manually adding the RCTWebsocket library:
find the RCTWebsocket project: open -R node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj
Drag it into xcode under your projects Libraries folder
on your project, select your project target, then goto "Build phases" --> "Link Binaries With Libraries" --> "+"
Search for libRCTWebSocket.a and add it
your project should build now. If libRCTWebSocket.a in step 4 is not there, try to build the project first.

I had the similar issue for iOS 12, XCode 10.
For those that may help (and avoid losing days like me..),
i had to add the libRCTWebSocket.a and the libfishhook.a binaries in the YourProject -> Targets -> YourProject -> Link Binary With Libraries list

I was able to build the app by placing libRCTWebSocket.a before libReact.

Related

XCode linker not finding framework or some libraries within the framework built via cocoapod

I just moved from manual to CocoaPods. The first thing I tried was Urban Airship. I got it all compiling but I get the following linker errors:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_UAConfig", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_UAirship", referenced from:
objc-class-ref in HomeScreenViewCtr.o
objc-class-ref in MyProfileViewController.o
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is my pods build settings screenshot showing it's supposedly building the Urban Airship framework.
My XCode file is opened to the xcworkspace file not the xcodeproj.
Now I don't know if I'm supposed to add the Urban Airship framework my Build Phases "Link Binary With Libraries". It seems to have created a pod named after my own App, should that be in the "Link Binary With ...". What should be listed under the "Frameworks" folder and under the yellow "Pods" folder in my main file / folder navigator?
OK I figured it out. "$(inherited)" was missing from my "Framework Search Paths" of my build target. I did the "pod setup" command but it apparently forgot to set up my Framework Search Paths correctly.
Detailed answer:
Set up your Framework Search Path
Add the cocoapods framework to your Build Phases, but do NOT add that Pod_your_app_name.framework
In your main navigator: Do not attempt to add anything related to the cocoapod Framework e.g. AirshipKit to your yellow "Pods" folder, but it should appear in your yellow "Frameworks" folder.
If you really search for the inner working of CocoaPods, you'll find that your cocoa pods frameworks get built deep in your ~/Library/Developer/Xcode/DerivedData directory. Various compile variables point over that direction.

xcode 6.1 - Undefined symbols for architecture x86_64 (zbar)

ld: warning: ignoring file /Users/sayan/Desktop/ProjectAtanu/Omlis/Custom Classes/ZBarSDK/libzbar.a, missing required architecture x86_64 in file /Users/sayan/Desktop/ProjectAtanu/Omlis/Custom Classes/ZBarSDK/libzbar.a (3 slices)
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_ZBarReaderViewController", referenced from:
objc-class-ref in HomeViewController.o
"_ZBarReaderControllerResults", referenced from:
-[HomeViewController imagePickerController:didFinishPickingMediaWithInfo:] in HomeViewController.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 using latest Xcode and iOS version in my App.
Any help much appreciated!
I was able to build a universal library with support for the simulator by following the instructions here: Build fat static library (device + simulator) using Xcode and SDK 4+
I hope that helps you too.
or
up vote
USING PODS
pod 'ZBarSDK'
OR
Recompile ZBar for iphone 5. You can download recompiled ZBAR from here to skip the following
Steps
Download the source code (you must have Mercurial for mac):
Open Terminal and run following commands
a. hg clone http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbar
b. cd zbar
c. hg checkout iPhoneSDK-1.3.1
d. open iphone/zbar.xcodeproj
In the xcode project edit the "libzbar" scheme and select Release in Build configuration
Go to Build Settings set following Architectures
a. Architectures - >Standard architectures(armv7,armv72,arm64)
b. Valid Architectures -> arm64,armv7 armv7s
Compile libzbar for device AND for simulator, here the configuration:
Find the compiled libzbar.a and go in the folder using Teminal.app,
In My Case : /Users/kappe/Library/Developer/Xcode/DerivedData/zbar-gyozyrpbqzvslmfoadhqkwskcesd/Build/Products
In this folder you you should have two sub folder Release-iphoneos and Release-iphonesimulator
using xcode command line tools build your universal lib:
lipo -create Release-iphoneos/libzbar.a Release-iphonesimulator/libzbar.a -o libzbar.a
Now you can use the libzbar.a created, both in device and simulator.
Ref : http://www.federicocappelli.net/2012/10/05/zbar-library-for-iphone-5-armv7s/

static Library in Xcode 4

I am too much of this Static Libary thing in Xcode 4.X
Following are the steps that I usually do..
1)For making a static libary , I open Xcode , new , static libary , and then by adding some classes in the project .. then build phases ->copy headers -> add all headers here one by one,and then i build up the project
when run on ios simulator -> static libary does not created ..(red color)
when run on ios device - > static library gets created..
2) for using the library..
I make a new Project , then i "add files to project" and also "copy if needed" the following 2 files..
.a file (i.e.static library)
folder consisting the headers of library files
Now when I try to import a header file in my project , there is no "suggestion" appear ...but still i write and it does not give an error "header file not found"...
but when I run the project it gives the error like:
ld: warning: ignoring file
/Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a,
file was built for archive which is not the architecture being linked
(i386):
/Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_LibraryImporting_test", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Plz guide me....point out if get wrong at some step....help plz
it will be better if someone mentions all the steps as i have done in making a library and using it in a project...it will be a great help
The key to the issue is this part of the error message:
file was built for archive which is not the architecture being linked
(i386)
You have imported the library built for the iPhone Device (ARM) by the look of it, and you are trying to use it in the iPhone Simulator which is i386.
What I would recommend is using an Xcode Workspace where the static library project is one of the projects and the iPhone app is another project. This way Xcode will build the library, as required, for Debug/Release and Device/Simulator.

Xcode 4.5 and Phonegap 2.0 reference issue

Yesterday I updated new Xcode 4.5, and I got an error in my build and I am not sure how can I even fix this.
Everything works fine if I build in simulator, but when I try to build for Archive for example, i get this:
ld: warning: ignoring file /Users/corotchi/Library/Developer/Xcode/DerivedData/NJR_IR-ftjwhrqtxwedihfjrbjikbqqttkx/Build/Products/Release-iphoneos/libCordova.a, file was built for archive which is not the architecture being linked (armv7s): /Users/corotchi/Library/Developer/Xcode/DerivedData/NJR_IR-ftjwhrqtxwedihfjrbjikbqqttkx/Build/Products/Release-iphoneos/libCordova.a
Undefined symbols for architecture armv7s:
"_OBJC_CLASS_$_CDVURLProtocol", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_CDVViewController", referenced from:
_OBJC_CLASS_$_MainViewController in MainViewController.o
"_OBJC_METACLASS_$_CDVViewController", referenced from:
_OBJC_METACLASS_$_MainViewController in MainViewController.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
and more errors bellow, which are the same
Everything worked fine until u updated the Xcode, I had another issue before where I read the formums that I have to remove the "ARMV6" from the build settings, cause it is not supported anymore in new IOS, and after that I get this reference issue.
I appreciate any help,
THanks!!!!
Remove armv7s from Valid Architectures from both your project and Cordova(phonegap) project. Also set iOS Deployment target 4.3 or above in both project and Cordova(phonegap) project. After that Clean and Clean Build Folder. This will solve the problem.
If you also take out armv7s from the build settings, you should get it to build for you.
Edit: As per below: Fix can be found here via PhoneGap: https://issues.apache.org/jira/browse/CB-1360
This is a bug already fixed at Cordova 2.2.0
https://issues.apache.org/jira/browse/CB-1360
Change the Buid setting ---> Architecture ---> Build Active Architecture only ---> Yes
This solved my issue for using old cordova versions in new Xcode 5

How to link to another library in Xcode?

I created a command line application. Then I realized it would be handy to be able to use code in other projects, so I added a new target - a cocoa library.
It seems to compile and a .a file is generated.
Now in another project I want to use this library. So first I added the first project to this new project as a reference.
In build settings I set "Always search user paths" to YES, then keyed in the path to the above project in user header paths.
In build phases, "Link Binary with libraries" , I added the .a file.
Now in my new project code sense seems to work. But when I try to build, I get an error : ndefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RIImageSplitter", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What did I do wrong? :S I am a beginner.
Didn't add file to compile sources of target. =S
Check this:
Did you drag the static library to your project navigator?
Did you add in Target/Build Phases/ Target Dependencies?
Did you add the Header Search Path for the headers of the static library?
Good Luck!

Resources