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

Difficulty compiling 15.1.0 from objective-c code #2140

Open
5 tasks done
mikehardy opened this issue Nov 2, 2022 · 7 comments
Open
5 tasks done

Difficulty compiling 15.1.0 from objective-c code #2140

mikehardy opened this issue Nov 2, 2022 · 7 comments

Comments

@mikehardy
Copy link

mikehardy commented Nov 2, 2022

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 😄 - 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: #2043 (comment))

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 git@github.com: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
@TarasOsiris
Copy link

I am experiencing the same issue when trying to make this SDK work with UE, did you find any solutions to this problem?

@mikehardy
Copy link
Author

No, I did not find a workaround, I'm stuck at 15.0.0. No response yet from maintainer(s) - though I see a commit from @samodom on Nov 8 and this was logged on Nov 2. Sam, I am not implying any expectation of response time with that comment, just saying as a general statement "the repository seems alive, Sam was here after the issue, perhaps it will get attention eventually" :-). Cheers

@TarasOsiris
Copy link

TarasOsiris commented Dec 17, 2022 via email

@mikehardy
Copy link
Author

@TarasOsiris can you be more specific, perhaps with an example or a diff or similar? I feel like I tried most things, but I must be unaware of the exact technique you mention as it did not occur to me and I'm not sure exactly what you mean. Thanks in advance if you can

@xtealer
Copy link

xtealer commented Dec 27, 2022

Hello, I've had this issue and spent couple hours debugging as well... Just figured out that AppDelegate extension ended in .mm and that stands for Objective C++ which does not support the imports that are producing these warnings! Just rename to .m and rewrite any Objective C+ code to Objective C and it should work! :)

https://stackoverflow.com/questions/29142045/module-not-recognized-in-xcode-project

@muhachev
Copy link

muhachev commented Dec 27, 2022

You should consider adding the appropriate XCode frameworks to your build: SafariServices and AuthenticationServices.
Then just import them:
#import <AuthenticationServices/AuthenticationServices.h>
#import <SafariServices/SafariServices.h>

@SufianBabri
Copy link

Just remember to put the import statements (shared by @muhachev) before the #import <FBSDKCoreKit/FBSDKCoreKit-swift.h>.

Big thanks to this comment.

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

No branches or pull requests

5 participants