Cannot import FirebaseMessaging in Service Extension target

Viewed 130

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?

1 Answers

I think I figured out a solution! Although the package has been added to the project, it needs to be explicitly added to the Service Extension as well.

enter image description here

enter image description here

Once it's been added, you should be able to import FirebaseMessaging from the Service Extension.

Related