Issue with React-native share extension with cocoapods for firebase - ios

I'm trying to implement a share extension with a firebase-based app. So I have created a pod file and generated a .xcworkspace project.
I'm using [react-native-share-extension][1]. Followed all installation tutorial and all seem ok, but when I try to launch the extension Xcode console says:
RNFirebase core module was not found natively on iOS, ensure you have correctly included the RNFirebase pod in your projects 'Podfile' and have run 'pod install'.
This is my pod file:
target 'Together' do
# Pods for Together
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Messaging'
pod 'Firebase/Storage'
pod "QBImagePickerController"
end
target 'TogetherShareEx' do
# Pods for TogetherShareEx
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
end
And this my TogetherShareEx.m:
#import <Foundation/Foundation.h>
#import "ReactNativeShareExtension.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLog.h>
#import <Firebase.h>
#interface TogetherShareEx : ReactNativeShareExtension
#end
#implementation TogetherShareEx
RCT_EXPORT_MODULE();
- (UIView*) shareView {
NSURL *jsCodeLocation;
[FIRApp configure];
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:#"TogetherShareEx"
initialProperties:nil
launchOptions:nil];
rootView.backgroundColor = nil;
return rootView;
}
#end
I have also added these:
added '$(inherited)' in Other Linker Flags
added '$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase' in Header Search Paths
The result is that extension is created but when I try to share something, nothing happens. On Debugging the extension with Xcode the log shows the error shown above.
Any idea? Thanks

I was able to get this working after following the standard installation instructions, make sure you do the following:
Link libRNFirebase.a in your Extension's Build Phases. Also, make sure that libPods-{YOUR_EXTENSION_NAME}.a is linked as well.
Set the GoogleService-Info.plist target for both your main app
and your share extension in the right panel.
In your share extension's Build Settings > Other Linker Flags,
make sure you add $(inherited)
In your Share Extension .m file, make sure you import
Firebase and configure it there as well!
For more info, see the following GitHub thread: https://github.com/alinz/react-native-share-extension/issues/79

Related

React Native 'GoogleMaps/GoogleMaps.h' file not found in AppDelegate.m:

Environment info
"react": "17.0.2",
"react-native": "0.66.3"
"react-native-maps": "^0.29.4"
XCode Version 13.1 (13A1030d)
macOS 12.0.1
Target Platform iOS 15.1 Phone using GoogleMaps
Steps to reproduce
Create new project
Add config = use_native_modules! in the Podfile
Add in the Podfile:
react-native-maps dependencies
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
pod install
Add in AppDelegate.m:
#import "AppDelegate.h"
#import <GoogleMaps/GoogleMaps.h>
#import <GooglePlaces/GooglePlaces.h>
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
[GMSServices provideAPIKey:#"xxxx"];
[GMSPlacesClient provideAPIKey:#"xxxx"];
}
Build in XCode
Describe what you expected to happen:
Build successful
Describe what you actually happens:
/ios/UbiWalkerReactNat/AppDelegate.m:2:9: 'GoogleMaps/GoogleMaps.h' file not found
you need to first import import <GoogleMaps/GoogleMaps.h> in AppDelegate.m see here.
Seems to be solved, there was a WARNING on pod install:
[!] The xxx [Debug] target overrides the FRAMEWORK_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-xxx-xxx/Pods-xxx-xxx.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the $(inherited)` flag, or
Remove the build settings from the target.
I've SOLVED with $(inherited) flag on Build Settings.

react native splash screen get 'React/RCTBridgeModule.h' file not found

I started a new react native application using :
react-native init myApplication
I started with splash screen so i used this library react native spalsh screen
I linked the library to generate native code using this command :
react-native link react-native-splash-screen
And i added files using Xcode like this :
In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
Go to node_modules ➜ react-native-splash-screen and add SplashScreen.xcodeproj
In XCode, in the project navigator, select your project. Add libSplashScreen.a to your project's Build Phases ➜ Link Binary With Libraries
To fix 'RNSplashScreen.h' file not found, you have to select your project → Build Settings → Search Paths → Header Search Paths to add: $(SRCROOT)/../node_modules/react-native-splash-screen/ios
I build the app using Xcode in a real Iphone and i get this error in RNSplashScreen.h :
/**
* SplashScreen
* 启动屏
* from:http://www.devio.org
* Author:CrazyCodeBoy
* GitHub:https://github.com/crazycodeboy
* Email:crazycodeboy#gmail.com
*/
#import <React/RCTBridgeModule.h> // <------'React/RCTBridgeModule.h' file not found
#import <UIKit/UIKit.h>
#interface RNSplashScreen : NSObject<RCTBridgeModule>
+ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView;
+ (void)show;
+ (void)hide;
#end
'React/RCTBridgeModule.h' file not found
the Podfile :
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
...... # other libaries
pod 'react-native-splash-screen', :path => '../node_modules/react-
native-splash-screen'
AppDelegate.m :
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNSplashScreen.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
.... <------- other code
[RNSplashScreen show];
return YES;
}
Instead of
#import <React/RCTBridgeModule.h>
use
#import "RCTBridgeModule.h"
Hope this helps you. Feel free for doubts.

react native the [[DEFAULT]] firebaseapp is not initialized react-native-firebase

I am trying to use react-native-firebase module with react native.
Error I am getting:
Steps I followed:
Step1: Created basic app
react-native init myFirebaseApp
Moved to project
cd myFirebaseApp
Installed module
npm install --save react-native-firebase
Step 2: Setup Firebase SDK (https://rnfirebase.io/docs/v4.2.x/installation/ios)
created firebase app and downloaded GoogleService-Info.plist for iOS
copied
GoogleService-Info.plist
in project, then
pod init
Add these line to pod file
pod 'Firebase/Core'
pod 'Firebase/Firestore'
Installed dependencies
pod install
and finally linked library
react-native link
Someone can guide me what I am missing or doing wrong?
Modify your AppDelegate.h and AppDelegate.m files
In AppDelegate.h add this,
#import <Firebase.h>
And in AppDelegate.m add [FIRApp configure];
#import <React/RCTRootView.h>
#import <ReactNativeNavigation/ReactNativeNavigation.h>
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure]; // <=== Add this line
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"index" fallbackResource:nil];
[ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];
return YES;
}
#end

"Error failed to import bridging header" when installing the app on device while working fine for simulator

I'm very new to iOS and I'm coming from the Android background. I've read many post about this issue but I'm unable to resolve this issue.
My problem is that the app runs fine on the iPhone simulator but while running on the device it gives me following error -
error: 'AFNetworking.h' file not found
#import "AFNetworking.h"
^
<unknown>:0: error: failed to import bridging header ‘path/to/project/<main project directory>/projectName-Bridging-Header.h'
Update:
platform :ios, '7.0'
use_frameworks!
target 'SomeTarget' do
pod 'AFNetworking'
pod 'MSDynamicsDrawerViewController'
pod 'KRLCollectionViewGridLayout', '~> 0.2.0'
pod 'Canvas'
pod 'MBProgressHUD'
pod 'RBMenu'
pod 'RKTabView'
pod 'AHTabBarController'
pod 'Fabric'
pod 'Crashlytics'
end
My Bridging Header File
#import "AFNetworking.h"
#import "UIKit+AFNetworking.h"
#import "MSDynamicsDrawerStyler.h"
#import "KRLCollectionViewGridLayout.h"
#import "Canvas.h"
#import "MBProgressHUD.h"
#import "UIScrollView+TwitterCover.h"
#import "A3ParallaxScrollView.h"
#import "ParallaxHeaderView.h"
#import "UIImage+ImageEffects.h"
#import "SGFocusImageFrame.h"
#import "RBMenu.h"
#import "ILBarButtonItem.h"
#import "CMPopTipView.h"
#import "RKTabView.h"
#import "AHTabBarController.h"
#import "UIViewController+MJPopupViewController.h"
#import "NSString+FontAwesome.h"
#import “KMAccordionTableViewController.h"
#import <Crashlytics/Crashlytics.h>
Can you please point the issue I'm getting right now. Why it is running fine on emulator and not on actual device?
This might help somebody.
I've fixed this issue by adding an entry for Header Search Paths to "${PODS_ROOT}/" with recursive. Thanks to lostInTransit for pointing this attribute.
You can find Header Search Paths under BuildSettings for your project target.

InstagramKit integration in swift project

As suggest title, I need to use InstagramKit (3.5.0) pod (written in objective-c) in a new swift project.
So I install pod (pod install), then I create my InstagramSwift-Bridging-Header.h and add-import library:
#import <InstagramKit/InstagramEngine.h>
Then, just building this empty project, I get:
/Users/.../workspace/InstagramSwift/InstagramSwift/InstagramSwift-Bridging-Header.h:5:9:
note: in file included from
/Users/.../workspace/InstagramSwift/InstagramSwift/InstagramSwift-Bridging-Header.h:5:
-(BOOL)application:(UIApplication *)application
^ <unknown>:0:
error: failed to import bridging header
'/Users/.../workspace/InstagramSwift/InstagramSwift/InstagramSwift-Bridging-Header.h'
Expected a type Failed to import bridging header
'/Users/.../workspace/InstagramSwift/InstagramSwift/InstagramSwift-Bridging-Header.h'
What could I miss?
After a lot of discussions with #eric-d, I probably find the problem in my podfile that was:
target "InstagramSwift" do
pod 'InstagramKit', '3.5.0'
end
So I deleted project and start again from an empty project using Podfile:
use_frameworks!
platform :ios, '8.0'
pod 'AFNetworking', '~> 2.5'
pod 'InstagramKit', '3.5.0'
Than I manually created SwitBridge.h and linked it in build settings.
Finally, in any swift file I can use instagramKit module, for example:
import InstagramKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let instagramEngine: InstagramEngine = InstagramEngine.sharedEngine()
}
}
Probably, problem was that platform setting is missing.
edit
Also,
"use_frameworks!"
thanks to this answer.

Resources