Hi everyone,
I'm facing a challenging integration issue with AmplitudeSwift (via SPM) in a mixed-language iOS project and would appreciate guidance from the community or the Amplitude team.
Project Architecture
- Parent app target:
ParentApp- Written entirely in Objective-C
- Does not import, link, or use Amplitude in any way
- Should be completely unaware of analytics implementation
- Embedded dynamic framework:
ChildFramework- Written in Swift
- Uses AmplitudeSwift internally for analytics
- Added to the parent app as an embedded dynamic framework
- Located in
ParentApp.app/Frameworks/
Intended design:
Only ChildFramework should use Amplitude.
ParentApp should NOT link any Amplitude code or contain Amplitude symbols.
The Issue
Despite the ParentApp doing nothing with Amplitude, I'm seeing large numbers of runtime warnings like:
objc: Class _TtC14AmplitudeSwift9Amplitude is implemented in bothParentApp.app/Frameworks/ChildFramework.framework/ChildFrameworkandParentApp.app/ParentApp.This may cause spurious casting failures and mysterious crashes.
This shows that AmplitudeSwift types are being included in both binaries, even though the ParentApp is in Objective-C and never references Amplitude.
Dozens of classes from AmplitudeSwift, AmplitudeCore, and AnalyticsConnector show duplicate definitions.
What I’ve Tried
1. Removing AmplitudeSwift from ParentApp target
Since ParentApp doesn’t use Amplitude, I removed the SPM package from ParentApp and kept it only in ChildFramework.
Result → App crashes at launch:
Library not loaded: @rpath /AmplitudeCore.framework/AmplitudeCoreReferenced from: ChildFramework.frameworkReason: AmplitudeCore.framework not found in ParentApp.app/Frameworks
This happens because ChildFramework depends on the Amplitude runtime frameworks, and iOS requires those to exist in the app bundle, not inside the framework.
2. Adding AmplitudeSwift back to ParentApp (to embed frameworks)
To resolve the crash, I re-added AmplitudeSwift to ParentApp so Xcode would embed:
AmplitudeSwift.frameworkAmplitudeCore.framework- other Amplitude runtime frameworks
This fixes the crash, but introduces the big problem:
ParentApp now also links AmplitudeSwift, even though it shouldn't
This causes all the duplicate class warnings, because SPM links the Amplitude code into both:
ParentApp binaryChildFramework binary
Even though ParentApp:
- is Objective-C
- never imports a Swift Amplitude module
- never uses any Amplitude API
It still ends up with Amplitude symbols in the main binary.
Summary
I am stuck between two invalid states:
Setup | Result |
|---|
Amplitude only in ChildFramework | App crashes (missing AmplitudeCore.framework at runtime) |
Amplitude added to ParentApp | Crash fixed, but duplicate Amplitude class warnings appear |
My Questions
1. How can I prevent AmplitudeSwift classes from being linked into the Objective-C ParentApp target?
ParentApp should:
- Only embed the Amplitude frameworks (for ChildFramework to run),
- NOT link AmplitudeSwift into its own binary.
2. Is there a recommended SPM configuration for:
“ChildFramework uses AmplitudeSwift; ParentApp (Obj-C) should embed the runtime frameworks but must NOT import/link Amplitude.”
3. Is there any official guidance for this architecture?
Many apps use:
- Swift dynamic frameworks (SDKs),
- Containing analytics code,
- Embedded into larger Objective-C parent apps.
Yet I cannot find documentation on avoiding duplicate symbol inclusion with SPM-based binary frameworks like AmplitudeSwift.
Environment
- iOS 16+
- ParentApp: Objective-C
- ChildFramework: Swift
- AmplitudeSwift integrated via SPM
- Targets:
ParentApp (Obj-C, no Amplitude)ChildFramework (Swift, uses Amplitude)
Thanks in advance for any help — this seems like a common scenario, so I’m hoping there’s a clean solution or recommended configuration.