facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 908 forks source link

'React/RCTComponentEvent.h' file not found #493

Open eyale opened 5 years ago

eyale commented 5 years ago
"react": "^16.7.0-alpha.2",
"react-native": "0.57.5",
"react-native-fbsdk": "github:facebook/react-native-fbsdk",

** BUILD FAILED **

The following build commands failed:

    CompileC /Users/${user}/Development/${project}/ios/build/Build/Intermediates.noindex/RCTFBSDK.build/Debug-iphonesimulator/RCTFBSDK.build/Objects-normal/x86_64/RCTFBSDKLoginButtonManager.o RCTFBSDK/login/RCTFBSDKLoginButtonManager.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

There issue fixing by reverting file to previous changes from commit: https://github.com/facebook/react-native-fbsdk/commit/3eb205e1d2a7ae738ef06ea2167687df461490a7#diff-9892e5bfd3fb7155d5e3ba386aac866b

Samykills commented 5 years ago

any uupdate here?

Samykills commented 5 years ago

For me the file does not exist in DerivedData../../../include/React/

eyale commented 5 years ago

my solution is going to node_modules/react-native-fbsdk/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.m change to


#import "RCTFBSDKLoginButtonManager.h"

#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>

#import "RCTConvert+FBSDKLogin.h"

@implementation RCTFBSDKLoginButtonManager

RCT_EXPORT_MODULE(RCTFBLoginButton)

#pragma mark - Object Lifecycle

- (UIView *)view
{
    FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
    loginButton.delegate = self;
    return loginButton;
}

#pragma mark - Properties

RCT_EXPORT_VIEW_PROPERTY(readPermissions, NSStringArray)

RCT_EXPORT_VIEW_PROPERTY(publishPermissions, NSStringArray)

RCT_CUSTOM_VIEW_PROPERTY(loginBehaviorIOS, FBSDKLoginBehavior, FBSDKLoginButton)
{
    [view setLoginBehavior:json ? [RCTConvert FBSDKLoginBehavior:json] : FBSDKLoginBehaviorNative];
}

RCT_EXPORT_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience)

RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, FBSDKLoginButton)
{
    [view setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
}

#pragma mark - FBSDKLoginButtonDelegate

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
    NSDictionary *event = @{
                           @"type": @"loginFinished",
                           @"target": loginButton.reactTag,
                           @"error": error ? RCTJSErrorFromNSError(error) : [NSNull null],
                           @"result": error ? [NSNull null] : @{
                                   @"isCancelled": @(result.isCancelled),
                                   @"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
                                   @"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
                                   },
                           };

     [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event];
    [self.bridge.eventDispatcher sendEvent:event];
}

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{
    NSDictionary *event = @{
                            @"target": loginButton.reactTag,
                           };

    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event];
    [self.bridge.eventDispatcher sendEvent:event];
}

@end
Samykills commented 5 years ago

thats great, i wonder why i cant find the RCTComponentEvent file itself :/

eyale commented 5 years ago

Or in package.json replace package version to previous commit

"react-native-fbsdk": "github:facebook/react-native-fbsdk#5fe8e726966faf83d3388af85dd9740f4015e5d6",
kesha-antonov commented 5 years ago

Same issue

kesha-antonov commented 5 years ago

@hramos Hey! Any fix for this?

I need to use different commits for ios & android to build my app.

beeremy commented 5 years ago

same issue here, any help would be very appreciated

mcgloneleviROOT commented 5 years ago

I am also experiencing this issue.

mcgloneleviROOT commented 5 years ago

I think I figured out what is happening. Inside my app's pod spec, I was referencing the dependency like so:

pod 'react-native-fbsdk', :podspec => node_modules_path + '/react-native-fbsdk/react-native-fbsdk.podspec'

This is bad because it will pull the latest commit from master. Instead of doing it this way, I referenced the path:

pod 'react-native-fbsdk', :path => node_modules_path + '/react-native-fbsdk'

This solved my issue.

chatarveer commented 5 years ago

This I tried with all above solutions. Its yet same. I am on rc1, I tried 0.8.0. 0.9.0, nothing works. Any update?

roshan-p commented 5 years ago

1.0.0-rc.3 still have this problem.

kesha-antonov commented 5 years ago

We need to wait while RN team will release React/RCTComponentEvent.h component, right? Before that we stuck with old version of fbsdk?

kesha-antonov commented 5 years ago

Based on @eyale

// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
//
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
// copy, modify, and distribute this software in source code or binary form for use
// in connection with the web services and APIs provided by Facebook.
//
// As with any software that integrates with the Facebook platform, your use of
// this software is subject to the Facebook Developer Principles and Policies
// [http://developers.facebook.com/policy/]. This copyright notice shall be
// included in all copies or substantial portions of the software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#import "RCTFBSDKLoginButtonManager.h"

#import <React/RCTBridge.h>
//#import <React/RCTComponentEvent.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>

#import "RCTConvert+FBSDKLogin.h"

@implementation RCTFBSDKLoginButtonManager

RCT_EXPORT_MODULE(RCTFBLoginButton)

#pragma mark - Object Lifecycle

- (UIView *)view
{
  FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
  loginButton.delegate = self;
  return loginButton;
}

#pragma mark - Properties

RCT_EXPORT_VIEW_PROPERTY(permissions, NSStringArray)

RCT_CUSTOM_VIEW_PROPERTY(loginBehaviorIOS, FBSDKLoginBehavior, FBSDKLoginButton)
{
  [view setLoginBehavior:json ? [RCTConvert FBSDKLoginBehavior:json] : FBSDKLoginBehaviorBrowser];
}

RCT_EXPORT_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience)

RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, FBSDKLoginButton)
{
  [view setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
}

#pragma mark - FBSDKLoginButtonDelegate

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
  NSDictionary *body = @{
    @"type": @"loginFinished",
    @"error": error ? RCTJSErrorFromNSError(error) : [NSNull null],
    @"result": error ? [NSNull null] : @{
      @"isCancelled": @(result.isCancelled),
      @"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
      @"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
    },
  };

    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:body];
//  RCTComponentEvent *event = [[RCTComponentEvent alloc] initWithName:@"topChange"
//                                                             viewTag:loginButton.reactTag
//                                                                body:body];
//  [self.bridge.eventDispatcher sendEvent:event];
}

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{
  NSDictionary *body = @{
    @"type": @"logoutFinished",
  };

    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:body];
//  RCTComponentEvent *event = [[RCTComponentEvent alloc] initWithName:@"topChange"
//                                                             viewTag:loginButton.reactTag
//                                                                body:body];
//  [self.bridge.eventDispatcher sendEvent:event];
}

@end

Is this correct?

jdnichollsc commented 5 years ago

Same issue here using 1.0.0-rc.4:

node_modules/react-native-fbsdk/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.m:22:9: fatal error: 'React/RCTComponentEvent.h' file not found
#import <React/RCTComponentEvent.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
marf commented 5 years ago

Same problem here

kesha-antonov commented 5 years ago

My current solution: 1. Add to Podfile:

post_install do |installer|
    fix_fb
end

def fix_fb
    node_modules_path = '../node_modules'
    patched_text = File.read("./RCTFBSDKLoginButtonManager.m.patch")

    File.open("#{node_modules_path}/react-native-fbsdk/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.m", "w") {|file| file.puts patched_text}
end

2. Add file yourProject/ios/RCTFBSDKLoginButtonManager.m.patch

// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
//
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
// copy, modify, and distribute this software in source code or binary form for use
// in connection with the web services and APIs provided by Facebook.
//
// As with any software that integrates with the Facebook platform, your use of
// this software is subject to the Facebook Developer Principles and Policies
// [http://developers.facebook.com/policy/]. This copyright notice shall be
// included in all copies or substantial portions of the software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#import "RCTFBSDKLoginButtonManager.h"

#import <React/RCTBridge.h>
//#import <React/RCTComponentEvent.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>

#import "RCTConvert+FBSDKLogin.h"

@implementation RCTFBSDKLoginButtonManager

RCT_EXPORT_MODULE(RCTFBLoginButton)

#pragma mark - Object Lifecycle

- (UIView *)view
{
  FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
  loginButton.delegate = self;
  return loginButton;
}

#pragma mark - Properties

RCT_EXPORT_VIEW_PROPERTY(permissions, NSStringArray)

RCT_CUSTOM_VIEW_PROPERTY(loginBehaviorIOS, FBSDKLoginBehavior, FBSDKLoginButton)
{
  [view setLoginBehavior:json ? [RCTConvert FBSDKLoginBehavior:json] : FBSDKLoginBehaviorBrowser];
}

RCT_EXPORT_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience)

RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, FBSDKLoginButton)
{
  [view setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
}

#pragma mark - FBSDKLoginButtonDelegate

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
  NSDictionary *body = @{
    @"type": @"loginFinished",
    @"error": error ? RCTJSErrorFromNSError(error) : [NSNull null],
    @"result": error ? [NSNull null] : @{
      @"isCancelled": @(result.isCancelled),
      @"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
      @"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
    },
  };

    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:body];
//  RCTComponentEvent *event = [[RCTComponentEvent alloc] initWithName:@"topChange"
//                                                             viewTag:loginButton.reactTag
//                                                                body:body];
//  [self.bridge.eventDispatcher sendEvent:event];
}

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{
  NSDictionary *body = @{
    @"type": @"logoutFinished",
  };

    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:body];
//  RCTComponentEvent *event = [[RCTComponentEvent alloc] initWithName:@"topChange"
//                                                             viewTag:loginButton.reactTag
//                                                                body:body];
//  [self.bridge.eventDispatcher sendEvent:event];
}

@end

3. cd ios && pod install

crispywong commented 5 years ago

Same issue here using

"react-native-fbsdk": "1.0.0-rc.4",
"react-native": "0.60.0",

Have tried @kesha-antonov method and having error

/node_modules/react-native-fbsdk/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.m:56:35: No visible @interface for 'RCTEventDispatcher' declares the selector 'sendInputEventWithName:body:'

Any help would be very appreciated.

panvourtsis commented 5 years ago

same issue with me using

"react-native-fbsdk": "1.0.0-rc.5", "react-native": "0.60.0",

any suggestion would be very helpful.

roshan-p commented 5 years ago

Now I'm downgrade it to "react-native-fbsdk": "0.8.0", "react-native": "0.59.0" and it is working fine. But you will have change some Old build artifact to AndroidX build artifact by yourself. ( This is just a temporary solution for me )

uguraktas commented 5 years ago

my solution is going to node_modules/react-native-fbsdk/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.m change to


#import "RCTFBSDKLoginButtonManager.h"

#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>

#import "RCTConvert+FBSDKLogin.h"

@implementation RCTFBSDKLoginButtonManager

RCT_EXPORT_MODULE(RCTFBLoginButton)

#pragma mark - Object Lifecycle

- (UIView *)view
{
    FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
    loginButton.delegate = self;
    return loginButton;
}

#pragma mark - Properties

RCT_EXPORT_VIEW_PROPERTY(readPermissions, NSStringArray)

RCT_EXPORT_VIEW_PROPERTY(publishPermissions, NSStringArray)

RCT_CUSTOM_VIEW_PROPERTY(loginBehaviorIOS, FBSDKLoginBehavior, FBSDKLoginButton)
{
    [view setLoginBehavior:json ? [RCTConvert FBSDKLoginBehavior:json] : FBSDKLoginBehaviorNative];
}

RCT_EXPORT_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience)

RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, FBSDKLoginButton)
{
    [view setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
}

#pragma mark - FBSDKLoginButtonDelegate

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
    NSDictionary *event = @{
                           @"type": @"loginFinished",
                           @"target": loginButton.reactTag,
                           @"error": error ? RCTJSErrorFromNSError(error) : [NSNull null],
                           @"result": error ? [NSNull null] : @{
                                   @"isCancelled": @(result.isCancelled),
                                   @"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
                                   @"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
                                   },
                           };

     [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event];
    [self.bridge.eventDispatcher sendEvent:event];
}

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{
    NSDictionary *event = @{
                            @"target": loginButton.reactTag,
                           };

    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event];
    [self.bridge.eventDispatcher sendEvent:event];
}

@end

I have a this problem use of undeclared identifier 'FBSDKLoginBehaviorNative'; did you mean 'FBSDKLoginBehaviorBrowser'?

platenger commented 5 years ago

Hi everybody, my solution was this:

1) change the line with the import in RCTFBSDKLoginButtonManager.m:

import <React/RCTComponentEvent.h>

changed to:

import "RCTComponentEvent.h"

2) select project RCTFBSDK.xcodeproj, select target RCTFBSDK, select Build Settings, search for 'header', select 'Header Search Paths' and add this new line: '${SRCROOT}/../../../node_modules/react-native/React/Base', as non-recursive.

In this way, the FB SDK project can find the file. Hope it helps.

msqar commented 5 years ago

@platenger didn't work for me :( throws other errors

BaderSerhan commented 5 years ago

I am having this error as well. I am on

react-native: 0.60.5
react: 16.9.0
react-native-fbsdk: git+https://github.com/facebook/react-native-fbsdk.git

Adding RCTComponentEvent.h to Copy Headers under React target as suggested here solves the problem for me.

However, every time I run yarn or npm, the Libraries are reset and I have to add the header again. Anyone knows if I can solve this, or should I wait till react-native adds the header to the React project and pushes an update?

msqar commented 5 years ago

@BaderSerhan THIS! yes, i'm also under the same situation. It works fine but the change can be easily reverted. I want to know if there's a way too.

oded-regev commented 5 years ago

@crispywong I think I have the solution for you, based on @kesha-antonov fix:

"react-native-fbsdk": "1.0.1", "react-native": "0.60.4",
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
//
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
// copy, modify, and distribute this software in source code or binary form for use
// in connection with the web services and APIs provided by Facebook.
//
// As with any software that integrates with the Facebook platform, your use of
// this software is subject to the Facebook Developer Principles and Policies
// [http://developers.facebook.com/policy/]. This copyright notice shall be
// included in all copies or substantial portions of the software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#import "RCTFBSDKLoginButtonManager.h"

#import <React/RCTBridge.h>
//#import <React/RCTComponentEvent.h>
//#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>

#import "RCTConvert+FBSDKLogin.h"

@implementation RCTFBSDKLoginButtonManager

RCT_EXPORT_MODULE(RCTFBLoginButton)

#pragma mark - Object Lifecycle

- (UIView *)view
{
  FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
  loginButton.delegate = self;
  return loginButton;
}

#pragma mark - Properties

RCT_EXPORT_VIEW_PROPERTY(permissions, NSStringArray)

RCT_CUSTOM_VIEW_PROPERTY(loginBehaviorIOS, FBSDKLoginBehavior, FBSDKLoginButton)
{
  [view setLoginBehavior:json ? [RCTConvert FBSDKLoginBehavior:json] : FBSDKLoginBehaviorBrowser];
}

RCT_EXPORT_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience)

RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, FBSDKLoginButton)
{
  [view setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
}

#pragma mark - FBSDKLoginButtonDelegate

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
  NSDictionary *body = @{
    @"type": @"loginFinished",
    @"error": error ? RCTJSErrorFromNSError(error) : [NSNull null],
    @"result": error ? [NSNull null] : @{
      @"isCancelled": @(result.isCancelled),
      @"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
      @"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
    },
  };

//    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:body];
//  RCTComponentEvent *event = [[RCTComponentEvent alloc] initWithName:@"topChange"
//                                                             viewTag:loginButton.reactTag
//                                                                body:body];
//  [self.bridge.eventDispatcher sendEvent:event];
}

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{
  NSDictionary *body = @{
    @"type": @"logoutFinished",
  };

//    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:body];
//  RCTComponentEvent *event = [[RCTComponentEvent alloc] initWithName:@"topChange"
//                                                             viewTag:loginButton.reactTag
//                                                                body:body];
//  [self.bridge.eventDispatcher sendEvent:event];
}

@end
msqar commented 5 years ago

@crispywong I think I have the solution for you, based on @kesha-antonov fix:

"react-native-fbsdk": "1.0.1", "react-native": "0.60.4",
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
//
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
// copy, modify, and distribute this software in source code or binary form for use
// in connection with the web services and APIs provided by Facebook.
//
// As with any software that integrates with the Facebook platform, your use of
// this software is subject to the Facebook Developer Principles and Policies
// [http://developers.facebook.com/policy/]. This copyright notice shall be
// included in all copies or substantial portions of the software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#import "RCTFBSDKLoginButtonManager.h"

#import <React/RCTBridge.h>
//#import <React/RCTComponentEvent.h>
//#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>

#import "RCTConvert+FBSDKLogin.h"

@implementation RCTFBSDKLoginButtonManager

RCT_EXPORT_MODULE(RCTFBLoginButton)

#pragma mark - Object Lifecycle

- (UIView *)view
{
  FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
  loginButton.delegate = self;
  return loginButton;
}

#pragma mark - Properties

RCT_EXPORT_VIEW_PROPERTY(permissions, NSStringArray)

RCT_CUSTOM_VIEW_PROPERTY(loginBehaviorIOS, FBSDKLoginBehavior, FBSDKLoginButton)
{
  [view setLoginBehavior:json ? [RCTConvert FBSDKLoginBehavior:json] : FBSDKLoginBehaviorBrowser];
}

RCT_EXPORT_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience)

RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, FBSDKLoginButton)
{
  [view setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
}

#pragma mark - FBSDKLoginButtonDelegate

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
  NSDictionary *body = @{
    @"type": @"loginFinished",
    @"error": error ? RCTJSErrorFromNSError(error) : [NSNull null],
    @"result": error ? [NSNull null] : @{
      @"isCancelled": @(result.isCancelled),
      @"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
      @"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
    },
  };

//    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:body];
//  RCTComponentEvent *event = [[RCTComponentEvent alloc] initWithName:@"topChange"
//                                                             viewTag:loginButton.reactTag
//                                                                body:body];
//  [self.bridge.eventDispatcher sendEvent:event];
}

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{
  NSDictionary *body = @{
    @"type": @"logoutFinished",
  };

//    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:body];
//  RCTComponentEvent *event = [[RCTComponentEvent alloc] initWithName:@"topChange"
//                                                             viewTag:loginButton.reactTag
//                                                                body:body];
//  [self.bridge.eventDispatcher sendEvent:event];
}

@end

Please don't tell me this isn't the definitive "fix" for this issue. I don't want to start commenting out 3rd party library code to build my app. What's missing? for Facebook to release a version where this ComponentEvent.h is added into the React.xcodeproj headers?

terence612 commented 5 years ago

Based on suggestions provided by @kesha-antonov @oded-regev

For me, with the environment

react-native-cli: 2.0.1
react-native: 0.59.10
react-native-fbsdk: 1.0.2

The project can be normally complied with below changes.

RCTFBSDKLoginButtonManager.m

#import "RCTFBSDKLoginButtonManager.h"

#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>

#import "RCTConvert+FBSDKLogin.h"

@implementation RCTFBSDKLoginButtonManager

RCT_EXPORT_MODULE(RCTFBLoginButton)

#pragma mark - Object Lifecycle

- (UIView *)view
{
    FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
    loginButton.delegate = self;
    return loginButton;
}

#pragma mark - Properties

RCT_EXPORT_VIEW_PROPERTY(readPermissions, NSStringArray)

RCT_EXPORT_VIEW_PROPERTY(publishPermissions, NSStringArray)

RCT_CUSTOM_VIEW_PROPERTY(loginBehaviorIOS, FBSDKLoginBehavior, FBSDKLoginButton)
{
    [view setLoginBehavior:json ? [RCTConvert FBSDKLoginBehavior:json] : FBSDKLoginBehaviorBrowser];
}

RCT_EXPORT_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience)

RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, FBSDKLoginButton)
{
    [view setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
}

#pragma mark - FBSDKLoginButtonDelegate

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
    NSDictionary *event = @{
                            @"type": @"loginFinished",
                            @"target": loginButton.reactTag,
                            @"error": error ? RCTJSErrorFromNSError(error) : [NSNull null],
                            @"result": error ? [NSNull null] : @{
                                    @"isCancelled": @(result.isCancelled),
                                    @"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
                                    @"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
                                    },
                            };

    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event];
    [self.bridge.eventDispatcher sendEvent:event];
}

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{
    NSDictionary *event = @{
                            @"target": loginButton.reactTag,
                            };

    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event];
    [self.bridge.eventDispatcher sendEvent:event];
}

@end
janicduplessis commented 5 years ago

Are you using cocoapods to link libraries? I think it happens only when linking the xcode projects.

Note that RN 0.61 won't include xcode projects anymore so I suggest migrating to cocoapods to link third party deps.

msqar commented 5 years ago

@janicduplessis no, i'm not using cocoapods, i've manually migrated from 0.59 to 0.60.4. I think that messed up my project. Although i was able to make this work by adding ComponentEvent.h into React.xcodeproj within my project, i think it's quite dirty to do that. Should i create a dummy project and move mine to the 0.60.4 version and link each dependency with cocoapods autolink? Happens that i don't know how will that work. I need to add every dependency that i use and supports autolink in the pod file?

akshayaroraGS commented 5 years ago

same issue on 1.0.2

linh232323 commented 5 years ago

same issue on 1.0.3 RN 0.59.10 using Cocoapods

I could not upgrade into RN 0.60, because it will ruin all un-support modules.

ErrorPro commented 5 years ago

Having the same issue with RN 0.59.

"react-native": "0.59.10",
"react-native-fbsdk": "^1.0.3",

UPDATE: Had to update the RN to 0.60 to make it work.

KevinDoom commented 5 years ago

I had the same issue using RN 0.59.9 and react-native-fbsdk@1.0.4.

Downgrading to react-native-fbsdk@0.10.0 fixed the problem for me. Apparently, starting at react-native-fbsdk@1.0.0, the library assumes RN 0.60.0.

divyanshunegi commented 4 years ago

I had the same issue using RN 0.59.9 and react-native-fbsdk@1.0.4.

Downgrading to react-native-fbsdk@0.10.0 fixed the problem for me. Apparently, starting at react-native-fbsdk@1.0.0, the library assumes RN 0.60.0.

@KevinDoom Fb login will not work in iOS 13 with this process as the version 1.0.0 only supports version 13.

divyanshunegi commented 4 years ago

my solution is going to node_modules/react-native-fbsdk/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.m change to


#import "RCTFBSDKLoginButtonManager.h"

#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>

#import "RCTConvert+FBSDKLogin.h"

@implementation RCTFBSDKLoginButtonManager

RCT_EXPORT_MODULE(RCTFBLoginButton)

#pragma mark - Object Lifecycle

- (UIView *)view
{
    FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
    loginButton.delegate = self;
    return loginButton;
}

#pragma mark - Properties

RCT_EXPORT_VIEW_PROPERTY(readPermissions, NSStringArray)

RCT_EXPORT_VIEW_PROPERTY(publishPermissions, NSStringArray)

RCT_CUSTOM_VIEW_PROPERTY(loginBehaviorIOS, FBSDKLoginBehavior, FBSDKLoginButton)
{
    [view setLoginBehavior:json ? [RCTConvert FBSDKLoginBehavior:json] : FBSDKLoginBehaviorNative];
}

RCT_EXPORT_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience)

RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, FBSDKLoginButton)
{
    [view setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
}

#pragma mark - FBSDKLoginButtonDelegate

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
    NSDictionary *event = @{
                           @"type": @"loginFinished",
                           @"target": loginButton.reactTag,
                           @"error": error ? RCTJSErrorFromNSError(error) : [NSNull null],
                           @"result": error ? [NSNull null] : @{
                                   @"isCancelled": @(result.isCancelled),
                                   @"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
                                   @"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
                                   },
                           };

     [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event];
    [self.bridge.eventDispatcher sendEvent:event];
}

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{
    NSDictionary *event = @{
                            @"target": loginButton.reactTag,
                           };

    [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event];
    [self.bridge.eventDispatcher sendEvent:event];
}

@end

FBSDKLoginBehaviorNative is not identified, and I needed to change it to FBSDKLoginBehaviorBrowser, is there a way to fix this issue ?

eshwartm commented 4 years ago

I had the same issue using RN 0.59.9 and react-native-fbsdk@1.0.4. Downgrading to react-native-fbsdk@0.10.0 fixed the problem for me. Apparently, starting at react-native-fbsdk@1.0.0, the library assumes RN 0.60.0.

@KevinDoom Fb login will not work in iOS 13 with this process as the version 1.0.0 only supports version 13.

Have you tested on iOS 13? @KevinDoom @divyanshunegi

acro5piano commented 4 years ago

I fixed the issue by downgrading to 0.10.0.

RN 0.60.0 is peer dependency in 1.x.x .

https://github.com/facebook/react-native-fbsdk/blob/master/package.json#L53