Captain Charmi
Captain Charmi

Reputation: 604

Cannot find protocol declaration for 'CrashlyticsDelegate' when compiling Objective C++ file

Sample Project: https://github.com/mike011/CrashlyticsDelegateExample

Steps to reproduce:

  1. Create a new Swift Project
  2. Add in Crashlytics via a Podfile and make sure use_frameworks! is listed
  3. Create the following extension:

extension AppDelegate: CrashlyticsDelegate { func crashlyticsDidDetectReport(forLastExecution report: CLSReport) { } }

  1. Add an Objective C++ file.
  2. Add the following import to the new file

#import <UIKit/UIKit.h> #import "CrashlyticsSampleApp-Swift.h"

  1. Compile

The error "Cannot find protocol declaration for 'CrashlyticsDelegate' is produced from the 'CrashlyticsSampleApp-Swift.h' file.

**KABOOM!**

Environment: MacOS 10.14 with xCode 9.4

Upvotes: 2

Views: 491

Answers (1)

agirault
agirault

Reputation: 2928

You will need to create a bridging header for obj-c/swift and add the following import to it:

#import <Crashlytics/Crashlytics.h>

I haven't tested, but you probably can get away with it by adding that import to your sample objc file (ObjectiveCMMFile.mm) if you do not need the bridging header (would be great if you could confirm).

Upvotes: 1

Related Questions