问题
I’m trying to use Realm for the first time in a real project, and I’ve added it via Cocoapods successfully. I’m using Xcode 6.4, but have the Xcode 7.1 beta installed on the same machine (for other projects).
When attempting to build the project or run unit tests (on the Simulator), I get a linker error saying that dozens of pairs of files are duplicated. Looks like one mentioned Bitcode and one doesn’t.
I’m using Xcode 6.4 – why does it even know about Bitcode? Here’s a small sample of the errors:
duplicate symbol _llvm.cmdline in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(row-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.embedded.module in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(row-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.cmdline in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(spec-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.embedded.module in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(spec-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.cmdline in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(table-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.embedded.module in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(table-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.cmdline in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(table_view-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.embedded.module in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(table_view-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.cmdline in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(unicode-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.embedded.module in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(unicode-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.cmdline in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(utilities-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.embedded.module in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(utilities-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.cmdline in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(version-iPhoneSimulator-bitcode.o)
duplicate symbol _llvm.embedded.module in:
/Users/me/Source/our-project-ios/Pods/Realm/core/librealm-ios.a(bptree-iPhoneSimulator-bitcode.o)
I’ve seen other people talking about similar issues but not with Xcode 6.4, and not with simply running the app, as opposed to submitting to the store.
I should also point out that adding Realm as a static framework (from the xcode-6
folder of 0.95.3
works perfectly, so it’s something to do with the build I’m getting from Cocoapods, it seems.
What can I do here? I’d really rather get it from Cocoapods if possible.
回答1:
Different versions of the core library for Realm are needed depending on which version of Xcode you're using, so it's important that the same version be activated with xcode-select
when you run pod install
as you will use to build the project. Since the Xcode 7 version of the library was downloaded, you probably had that version of Xcode active. Run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
(assuming that is where you have Xcode 6 installed; adjust it as necessary), delete the Pods
directory, and then rerun pod install
.
You can check which version of Xcode you have active with xcrun swiftc -v
.
来源:https://stackoverflow.com/questions/33125781/duplicate-symbols-when-adding-realm-cocoapod