From 55ee555c68c4c8e36d1166b608447cab3aec6b4f Mon Sep 17 00:00:00 2001 From: Cody Sehl Date: Thu, 28 Apr 2022 14:32:49 -0600 Subject: [PATCH] Compile with code coverage enabled (#398) When building Amplitude as a Swift Package Manager dependency for an XCode project with code coverage enabled (https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/07-code_coverage.html), the build fails. It fails with an error ``` Undefined symbols for architecture x86_64: "___llvm_profile_runtime", referenced from: ___llvm_profile_runtime_user in Amplitude.o ``` You can resolve this error by passing the `-fprofile-instr-generate` flag to clang (https://clang.llvm.org/docs/SourceBasedCodeCoverage.html). Unfortunately, this flag must be passed to the Amplitude dependency directly (rather than being applied to the project that relies on Amplitude, e.g.) That is what this commit does. --- Package.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index e0021765..514b9454 100644 --- a/Package.swift +++ b/Package.swift @@ -25,7 +25,9 @@ let package = Package( ], path: "Sources", resources: [.process("Resources/ComodoRsaDomainValidationCA.der")], - publicHeadersPath: "Amplitude/Public"), + publicHeadersPath: "Amplitude/Public", + linkerSettings: [.unsafeFlags(["-fprofile-instr-generate"])] + ) ] )