I need to add the following code to my main AppDelegate, I have 2 files called AppDelegate, AppDelegate.m, AppDelegate.h, which one do I need to edit?
Neither file has #import they both have #import
#import UIKit;
#import Firebase;
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
return YES;
}
#import is available since iOS 7 and is an improvement on #import (see for example this blogpost for more info). You should be able to use #import Firebase;, but otherwise it'd be #import <Firebase/Firebase.h>
Related
After import the Firebase.h file i wrote "[FIRApp configure]" on "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions". While running on the simulator it is showing "Use of undeclared identifier 'FIRApp'". But if select "Generic iOS device" option for build, no error is coming. Build and Archive working as properly. But on local simulator issue is coming.I have to run the app on Simulator first for crash communications with Firebase server. Please give me solution.enter
In AppDelegate.m file, you should import firebase like #import <Firebase.h> before #ifdef FB_SONARKIT_ENABLED line.
As I understand, You probably get success on dev build because FlipperKit libraries are used for debugging and this #ifdef FB_SONARKIT_ENABLED if condition is satisfied. When you try to archive it will not be imported and the variables will be undeclared because #import <Firebase.h> remains in that if condition.
FIRApp is moved (or initially was) to FirebaseCore framework. So.
#import <FirebaseCore/FirebaseCore.h>.
As stated in this github comment:
What work for me
Just add
#import <Firebase.h> to the AppDelegate.h as well
Source:
I have a same problem but I haven't FB_SONARKIT_ENABLED
#import <React/RCTAppSetupUtils.h>
#if RCT_NEW_ARCH_ENABLED
#import <Firebase.h>
#import <FirebaseCore/FirebaseCore.h>
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <react/config/ReactNativeConfig.h>
static NSString *const kRNConcurrentRoot = #"concurrentRoot";
#interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
RCTTurboModuleManager *_turboModuleManager;
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
facebook::react::ContextContainer::Shared _contextContainer;
}
#end
#endif
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
RCTAppSetupPrepareApp(application);
enter image description here
In the react native firebase docs (see here: https://rnfirebase.io/) it says put the #import <Firebase.h> at the top of the document. You imported #import <Firebase.h> below #if RCT_NEW_ARCH_ENABLED, so you basically import firebase module if the RCT_NEW_ARCH_ENABLED condition is true.
you should do :
#import <Firebase.h>
#import <React/RCTAppSetupUtils.h>
#if RCT_NEW_ARCH_ENABLED
#import <FirebaseCore/FirebaseCore.h>
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <react/config/ReactNativeConfig.h>
I want to capture the iOS native errors to Sentry and also capture some custom messages.
I'm using the sentry-expo library but this only captures javascript errors even with the parameter:
deactivateStacktraceMerging: false
I'v been following the official installation guide https://docs.sentry.io/clients/react-native/ but I'm stuck when trying to configure the AppDelegate.m file
#import "AppDelegate.h"
#import "ExpoKit.h"
#import "EXViewController.h"
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>
#if __has_include(<React/RNSentry.h>)
#import <React/RNSentry.h> // This is used for versions of react >= 0.40
#else
#import "RNSentry.h" // This is used for versions of react < 0.40
#endif
#interface AppDelegate ()
#property (nonatomic, strong) EXViewController *rootViewController;
#end
#implementation AppDelegate
-(EventsObserver*)getEventsObserver
{
return EventsObserver.shared;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Fabric with:#[[Crashlytics class]]];
[application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
_window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
_window.backgroundColor = [UIColor whiteColor];
[[ExpoKit sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
_rootViewController = [ExpoKit sharedInstance].rootViewController;
_window.rootViewController = _rootViewController;
[_window makeKeyAndVisible];
[self getEventsObserver];
[RNSentry installWithRootView:rootView];
return YES;
}
At this point I don't have the rootView object of type RCTRootView. I'm using a EXViewController and the library does not support that type of object to invoke the function installWithRootView. Am I following a wrong path?
I have included the API Frameworks but still get error : Use of undeclared identifier 'QBSettings' in AppDelegate.m file.
#import <FYX/FYX.h>
#import "AppDelegate.h"
#import "ApplicationContext.h"
#import "EnableProximityViewController.h"
#import "LoginViewController.h"
#implementation AppDelegate
#synthesize window = _window;
#synthesize loginViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Set QuickBlox credentials (You must create application in admin.quickblox.com)
[QBSettings setApplicationID:11948];
[QBSettings setAuthorizationKey:#"SHdXhhjVY7BL-GtGH"];
[QBSettings setAuthorizationSecret:#"3ZYjkXTzaUfd6kLTL"];
[QBSettings setAccountKey:#"yFHpgFbxe3hjkMXmjs9sv9u"];
Found the answer...
Go to App-Name.pch then add the import to the Framework file. This is how it links back.
#import <Quickblox/Quickblox.h>
I am trying to migrate a UIViewController Objective-C class to Swift. This view controller is inheriting from a BaseViewController where I have common functionality that I want to have in all controllers. The problem I am having is that the generated myproject-Swift.h is not able to find my BaseViewController.
Is there any way to implement a UIViewController in swift that inherits from a BaseViewController (subclass of UIViewController) written in Objective-C? Is there a bridging problem?
It can be reproduced with this minimal code:
BaseViewController.h
#import <UIKit/UIKit.h>
#interface BaseViewController : UIViewController
#end
BaseViewController.m
import "BaseViewController.h"
#implementation BaseViewController
#end
ViewController.swift
import UIKit
class ViewController : BaseViewController {
}
AppDelegate.m
#import "AppDelegate.h"
#import "projectname-Swift.h" // Replace with your project name
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
ViewController *vc = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
return YES;
}
projectname-Bridging-Header.h
#import "BaseViewController.h"
As pointed out in the accepted answer on How can I add forward class references used in the -Swift.h header?
Interoperability guide (Importing Swift into Objective-C):
If you use your own Objective-C types in your Swift code, make sure to
import the Objective-C headers for those types prior to importing the
Swift generated header into the Objective-C .m file you want to access
the Swift code from.
The example is solved by importing BaseViewController before the importing projectname-Swift.h in:
AppDelegate.m
#import "AppDelegate.h"
#import "BaseViewController.h"
#import "projectname-Swift.h" // Replace with your project name
// ...
It looks like they have fixed the issue. Currently under XCode6-Beta6 the problem reported by #atxe does not occur anymore. Therefor you can finally roll your AppDelegate.m header back to:
#import "AppDelegate.h"
#import "projectname-Swift.h" // Replace with your project name
I'm trying to test my core data scheme. However, it seems I am unable to create the context because it says No visible #interface for 'MyAppDelegate' declares the selector 'managedObjectContext'.
In online tutorials this method seems to be auto-generated when we create the app. However, in my case it doesn't exist.
This is MyAppDelegate:
Header
#import <UIKit/UIKit.h>
#interface MyAppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
.m file
#import "MyAppDelegate.h"
#implementation MyAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSManagedObjectContext *context = [self managedObjectContext];
// Override point for customization after application launch.
return YES;
}
How should I fix this in Xcode 5 with iOS 7?
I think the best way for you is to create a Master-Detail Application with Xcode 5 and don't forget to check Use Core Data :
With that, you will have an AppDelegate.h and an AppDelegate.m configured with a managedObjectContext.
You will have a project configured correctly with Core Data and a .xcdatamodeld to use easily your SQLite database.