Swinject: Undefined symbols for architecture x86_64: ___llvm_profile_runtime

Created on 28 Sep 2017  路  10Comments  路  Source: Swinject/Swinject

I'm getting an issue linking Swinject framework into my project when using Xcode9 and Swift3.2

It's giving me the following error:

Undefined symbols for architecture x86_64:
  "___llvm_profile_runtime", referenced from:
      ___llvm_profile_runtime_user in Swinject(SpinLock.o)
      ___llvm_profile_runtime_user in Swinject(Assembler.o)
      ___llvm_profile_runtime_user in Swinject(ObjectScope.Standard.o)
      ___llvm_profile_runtime_user in Swinject(ServiceEntry.o)
      ___llvm_profile_runtime_user in Swinject(SynchronizedResolver.o)
      ___llvm_profile_runtime_user in Swinject(DebugHelper.o)
      ___llvm_profile_runtime_user in Swinject(InstanceStorage.o)
      ...
     (maybe you meant: ___llvm_profile_runtime_user)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Getting this error with both 2.1.1 and 2.0.0 stable releases
screen shot 2017-09-28 at 9 03 56 am

more info needed

Most helpful comment

Try cleaning up the project. Also, release for Xcode9 and Swift3.2 is not out yet.

All 10 comments

Try cleaning up the project. Also, release for Xcode9 and Swift3.2 is not out yet.

Tried cleaning project, derived data, etc. to no avail.
I understand the release isn't out yet; just wanted to make sure this issue is tracked.

@andriko13, how did you install Swinject? With Carthage or CocoaPods?

This is related to profiling. I get the exact same error in a different project when compiling with -fprofile-instr-generate. No idea why yet - I guess Clang is not linking with some require runtime library but I can't work out which one.

Ah, found the problem. If you pass -fprofile-instr-generate during compilation, but not during linking, Clang won't link with the appropriate libraries and you get this error.

@andriko13 is your original issue related to what @Timmmm is describing? If that is the case, and I understand it correctly, this is not the issue with the Swinject, but rather with specific project settings.

The reason why this is failing is because codeCoverageEnabled is set to YES on the test target (seems to be a bug on Xcode when linking statically). Removing that setting on Swinject fixes the problem.

For what is worth, passing -fprofile-instr-generate is only recommended on sim builds.

Closing due to inactivity

I found this issue through a DuckDuckGo search for "undefined symbol llvm profile runtime". The issue does seem to occur when:

  • You're building a test target for some project
  • The project's test target does not have code coverage enabled
  • The project includes a static framework whose test target _does_ have coverage enabled

Another fix that worked for me (not related to Swinject in particular) is to enable code coverage on the super-project. This way, the included framework can continue using code coverage during development.

This appears to be breaking SwiftUI's Preview by complaining that ___llvm_profile_runtime_user was not found for architecture x86_64. As @Reflejo mentioned, turning code coverage off fixes it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

movses-margaryan picture movses-margaryan  路  5Comments

Mijail picture Mijail  路  6Comments

alynmuntean picture alynmuntean  路  6Comments

drekka picture drekka  路  7Comments

igorkotkovets picture igorkotkovets  路  7Comments