How can I properly share the Amplify framework with my Main App and my App Extension for an iOS app?

Viewed 299

I have an iOS app using AWS amplify for the backend. I am using Xcode 13 and SwiftUI. I previously added the Amplify framework using Cocoapods however I was unable to get the framework to work with the extension.

So I recently switched to Swift Package Manager. I added the package to my main project. Then I went to my Share Extension and in General - Frameworks and Libraries and manually added the libraries.

After doing this the app builds and runs and both the main app and extension work fine and are able to use the libraries.

The problem is that I cannot archive and upload the app to the App Store. I get the following error:

CFBundleIdentifier Collision. There is more than one bundle with the CFBundleIdentifier value 'com.amazonaws.AWSAuthCore' under the iOS application 'MyAPP.app'. With error code STATE_ERROR.VALIDATION_ERROR...

I went on many forums and spent many hours trying to fix this but to no avail. The suggestions are to click 'do not embed' for the libraries but that option is not available for me.

I wonder if there is anyway to resolve this?

Below are my General and Build Phases for the Share Extension:

enter image description here

enter image description here

1 Answers

Just remove explicit Amplify dependency from extension, ie. next section should be empty

demo1

Make sure (it should be automatically, but anyway)

  1. Link Frameworks Automatically parameter (in Build Settings) is true

demo2

  1. Runpath Search Path parameter is related to main bundle

demo3

So as targets from SPM are built in same location as product and extension and automatic framework linking is enabled the imported modules in extension will available and linked automatically and due to run paths are set the frameworks will be found in run-time as well.

Note: of course in main app target all should be included

demo4

Tested with Xcode 13.1 / iOS 15.1

Related