DataDog/dd-sdk-flutter

Duplicate interface (iOS)

FDavidse20 opened this issue · 4 comments

Describe the bug

The error that I'm having is exactly the same as the iOS related error described on the Datadog troubleshooting page:
https://docs.datadoghq.com/real_user_monitoring/mobile_and_tv_monitoring/troubleshooting/flutter/

when trying to run my flutter package I'm getting the error:

Semantic Issue (Xcode): Duplicate interface definition for class 'DatadogSdkPlugin'
/Users/filip/Documents/Development/Apps/listing-search-wonen/src/funda.search.apps/listing_search/example/build/ios/Debug-iphonesimulator/datadog_flutter_plugin/datadog_flutter_plugin.framework/Headers/DatadogSdkPlugin.h:6:0
DatadogSdkPlugin.h:6

Modules Issue (Xcode): Definition of 'DatadogSdkPlugin' must be imported from module 'datadog_flutter_plugin.Swift' before it is required
/Users/filip/Documents/Development/Apps/listing-search-wonen/src/funda.search.apps/listing_search/example/ios/Runner/GeneratedPluginRegistrant.m:85:3
GeneratedPluginRegistrant.m:85

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro.

Reproduction steps

My package has a transitive dependency on the datadog_flutter_plugin. I'm not writing any specific code to use the datadog_flutter_plugin in my package.
But just running fvm flutter run results in the error.

SDK logs

No response

Expected behavior

not prevent my flutter package from building successfully on iOS

Affected SDK versions

datadog_flutter_plugin: 2.5.0

Latest working SDK version

below version 2.0

Did you confirm if the latest SDK version fixes the bug?

Yes

Flutter Version

3.19.5

Setup Type

flutter package

Device Information

all iOS simulators and devices

Other relevant information

I've tried the tips from this page:
'Try performing flutter clean && flutter pub get and rebuilding. This usually resolves the issue.'
But this doesn't resolve the issue for me.

Hi @FDavidse20 ,

Not sure what would cause this as we haven't seen any instances where a flutter clean didn't fix the issue. Can you post your GeneratedPluginRegistrant.m for me to look at?

Also, what package is depending on datadog_flutter_plugin? At the moment, the Flutter SDK should really only be used to monitor an application, not another package / SDK.

Hi, thanks for your reply.
So we have a flutter app, with some internal feature packages (which is the one I'm concerned with) and some packages which allow us to to analytics, and that depends on datadog. And those packages are also imported by my package.

here's my GeneratedPluginRegistrant.m

//
//  Generated file. Do not edit.
//

// clang-format off

#import "GeneratedPluginRegistrant.h"

#if __has_include(<app_settings/AppSettingsPlugin.h>)
#import <app_settings/AppSettingsPlugin.h>
#else
@import app_settings;
#endif

#if __has_include(<connectivity_plus/ConnectivityPlusPlugin.h>)
#import <connectivity_plus/ConnectivityPlusPlugin.h>
#else
@import connectivity_plus;
#endif

#if __has_include(<datadog_flutter_plugin/DatadogSdkPlugin.h>)
#import <datadog_flutter_plugin/DatadogSdkPlugin.h>
#else
@import datadog_flutter_plugin;
#endif

#if __has_include(<flutter_appauth/FlutterAppauthPlugin.h>)
#import <flutter_appauth/FlutterAppauthPlugin.h>
#else
@import flutter_appauth;
#endif

#if __has_include(<geolocator_apple/GeolocatorPlugin.h>)
#import <geolocator_apple/GeolocatorPlugin.h>
#else
@import geolocator_apple;
#endif

#if __has_include(<google_maps_flutter_ios/FLTGoogleMapsPlugin.h>)
#import <google_maps_flutter_ios/FLTGoogleMapsPlugin.h>
#else
@import google_maps_flutter_ios;
#endif

#if __has_include(<google_mobile_ads/FLTGoogleMobileAdsPlugin.h>)
#import <google_mobile_ads/FLTGoogleMobileAdsPlugin.h>
#else
@import google_mobile_ads;
#endif

#if __has_include(<integration_test/IntegrationTestPlugin.h>)
#import <integration_test/IntegrationTestPlugin.h>
#else
@import integration_test;
#endif

#if __has_include(<listing_search_ads/ListingSearchAdsPlugin.h>)
#import <listing_search_ads/ListingSearchAdsPlugin.h>
#else
@import listing_search_ads;
#endif

#if __has_include(<permission_handler_apple/PermissionHandlerPlugin.h>)
#import <permission_handler_apple/PermissionHandlerPlugin.h>
#else
@import permission_handler_apple;
#endif

#if __has_include(<shared_preferences_foundation/SharedPreferencesPlugin.h>)
#import <shared_preferences_foundation/SharedPreferencesPlugin.h>
#else
@import shared_preferences_foundation;
#endif

#if __has_include(<url_launcher_ios/URLLauncherPlugin.h>)
#import <url_launcher_ios/URLLauncherPlugin.h>
#else
@import url_launcher_ios;
#endif

@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
  [AppSettingsPlugin registerWithRegistrar:[registry registrarForPlugin:@"AppSettingsPlugin"]];
  [ConnectivityPlusPlugin registerWithRegistrar:[registry registrarForPlugin:@"ConnectivityPlusPlugin"]];
  [DatadogSdkPlugin registerWithRegistrar:[registry registrarForPlugin:@"DatadogSdkPlugin"]];
  [FlutterAppauthPlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterAppauthPlugin"]];
  [GeolocatorPlugin registerWithRegistrar:[registry registrarForPlugin:@"GeolocatorPlugin"]];
  [FLTGoogleMapsPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTGoogleMapsPlugin"]];
  [FLTGoogleMobileAdsPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTGoogleMobileAdsPlugin"]];
  [IntegrationTestPlugin registerWithRegistrar:[registry registrarForPlugin:@"IntegrationTestPlugin"]];
  [ListingSearchAdsPlugin registerWithRegistrar:[registry registrarForPlugin:@"ListingSearchAdsPlugin"]];
  [PermissionHandlerPlugin registerWithRegistrar:[registry registrarForPlugin:@"PermissionHandlerPlugin"]];
  [SharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"SharedPreferencesPlugin"]];
  [URLLauncherPlugin registerWithRegistrar:[registry registrarForPlugin:@"URLLauncherPlugin"]];
}

@end

Okay, so long as the internal package isn't looking to send information to a different org you should be fine.

I'm very confused why this might be happening. If you run pod install from example/ios does it complain at all? Additionally could you try a pod disintegrate followed by pod install in your example/ios directory as well? Performing a flutter clean should do this but I'm wondering if the output of Cocoapods can tell us more information.

If that doesn't work, can you open a ticket with Datadog support? I might need more information and it might be easier to do from there.

Thanks for the tips. Unfortunately it didn't do the trick.
I've just created a ticket with Datadog support as you suggested