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

Datadog use in ios (notification) extension #370

Closed
SimpleApp opened this issue Jan 14, 2021 · 8 comments
Closed

Datadog use in ios (notification) extension #370

SimpleApp opened this issue Jan 14, 2021 · 8 comments
Assignees
Labels
compilation issue SDK doesn't compile or gives warnings.

Comments

@SimpleApp
Copy link

SimpleApp commented Jan 14, 2021

The issue

I'm trying to use datadog in both the app bundle and the notification extension bundle. I've tried two and encountered two different errors:
1/ using spm. I had to manually embed the Datadog library for the notification extension code to compile. That worked just fine, however, doing that triggered a bug when submitting to apple :

  • ERROR ITMS-90685: "CFBundleIdentifier Collision. There is more than one bundle with the CFBundleIdentifier value 'Datadog' under the iOS application
  • ERROR ITMS-90205: "Invalid Bundle. The bundle at … /Plugins/NotificationServiceExt.appex' contains disallowed nested bundles.
  • ERROR ITMS-90206: "Invalid Bundle. The bundle at '…/PlugIns/NotificationServiceExt.appex' contains disallowed file 'Frameworks'."

So, i tried using Cocoapods, and wrote "pod 'DatadogSDK' " in both the app and the extension targets.
This doesn't compile, because of a "UIApplication.shared" dependency in RUMDebugging.swift :

  • 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.
    At this point i feel kind of stuck.. Did i miss something ?

Datadog SDK version:

1.4.0

Last working Datadog SDK version:

?

Dependency Manager:

CocoaPods & SwiftPM

Other toolset:

Xcode version:

12.2

Swift version:

5.x

Deployment Target:

ios 13.0

@SimpleApp SimpleApp added the compilation issue SDK doesn't compile or gives warnings. label Jan 14, 2021
@ncreated ncreated self-assigned this Jan 15, 2021
@ncreated
Copy link
Member

Hello @SimpleApp 👋. Thanks for reporting this issue. Indeed, there was a problem with UIApplication.shared API when compiling the SDK for use in some app extensions (in this case, Notifications Service Extension). This is solved in #375 and will be available soon as 1.4.1 hotfix 🙂👌.

1/ using spm. I had to manually embed the Datadog library for the notification extension code to compile.

What was the reason of embedding Datadog in extension's target? It should work fine with "Do Not Embed" setting. I managed to build a simple example using Share Extension and link Datadog through SPM. It compiles and sends logs with no issue (tested on iOS Simulator, Xcode 12.3):

Screenshot 2021-01-18 at 17 43 30

@ncreated
Copy link
Member

The fix is available in 1.4.1. I'm closing the issue for now 👌, but feel free to open it or ask more questions. Thank you again for finding this bug!

@SimpleApp
Copy link
Author

SimpleApp commented Jan 19, 2021

Hi, for some reason, selecting "do not embed" makes the library disappear from the list and not link at all (even on the latest xcode 12.3)

@SimpleApp
Copy link
Author

SimpleApp commented Jan 19, 2021

I found this https://forums.swift.org/t/is-this-an-xcode-bug-or-somehow-related-to-spm/33987 which is probably what happens here
@ncreated : you may want to investigate whether using spm wasn't the culprit, because from what i read on the swiftforum thread, not embedding the datadog library using spm may not be possible atm...
EDIT: didn't watch your screenshot properly, and it looks like it's working just fine for you... Not sure what the reason is then..

@ncreated
Copy link
Member

Hello @SimpleApp 👋. Thank you for digging into more details on the SPM 💪. We need to look closer into app extensions + SPM configuration with recent Xcode tooling - I put this topic high in our backlog, and we will investigate it soon. For now, linking through CocoaPods seems to be a good workaround - I hope it solves the problem for you 🙂.

@amardeepranu
Copy link

amardeepranu commented Jan 21, 2021

When using cocoapods, I can't build in the extension because you're using UIApplication.shared:

/ios/Pods/DatadogSDK/Sources/Datadog/RUM/Debugging/RUMDebugging.swift:99:44: 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.

@ncreated
Copy link
Member

@amardeepranu this is fixed in 1.4.1.

@buranmert
Copy link
Contributor

ℹ️ we've recently found a new workaround for Swift Package Manager and lack of Do not embed option, please have a look at this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilation issue SDK doesn't compile or gives warnings.
Projects
None yet
Development

No branches or pull requests

4 participants