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

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
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

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
On 1/29/2020 at 10:04 PM, Dave Nottage said:

If you're still having trouble, please look here

Thank you, I will have a look. 

Share this post


Link to post
On 1/29/2020 at 10:04 PM, Dave Nottage said:

If you're still having trouble, please look at line 175 here:

https://github.com/DelphiWorlds/KastriFree/blob/master/API/DW.iOSapi.Firebase.pas

Basically forces the linker to link to libclang_rt.ios.a, which has the "missing" symbol

Thanks Dave, it solved the problem!

 

I added the fake includer function to the FB SDK headers as you suggested:

procedure CLangRTLoader; cdecl; external '/usr/lib/clang/lib/darwin/libclang_rt.ios.a';

Now it links with the FBSDK 4.36 without problems, and after a few hours of work to adapt my code to the new API version, everything works!

(I didn't try newer versions for now, as they might require further updating of my code and headers)
 

  • Like 1

Share this post


Link to post
6 hours ago, Hans♫ said:

Now it links with the FBSDK 4.36 without problems, and after a few hours of work to adapt my code to the new API version, everything works!

Excellent! There's someone in another post here asking about whether there are updated imports for the FB SDK. Perhaps you can help them, or at least give them an idea as to whether everything still works anyway. (using 4.36)

Share this post


Link to post
12 hours ago, Dave Nottage said:

There's someone in another post here asking about whether there are updated imports for the FB SDK.

I didn't answer this one because the steps to include the FB SDK is pretty much the same as mentioned in the GRIJJY blog. Though I never needed to fix anything regarding Delegates, so depending on your needs, this pretty long part can be skipped.

Also, my first implementation of the FB SDK was made in 2015-16, before anyone else had published solutions for it. My implementation is much simpler and focus only on the areas that I needed my self. Therefore it is not compatible with the GRIJJY source code.

 

However,

@MikeMon I'll be happy to share my headers and units to implement the Facebook API.

Share this post


Link to post
1 hour ago, Hans♫ said:

I didn't answer this one because the steps to include the FB SDK is pretty much the same as mentioned in the GRIJJY blog. Though I never needed to fix anything regarding Delegates, so depending on your needs, this pretty long part can be skipped.

Also, my first implementation of the FB SDK was made in 2015-16, before anyone else had published solutions for it. My implementation is much simpler and focus only on the areas that I needed my self. Therefore it is not compatible with the GRIJJY source code.

 

However,

@MikeMon I'll be happy to share my headers and units to implement the Facebook API.

Hi Hans. Thank you for your answer. Have you seen Embarcadero's implementation in their documentation below?

 

http://docwiki.embarcadero.com/RADStudio/Rio/en/REST_Client_Library#Accessing_Facebook_API

 

Is that enough to use Facebook functionality in an app? e.g. login with facebook, etc... 

Share this post


Link to post
13 minutes ago, MikeMon said:

Is that enough to use Facebook functionality in an app? e.g. login with facebook, etc... 

I haven't investigated their REST API, so I don't know how much functionality it implements compared to the SDK.

Share this post


Link to post
5 hours ago, Hans♫ said:

I haven't investigated their REST API, so I don't know how much functionality it implements compared to the SDK.

Tx Hans and Dave

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

×