facebook-ios-sdk icon indicating copy to clipboard operation
facebook-ios-sdk copied to clipboard

Difficulty compiling 15.1.0 from objective-c code

Open mikehardy opened this issue 1 year ago • 7 comments

Checklist before submitting a bug report

Xcode version

14.0

Facebook iOS SDK version

15.1.0

Dependency Manager

CocoaPods

SDK Framework

Core

Goals

I am the maintainer of react-native-fbsdk-next (the current FBSDK wrapper, we drive a lot of SDK usage :smile: - 64,000+ package downloads a week it appears https://www.npmjs.com/package/react-native-fbsdk-next )

I am trying to update our wrapper to use facebook-ios-sdk 15.1.0, it worked with 15.0.0

We are still written in Objective-C, and need swift/objc interop to work well

Currently we advise people that do deep-linking to import the module in AppDelegate.mm like so:

#import <FBSDKCoreKit/FBSDKCoreKit-swift.h>

I understand from other issues that @import FBSDKCoreKit; is the recommended objc interop way of doing it but:

  1. believe it or not this worked great with v15.0.0 of the SDK here
  2. if we do that we get warnings about c++ modules not being in use, because of the way react-native compiles things

(same as noted in following comments on that issue linked just above: https://github.com/facebook/facebook-ios-sdk/issues/2043#issuecomment-1122049872)

So the goal is just to get the react-native-fbsdk-next obj-c code compiling correctly vs v15.1.0 here in a react-native-compatible way

Expected results

A successful compile

Actual results


❌ /Users/mike/Library/Developer/Xcode/DerivedData/RNFBSDKExample-fyfqqrwanmaihzdzdblaijkftntu/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/FBSDKCoreKit/FBSDKCoreKit.framework/Headers/FBSDKCoreKit-swift.h:2430:146: cannot find protocol declaration for 'SFSafariViewControllerDelegate'
@interface _BridgeAPI : NSObject <FBSDKBridgeAPIRequestOpening, FBSDKApplicationObserving, FBSDKURLOpener, FBSDKContainerViewControllerDelegate, SFSafariViewControllerDelegate>
                                                                                                                                                 ^
❌ /Users/mike/Library/Developer/Xcode/DerivedData/RNFBSDKExample-fyfqqrwanmaihzdzdblaijkftntu/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/FBSDKCoreKit/FBSDKCoreKit.framework/Headers/FBSDKCoreKit-swift.h:2445:56: cannot find protocol declaration for 'ASWebAuthenticationPresentationContextProviding'
@interface _BridgeAPI (SWIFT_EXTENSION(FBSDKCoreKit)) <ASWebAuthenticationPresentationContextProviding>
                                                       ^
❌ /Users/mike/Library/Developer/Xcode/DerivedData/RNFBSDKExample-fyfqqrwanmaihzdzdblaijkftntu/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/FBSDKCoreKit/FBSDKCoreKit.framework/Headers/FBSDKCoreKit-swift.h:2446:4: expected a type
- (ASPresentationAnchor _Nonnull)presentationAnchorForWebAuthenticationSession:(ASWebAuthenticationSession * _Nonnull)session SWIFT_WARN_UNUSED_RESULT;

Steps to reproduce

I think the best way to reproduce might be to try the PR I have open in our example app, I am not 100% of the best way to do it, but I think this might work:

  • make sure you have node v16 installed + yarn
  • git clone [email protected]:thebergamo/react-native-fbsdk-next
  • cd react-native-fbsdk-next
  • gh pr checkout 339 (not sure this will work, but the goal is to get the pull request update in place, alternatively alter the podspec in the main directory to use the new SDK version)
  • yarn
  • yarn example:install && yarn example:devcopy && yarn example:install
  • yarn example:start (this will consume one terminal)
  • yarn example:ios

That should reproduce the errors above.

RNFBSDKExample/ios/AppDelegate.mm has the integration with import. If you change it to swift @import style you get the c++ modules issue.

Perhaps there is a way to add an @obj protocol interop specifier or similar in FBSDKCoreKit? Perhaps there is something I/we could put in our podspec that would help?

It is possible to play with possibilities by reaching directly in to RNFBSDKExample/node_modules/react-native-fbsdk-next and altering things (like perhaps the podspec to add compiler flags)

I wish I had more Obj-C/Swift interop experience but hopefully, since we (me, really at this point) are now maintaining the facebook module for react-native after it was pulled out of the main facebook/meta repos you will take pity on my and help keep it going, I would certainly appreciate it

Code samples & details

https://github.com/thebergamo/react-native-fbsdk-next/blob/master/RNFBSDKExample/ios/RNFBSDKExample/AppDelegate.mm

mikehardy avatar Nov 02 '22 14:11 mikehardy