Error: undefined is not an object (evaluating \'RCTWebSocketManager.connect\') - ios

I m using React-native v0.10.0 and getting this screen:
Ok, So I figure out I m doing something wrong.
So I downloaded the code from this official React-native website for integrating React-native into existing app using pod.
The downloaded code uses React-native v0.2.1 and everything looks good there.
So I copied the whole code and overrode mine, but the red screen still appears. It left me just with the changes of the React-nativeŚ„
Is there any chance that the current version of React-native v0.10.1 doesn't work at all? :/
Thanks in advance!

I've had success by adding pod 'React/RCTWebSocket' to the Podfile as well and running pod install again.

This issue is caused because RCTWebSocketManager is not defined in your bundled app. The connect method of an object cannot be called on an undefined or null object.
To resolve this problem in iOS open Build Phases for your app target and ensure libRCTWebSocket.a exists in the Link Binary with Libraries section. If the item is not listed and not available for addition then add RCTWebSocket.xcodeproj to your app's Libraries folder in Xcode and try linking again.

This may seem rather trivial, but check to make sure that you have deleted react-native from the node_modules directory within the directory of react-native-router in the app's node_modules directory. If react-native is listed again the app will throw an error.
I have experienced this issue on a couple of occasions and this has been the cause for the error.

Related

ld: library not found for -lCocoaAsyncSocket - React Native

I have created a new react native project and when I try to run the app within an iOS emulator it always crashes.
When I open the .xcworkspace within Xcode I get the following error.
I have tried to update the search paths but this has not worked, I have also tried to reinstall pods but this hasn't worked.
This must be fixed on the framework side, however, the solution is the following steps:
On the Xcode bring the Build Settings tab
Find the Search Paths and then try to modify Library search paths
Add ${inherited} to the first of the list. It's important to be the first
Delete the build folder inside the ios folder of the project
Try to run the project again
It must fix the issue
This issue is basically related to the wrongly linking classes. Please follow these steps:
check make sure, you have install all the pods.
Please check your .js files, and check your import statements. To be make sure , every import statement package is installed in your project
clean project
Rebuild again
I can see that you state you have already checked search paths, but I had this same issue, and it was resolved by adding "${PODS_CONFIGURATION_BUILD_DIR}" as recursive to my Library Search Paths, under <Project> > Build Settings > Library Search Paths. However, now I'm stuck on the linker instruction -lcrypto, so it's not a complete solution.

Custom Module not found

I'm a beginner in iOS development. I cloned a repo containing working code. I opened up the project in xcode, but when I build the project I receive the error Module 'Subscriptions' not found.
In my build settings, the Subscriptions.framework framework is in Linked Frameworks and Libraries. From what I've researched about module not found errors in xcode, this should be the fix for my problem. However, this is not fixing my problem. This project should normally be able to be built and compiled. Is there something I'm missing here?
Update
Here is the xcode file tree view.
Main
|-Main
|-MainTests
|-Products
|-Frameworks
|-Subscriptions.xcodeproj
|-Subscriptions
|-Products
|-Subscriptions.framework
|-Frameworks
|-Pods
Pods
Ok. I finally figured out what was going on. I dove into the directory I thought that the Susbcriptions.framework was being installed in, and it wasn't there. The directory in the build products path was set to Products/Debug-iphoneos but the Subscriptions.framework was instead being installed into Products/Debug. This made me realize that somewhere in XCode I had the build setting set to build for MacOS instead of iOS. I found the setting and rebuilt my project for an iPhone XS simulator and the module was imported successfully.

Xcode 9 not finding React Native 0.56 or 0.57

I was working on my first React Native NativeModule. A simple 'Hello, World!' Objective-C function just to get an idea of how it worked. Things were going relatively smoothly, however, it seems xcode lost reference to all React Native files. I thought this problem was probably project specific, so I started a new TestApp using react-native init TestApp, but when I open that .xcodeproj file I have the same issue.
The first error in this new TestApp is in the AppDelegate.m file: 'React/RCTBundleURLProvider.h' file not found but as you might expect it avalanches from there.
I spent the most of yesterday trying out all sorts of potential solutions to no avail.
This might be a false lead, but maybe not, however I noticed Header Search Paths is empty whenever I first open .xcodeproj on a newly initialized project. That being said, I have tried numerous search paths based on answers I have found here on StackOverflow, GitHub, etc, the latest being $(SRCROOT)/../node_modules/react-native/React
I know this problem might be a little vague, but any help would be greatly appreciated. As an iOS developer, I am trying my best to be open to React Native, but continually running into issues such as this is really putting a damper on that.
Thanks!
ps. At this point I wonder if reinstalling xcode, node, npm, and react native altogether would be the surest solution.
Edits for clarity
First I run react-native init TestApp and cd TestApp followed by npm install. I've tried running react-native link at this point as well.
I then open ios/TestApp.xcodeproj. After xcode does its usual indexing I will inevitably be greeted by a red 'React/RCTBundleURLProvider.h' file not found in AppDelegate. Sometimes 'React/RCTRootView.' file not found' happens too. Most of the time, even if this second warning doesn't happen, The RCTRootView * in didFinishLaunchingWithOptions is not colored.
If I try to create a native module like so:
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#interface Test : NSObject <RCTBridgeModule>
#end
I get an immediate 'RCTBridgeModule.h' file not found.
In other words, Xcode is not finding anything RCT. Autocomplete doesn't suggest anything RCT.
Even with these warnings, I can run the app from Xcode or by running react-native run-ios.
This extra bit, may or may not be relevant:
If I have import { NativeModules } from 'react-native' in my App.js, NativeModules turns out to be undefined.
My current feeling is that there is a crucial step in set up that is not listed in the RN Docs, and for some reason other tutorials aren't touching either. I tried on another computer to the same result.
"Header search paths" being empty is perfectly normal. RN is exposing its headers from the React project. If you go to React.xcodeproj (under Libraries) you can see that the React target has a "Copy Headers" Build Phase, and these headers are being exposed when packaging the library as public headers.
To make sure that your app can use the headers, go to your app's scheme and into the Build section - the React target should be in the list and before your app's target. Also, the Parallelize Build checkbox needs to be OFF. It should be set-up like this out of the box in new RN projects, but maybe something was changed in your project so it's worth checking.
When the build is just starting, and especially on a freshly initialized project, you can expect to see some errors in the IDE during the build regarding public React headers, but they should be gone and resolved once all React third-party libraries finish building and React itself is packaged.
If everything is set-up correctly and it's still not working, delete the DerivedData folder and build again.
Finally linking native code with react-native!
So, I haven't really solved the precise issue, but I managed a workaround.
Previously I was trying to initialize a react-native project and then modifying the Xcode project that was built in the initialization.
I decided instead to approach the problem from the opposite angle of linking react-native to an existing xcode project by following this documentation: https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
I've been able to repeatedly link native code (both swift and objc) to react-native after react-native init TestApp by erasing the contents of TestApp/ios and following the process in the link above.
Thanks #Artal for providing some valuable info on the way it is supposed to work.

Cocoapod issue not able to run on simulator

I have created my cocoapod and cross check in sample project but it is showing everytime this error.
I googled and found solution
Reset content and setting
Clear derived data
Clean and build
Restart xcode
But non of them works
i tried on device
Make sure you are opening the newly created .workspace file rather than your original project.
Refer to this answer for debugging.
https://stackoverflow.com/a/26129829
Basically you need to look at ~/Library/logs/CoreSimulator/CoreSimulator.log for the source of the errors.
You need to consider the fact that the simulator is not linking files properly than any specific cocoapod issue.
Alternately, the problem could be related to code signing.
Refer : https://stackoverflow.com/a/17402788/2569560
If details like the Podspec and the simulator log were shared, perhaps we could be of more help.

FBDialogClosePNG.h not found in Facebook iOS SDK

I've been trying to upgrade the Facebook iOS SDK used in my app. I cloned the Git repo and copied everything across to the directory containing the old version, and attempted to build the project. However I get the error "FBDialogClosePNG.h" file not found. I can't find that filename anywhere in the repo, or anywhere else through Google. It appears that it is meant to be a wrapper class for an image, since it appears to be called through the following line:
UIImage* closeImage = [FBDialogClosePNG image];
Does anyone know what we're meant to do with this?
Removing Xcode's DerivedData directory and the generated Pods directory fixed this for me.
/Users/{username}/Library/Developer/Xcode/DerivedData
/{YourProject}/Pods
there is a file in the path {FB_SDK_DIR}/scripts/image_to_code.py which will generate a bunch of files including FBDialogClosePNG.h.
To get this file, you need to compile facebook's source codes using src/facebook-ios-sdk.xcodeproj first, then locate the DerivedSources folder, put the whole folder into your project.
And you will need a to switch off a lot of compiler warning before your code could compile. Then you should good to go
For me, it was because my Facebook-iOS-SDK pod didn't get fully updated for whatever reason. I deleted the Facebook-iOS-SDK folder from my Pods folder, then ran pod update again, and now the problem is fixed.
I was getting lots of missing files: FBDialogClosePNG.h, FBLikeButtonPopWAV.h, FBLikeButtonBackgroundPNG.h, FBLoginViewButtonPNG.h, FBPlacePickerViewGenericPlacePNG.h and FBProfilePictureViewBlankProfilePortraitPNG.h.

Resources