Jump to content
Hans♫

Linker errors when including Facebook SDK on iOS12

Recommended Posts

When I target iOS 12 I get linker errors related to the Facebook SDK, while linking towards iOS11.2 works fine.
I hoped that Delphi 10.3.1 fixed it, but it didn't so now I ask here.
What can it be?

 

I am using:
Delphi 10.3.1
XCode 10.1 (10B61)
SDK iOS12.0
The SDK is included by setting "Options passed to the LD linker" (in: Project Options > Building > Delphi Compiler > Linking) to "-ObjC -lz -framework FBSDKCoreKit -weak_framework Bolts"

 

The errors I get with different versions of the Facebook iOS SDK:


FBSDK 4.40 (latest SDK)
Error: "___isOSVersionAtLeast", referenced from:      -[FBSDKApplicationDelegate application:openURL:options:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKApplicationDelegate.o);      -[FBSDKApplicationDelegate application:openURL:sourceApplication:annotation:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKApplicationDelegate.o);      -[FBSDKApplicationDelegate applicationDidBecomeActive:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKApplicationDelegate.o);      ___51-[FBSDKApplicationDelegate openURL:sender:handler:]_block_invoke in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKApplicationDelegate.o);      -[FBSDKApplicationDelegate openURLWithSafariViewController:sender:fromViewController:handler:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKApplicationDelegate.o);      -[FBSDKWebDialog _applicationFrameForOrientation] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKWebDialog.o);      -[FBSDKPaymentProductRequestor logTransactionEvent:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKPaymentObserver.o);      ...

 

FBSDK 4.36
Error: "___isOSVersionAtLeast", referenced from:      -[FBSDKApplicationDelegate application:openURL:sourceApplication:annotation:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKApplicationDelegate.o);      -[FBSDKApplicationDelegate applicationDidBecomeActive:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKApplicationDelegate.o);      -[FBSDKApplicationDelegate openURLWithSafariViewController:sender:fromViewController:handler:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKApplicationDelegate.o);      -[FBSDKPaymentProductRequestor logTransactionEvent:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKPaymentObserver.o);

 

FBSDK 4.15
It works, but this SDK version is deprecated.

Edited by Hans♫

Share this post


Link to post

No one using the Facebook SDK in an iOS app?

If it works for you, please let me know, then at least there is hope...

Share this post


Link to post
18 hours ago, Hans♫ said:

No one using the Facebook SDK

Sorry, never have, never will.

Share this post


Link to post
Posted (edited)

Hans, I tried facebook sdk v4.42.0. it works. You need 3 base files to add into your project: Bolts.a, FBSDKCoreKit.a, FBSDKLoginKit.a. 

Wrapper I used is from Grijjy: https://blog.grijjy.com/2017/01/23/using-facebook-sdk-native-framework-for-ios-and-android-for-social-login-and-more-part-1/

Also you need check your error messages during the project compiling and find in it some frameworks for iOS you need to add to iOS SDK settings

Edited by Yury

Share this post


Link to post
1 hour ago, Yury said:

I tried facebook sdk v4.42.0. it works

That sounds great. What version of Delphi, XCode and iOS-SDK do you use?

Share this post


Link to post

We use it for two things:

1) Allow users to share their achievements in our App on Facebook

2) To report all our in-app sales to Facebook so the ROI can be calculated for our Facebook Ads.

Share this post


Link to post
On 5/27/2019 at 2:12 PM, Hans♫ said:

That sounds great. What version of Delphi, XCode and iOS-SDK do you use?

-Tokyo 10.2,3; 

-XCode10.1;

-fb sdk 4.42.0

Share this post


Link to post
Posted (edited)
On 6/3/2019 at 2:29 PM, Yury said:

-Tokyo 10.2,3; 

-XCode10.1;

-fb sdk 4.42.0

 

I tried to use the Grijjy implementation that you linked to earlier, but I still get the same linker error:

___isOSVersionAtLeast", referenced from: -[FBSDKApplicationDelegate application:openURL:sourceApplication:annotation:] in Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit(FBSDKApplicationDelegate.o);

However, I just realize that you do not mention your iOS SDK version. I only have the problem with iOS 12, not with iOS11 and earlier.

What iOS SDK do you use?

Edited by Hans♫

Share this post


Link to post
On 5/27/2019 at 2:12 PM, Hans♫ said:

That sounds great. What version of Delphi, XCode and iOS-SDK do you use?

-Tokyo 10.2,3; 

-XCode10.1;

-fb sdk 4.42.0


iOS sdk 12.1

Share this post


Link to post
On 6/14/2019 at 12:54 PM, Yury said:

iOS sdk 12.1

That is really strange. I wonder what difference we have in our configuration that causes this error to happen for me and not for you?

Would it be possible that you make a screen shot of your Project Options? (the "Compiling" page and the "Linking" page)

Share this post


Link to post

@Hans♫

Have you tried this with a complete new, empty project from the scratch ? if not I would recommend so.

Share this post


Link to post
Posted (edited)

Yes, I am using an empty app to test it. It only contains a few lines that uses the FBSDK.

 

This is the code. It calls the "ActivateApp" function and tries to show a Facebook Link Sharing Dialog on iOS. But it fails in the linking process (with the errors mentioned earlier), so the code never executes. Note, I had to add some Objective-C classes to the Grijjy unit, as it did not include all the ones I need (the modified unit is attached):

 

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  iOSapi.UIKit, iOSapi.Foundation,
  Macapi.Helpers,
  Grijjy.FBSDK.iOS.API,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs;

type
  TForm1 = class(TForm)
    procedure FormShow(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

function GetRootViewController: UIViewController;
begin
//Get the main window to be the parent of the facebook window (First window is always the main window)
  Result := TUIWindow.Wrap(TUIApplication.Wrap(TUIApplication.OCClass.sharedApplication).windows.objectAtIndex(0)).rootViewController;
end;

procedure ShowShareDialogMode(aContent: Pointer);
var lFBSDKShareDialog: FBSDKShareDialog;
begin
  lFBSDKShareDialog := TFBSDKShareDialog.Create;
  lFBSDKShareDialog.setshareContent(aContent);
  lFBSDKShareDialog.setFromViewController(GetRootViewController);
  lFBSDKShareDialog.setMode(FBSDKShareDialogModeNative);
  if not lFBSDKShareDialog.canShow then //if FB app not installed, fallback to web access
    lFBSDKShareDialog.setMode(FBSDKShareDialogModeFeedBrowser);
  lFBSDKShareDialog.Show;
end;

procedure ShareLink(const aLink: string);
var lLinkContent: FBSDKShareLinkContent;
begin
  lLinkContent := TFBSDKShareLinkContent.Create;
  lLinkContent.SetcontentURL(StrToNSUrl(aLink));
  ShowShareDialogMode( NSObjectToID(lLinkContent) );
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  TFBSDKAppEvents.OCClass.activateApp;
  ShareLink('');
end;

 

Grijjy.FBSDK.iOS.API.pas

Edited by Hans♫

Share this post


Link to post

Dear Hans, could you solve this problem?

Please let me know

Edited by ra.eremeev

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×