1

I am trying to run the initialization of the AppsFlyer SDK, but I am getting a Thread 1: signal SIGABRT error when the app is launching. I am using the guide from AppsFlyer here: https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS#3-sdk-initialization.

I am using this on a swift ios app in Xcode 10. I used the cocopods option in the guide. I tried using the exact code that the guide provided, but that did not work. I then tried to follow the changes that Xcode sudgested. That gave me a warning and the app then crashed when launching.

The Code that The guide says to use:

AppsFlyerTracker.shared().appsFlyerDevKey = "<your-appsflyer-dev-key>";
AppsFlyerTracker.shared().appleAppID = "123456789"
AppsFlyerTracker.shared().delegate = self

Xcode sugested fixed code: (Error: "Cannot assign value of type 'AppDelegate' to type 'AppsFlyerTrackerDelegate?'")

AppsFlyerTracker.shared().appsFlyerDevKey = "xxxxxxxxx";
AppsFlyerTracker.shared().appleAppID = "xxxxxxxx"
AppsFlyerTracker.shared().delegate = self as! AppsFlyerTrackerDelegate

Error after launching: Thread 1: signal SIGABRT

I am trying to get the SDK to initialize.

I am also using AdMob/Firebase and that is also using cocopods. It is working as expected.

username
  • 79
  • 10
  • Instead of force casting your `AppDelegate` class, have you instead tried implementing the `AppsFlyerTrackerDelegate` protocol? Without the full crash log, my expectation is that this framework is attempting to call one of the functions that it's delegate protocol expects to be defined however you are providing it an object that doesn't conform to the requirements. – Jamie Edge Dec 31 '18 at 21:13
  • @JamieEdge if I try using the `AppsFlyerTrackerDelegate` protocol I get a error that `Type 'AppsFlyerTrackerDelegate' has no member 'shared'`. If I comment out this line then whole app works as expected. – username Dec 31 '18 at 22:42
  • It sounds like you are removing the `UIApplicationDelegate` conformance rather than implementing the framework’s delegate protocol in addition to it. Add an extension to the `AppDelegate` class and implement the required types in it. – Jamie Edge Dec 31 '18 at 22:46
  • @JamieEdge I'm sorry, I do not understand what you mean by that. – username Dec 31 '18 at 22:51
  • It is a requirement to conform to the `UIApplicationDelegate` protocol. You cannot remove this protocol conformance otherwise you will get the compilation error which you mentioned. In order to make the class suitable as a delegate for this particular framework, you need to add conformance to the protocol that it needs in addition to the existing protocol, rather than replacing it. This can be done either using an `extension` (recommended) or through comma separation (`class AppDelegate: NSObject, UIApplicationDelegate, AppsFlyerTrackerDelegate`). – Jamie Edge Dec 31 '18 at 23:03

1 Answers1

1

I was able to fix the error by changing AppsFlyerTracker.shared().delegate = self to AppsFlyerTracker.shared()?.delegate = self as? AppsFlyerTrackerDelegate.

username
  • 79
  • 10