Skip to content

Commit

Permalink
Compile with code coverage enabled (#398)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lalunamel authored Apr 28, 2022
1 parent e135cfe commit 55ee555
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"])]
)
]
)

0 comments on commit 55ee555

Please sign in to comment.