Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Facebook Login Error / Build Failed #646

Closed
zoeitsolutions opened this issue Nov 25, 2017 · 5 comments
Closed

iOS Facebook Login Error / Build Failed #646

zoeitsolutions opened this issue Nov 25, 2017 · 5 comments

Comments

@zoeitsolutions
Copy link

Issue

Hi. I got Firebase Auth working with Email/Password. I then tried implementing Facebook login as per https://rnfirebase.io/docs/v3.1.*/auth/social-auth#Facebook by installing and configuring the react-native-fbsdk

When calling the facebookLogin function, I get the following error:

Cannot read property 'loginInWithReadPermissions' of undefined.

screen shot 2017-11-25 at 12 36 37 pm

PODFILE:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'TestApp' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for TestApp

  # Required by RNFirebase
  pod 'Firebase/Core'
  pod 'Firebase/Auth'

  target 'TestAppTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'TestApp-tvOS' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for TestApp-tvOS

  target 'TestApp-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

INFO.PLIST:

<key>CFBundleURLTypes</key>
	<array>
		<dict>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>fb1772011746413220</string>
		</array>
		</dict>
	</array>
	<key>FacebookAppID</key>
	<string>1772011746413220</string>
	<key>FacebookDisplayName</key>
	<string>TestApp</string>

AppDelegate.m


/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
#import <Firebase.h>
#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  //firebase
  [FIRApp configure];
  //facebook
  [[FBSDKApplicationDelegate sharedInstance] application:application
    didFinishLaunchingWithOptions:launchOptions];
  
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"TestApp"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

- (BOOL)application:(UIApplication *)application 
            openURL:(NSURL *)url 
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {

  BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
    openURL:url
    sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
    annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
  ];
  // Add any custom logic here.
  return handled;
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

@end

I did follow all the steps outlined by Facebook, but I am not sure if I correctly inserted the code into the AppDelegate.m file.

I also started getting this error when running react-native run-ios command:


ld: warning: object file (/Library/WebServer/Documents/xxx/xxx/ios/build/Build/Products/Debug-iphonesimulator/libPods-TestApp.a(Pods-TestApp-dummy.o)) was built for newer iOS version (9.0) than being linked (8.0)
ld: framework not found FileProvider for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **


The following build commands failed:

	Ld build/Build/Products/Debug-iphonesimulator/TestApp.app/TestApp normal x86_64
(1 failure)

Environment

  1. Application Target Platform: iOS

  2. Development Operating System: macOS EL Capitan

  3. Build Tools:
    xCode 8.3.1
    react-native-cli: 2.0.1

  4. React Native version: 0.49.3

  5. RNFirebase Version: 3.1.0

  6. Firebase Module: Auth

@devagul93
Copy link

devagul93 commented Nov 26, 2017

I am Facing the same issue.
It is working on Android, I am running it on Simulator, arranging Ios device for testing. Is it because of that ?

@zoeitsolutions
Copy link
Author

@devagul93 I am not sure. From my understanding it's suppose to work in the emulator, it would simply revert to the website version instead of opening the Facebook app.

I am going to do a fresh build and then test on my iPhone and see what happens.

Are you getting any build errors? And could you confirm your podfile and appdelegate file?

@devagul93
Copy link

devagul93 commented Nov 27, 2017

@zoeitsolutions
Just resolved my issue.
Had the folder ~/Documents/FacebookSDK wrong,
After that I Repeated the steps below:
1)Drag FBSDKCoreKit and FBSDKLoginKit to Frameworks in Project Navigator.
2)Open Xcode's Build Settings tab in your project.
3)Add ~/Documents/FacebookSDK to the project's Framework Search Paths.
Recompiled and then everything was working fine.

Podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'Rudralife' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for Rudralife

  target 'RudralifeTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'Rudralife-tvOS' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for Rudralife-tvOS

  target 'Rudralife-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
pod 'Firebase/Performance'
pod 'Firebase/Crash'
pod 'Firebase/RemoteConfig'


AppDelegate.m

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>

@implementation AppDelegate

  - (void)applicationDidBecomeActive:(UIApplication *)application {
    [FBSDKAppEvents activateApp];
  }
  
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

  NSURL *jsCodeLocation;
  [FIRApp configure];
  [[FBSDKApplicationDelegate sharedInstance] application:application
                           didFinishLaunchingWithOptions:launchOptions];
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Rudralife"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}
  
  - (BOOL)application:(UIApplication *)application
              openURL:(NSURL *)url
    sourceApplication:(NSString *)sourceApplication
           annotation:(id)annotation {
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
  }

@end

Hope this helps

@zoeitsolutions
Copy link
Author

@devagul93 thank you, will have a look and close if it's fixed.

@chrisbianca
Copy link
Contributor

I'm going to close this as it seems to be a react-native-fbsdk setup issue rather than anything react-native-firebase related. If this turns out to be a issue with RNFirebase, please re-open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants