'Cannot import FirebaseMessaging in Service Extension target

I have a SwiftUI project where I added the Firebase dependency using the "Add Package" at the project level.

I could then put 'import FirebaseMessaging' inside a swift file and it would build without error, so I know the dependency is added correctly.

I then added a UNNotificationServiceExtension by going to File > New > Target and adding a Notification Service Extension.

Now in code in my new target in the same project, 'import FirebaseMessaging' will not resolve.

If I right click on the service extension and select 'Add Package', it will not allow me to add the firebase sdk package to the service extension, as it is already added to the project.

How can I get the Firebase dependency to be added to my service extension target?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source