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

Why is the SDK Crashing at runtime after upgrading to v11? (Solution Included) #1763

Closed
5 tasks done
joesus opened this issue Jun 8, 2021 · 3 comments
Closed
5 tasks done

Comments

@joesus
Copy link
Contributor

joesus commented Jun 8, 2021

Checklist

Environment

Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:

  • Xcode Version: Any
  • Swift Version: Any
  • Installation Platform & Verison: Any

Goals

Upgrade to v11 and run the application without a crash.

Expected Results

What do you expect to happen?

Actual Results

SDK crashes:

libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'InvalidOperationException', reason: 'As of v9.0, you must initialize the SDK prior to calling any methods or setting any properties. You can do this by calling `FBSDKApplicationDelegate`'s `application:didFinishLaunchingWithOptions:` method.Learn more: https://developers.facebook.com/docs/ios/getting-started'
terminating with uncaught exception of type NSException

image

Steps to Reproduce

Call a method or access or set a property before calling application:didFinishLaunchingWithOptions:.

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        Settings.appID = "foo" // MOVE THIS LINE TO BE AFTER SDK INITIALIZATION
        ApplicationDelegate.shared.application(
            application,
            didFinishLaunchingWithOptions: launchOptions
        )

        return true
    }

image

Solution:

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        ApplicationDelegate.shared.application(
            application,
            didFinishLaunchingWithOptions: launchOptions
        )
        Settings.appID = "foo"

        return true
    }

image

@joesus joesus closed this as completed Jun 8, 2021
@joesus joesus reopened this Jun 8, 2021
@jawwad jawwad changed the title Why is the SDK Crashing at runtime after upgrading to v11? Why is the SDK Crashing at runtime after upgrading to v11? (Solution Included) Jun 9, 2021
@SaidRs
Copy link

SaidRs commented Jul 20, 2021

But what about the app extension? In extension there's no AppDelegate and therefore I'm not able to pass anything to ApplicationDelegate.shared.application and therefore the extension keeps crashing on v11.

@joesus
Copy link
Contributor Author

joesus commented Jul 30, 2021

But what about the app extension? In extension there's no AppDelegate and therefore I'm not able to pass anything to ApplicationDelegate.shared.application and therefore the extension keeps crashing on v11.

We are reintroducing the ability to initialize the SDK without an AppDelegate #1793

As far as extensions go, this was never explicitly supported and will require some effort to come up with a good way to support this. It's not entirely unlikely, based on how Xcode 13 handles NS_EXTENSION_UNAVAILABLE with regard to Swift Package Manager, that the SDK will break in extensions for other modes of building in the future. See: #1811

@lgyorgyi
Copy link

lgyorgyi commented Sep 2, 2021

  • [ ]

@jawwad jawwad pinned this issue Sep 13, 2021
@jawwad jawwad closed this as completed Sep 13, 2021
@jawwad jawwad unpinned this issue Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants