I'm using CocoaPods developing a project in pieces of private pods. I got a problem with including Realm frameworks into my private pod:
ld: framework not found Realm for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(This error happened when trying to include Realm frameworks in a podspec file)
I filed an issue(github.com/realm/realm-cocoa/issues/5230) at Realm.
Yet, the problem remained unsolved.
You don't have to go over that issue, I copied most of it to this post.
So I want to ask you guys and see if there's any clue to solve this problem.
Report
What did you do?
Let's assume the sample project's name is RealmTest.
I created it by using pod lib create RealmTest.
And I added the two necessary frameworks, for Realm to run in Swift, into the directory RealmTest within the root project directory.
I added the line s.vendored_frameworks = 'RealmTest/Realm.framework', 'RealmTest/RealmSwift.framework' to the podspec file.
And then I did a pod install for the Example project.
What did you expect to happen?
The build did succeed and I expect by doing all those to speed up the build time of the project, instead of compiling Realm from source code.
What happened instead?
Until I import RealmSwift and started to use it.
The build report says as mentioned earlier:
ld: framework not found Realm for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Notes
I specifically use
lipo -infoto check both of the Realm's frameworks, downloaded from their official site. Both of them support all of the four architectures.Both of the frameworks are already included into the
Pods.And in the project's product directory(the compile technically succeeded, but the link failed at the end), both frameworks are indeed included in the app bundle's framework directory.
Experiment
I created a dummy framework which supports all of the architectures and added it to the project.
With Realm import commented out, the project gets built successfully.
Once I import Realm module, the error resurfaces!
But one of the team members from Realm took a look at the sample project and couldn't find anything wrong on the Realm side so far.
You can read the discussion from the issue
github.com/realm/realm-cocoa/issues/5230
and download the sample project. It is already included both Realm frameworks and the dummy framework.
To see the error, just simply uncomment import RealmSwift at the top of the class file TestClass.swift which is under group path Development Pods/RealmTest/RealmTest/Classes within the Pods project in RealmTest.xcworkspace.
Am I doing a weird thing here including frameworks into a pod project to speed up build time? I couldn't find much of the related content on the Internet?
Thank you for your time!!
Xcode Version
8.3.2
Swift Version
3.1
Podspec
Pod::Spec.new do |s|
s.name = 'RealmTest'
s.version = '0.1.0'
s.summary = 'A short description of RealmTest.'
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://github.com/ivsall2012/RealmTest'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'ivsall2012' => 'ivsall2012@gmail.com' }
s.source = { :git => 'https://github.com/ivsall2012/RealmTest.git', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.source_files = 'RealmTest/Classes/**/*'
s.vendored_frameworks = 'RealmTest/DummyFramework.framework','RealmTest/Realm.framework', 'RealmTest/RealmSwift.framework'
end
Podfile
use_frameworks!
target 'RealmTest_Example' do
pod 'RealmTest', :path => '../'
target 'RealmTest_Tests' do
inherit! :search_paths
end
end
Project that demonstrates the issue
[The sample project(32.96 MB)]