I get linking error when trying to compile iOS project from terminal with Xcode 7.1.1:
xcodebuild -project MyProject.xcodeproj -configuration Debug -target MyProject build
As result I receive next error:
ld: framework not found AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is my pod file:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target "MyProject" do
pod "AFNetworking", "~> 2.0"
pod 'GoogleMaps'
pod 'MONActivityIndicatorView'
pod 'NYXImagesKit'
pod 'MagicalRecord'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
pod 'Countly'
end
xcodeproj 'MyProject'
I also tried adding link_with but get the same error. How to fix the problem above?
You need to build using the workspace generated by CocoaPods:
xcodebuild -workspace MyProject.xcworkspace -configuration Debug -scheme MyProject build
If you build just the project, xcodebuild does not see the dependency on the Pods project. Note that you have to use a scheme when building a workspace rather than a target. This means if you are building on a build server you will need to mark your scheme as shared in the scheme editor.
Related
I am making a xcframework. In my framework project, I have added cocoa pods like Alamofire, Realm, and more. When I integrate my xcframework in my application, the application crashes showing following error:
dyld: Symbol not found: _$s9Alamofire10HTTPMethodO3getyA2CmFWC
Referenced from: /private/var/containers/Bundle/Application/E81F9FBA-3876-4959-B675-B89A4EC0257A/BykesPod.app/Frameworks/MYFRAMEWORK.framework/MYFRAMEWORK
Expected in: /private/var/containers/Bundle/Application/E81F9FBA-3876-4959-B675-B89A4EC0257A/DEMOAPP.app/Frameworks/Alamofire.framework/Alamofire
in /private/var/containers/Bundle/Application/E81F9FBA-3876-4959-B675-B89A4EC0257A/DEMOAPP.app/Frameworks/MYFRAMEWORK.framework/MYFRAMEWORK
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
Following is the pod file of my framework project
target 'MYFRAMEWORK' do
project './MYFRAMEWORK.xcodeproj'
pod 'Realm'
pod 'RealmSwift'
pod 'Alamofire', '~> 4.8'
pod 'MBProgressHUD','1.1.0'
pod 'SwiftyJSON'
end
I have added following dependencies in my podspec file:
s.dependency "Realm"
s.dependency "RealmSwift"
s.dependency "Alamofire","~> 4.8.2"
s.dependency "MBProgressHUD","~> 1.1.0"
s.dependency "SwiftyJSON"
Following is the pod file of my demo application:
target 'DEMOAPP' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'PODNAME'
end
Following are the commands from which I am making xcframeworks
xcodebuild archive -workspace MYFRAMEWORK.xcworkspace -scheme MYFRAMEWORK -sdk iphoneos -archivePath "archives/0/ios_device.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO
xcodebuild archive -workspace MYFRAMEWORK.xcworkspace -scheme MYFRAMEWORK -sdk iphonesimulator -archivePath "archives/0/ios_simulators.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO
xcodebuild -create-xcframework -framework archives/0/ios_device.xcarchive/Products/Library/Frameworks/MYFRAMEWORK.framework -framework archives/0/ios_simulators.xcarchive/Products/Library/Frameworks/MYFRAMEWORK.framework -output build/MYFRAMEWORK.xcframework
Note: My code xcode version is 12.4
Solution to this problem is to enable following option in Target Build setting
Open Target build settings in Xcode
search for Build Libraries for distribution
change it to "Yes".
Note: If you are distributing Project/Library/Framework and it contains/depends on Cocoapods add following script into your destination Project where framework is integrated.
This script enables Build Libraries for distribution for all installing Cocoapod dependencies.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
Currently, the solution I found was to make the "Build Libraries for distribution" flag true in the Pods project of my application. See attached screenshot.
I tried doing a clean build, uninstalling/reinstalling pods, not too sure where to go to next.
I never received this error before, but I first got it when I tried integrating Firebase into my project. I made sure to add all of the correct pods, I then went ahead and added a few other Firebase pods, just in case. I'm not sure if it has anything to do with this, but here is what my pods file looks like.
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'Effortflex' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
use_modular_headers!
# Pods for Effortflex
pod 'RealmSwift'
pod 'IQKeyboardManagerSwift'
pod 'Firebase'
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Firestore'
pod 'FirebaseFirestoreSwift'
end
Here is a sample of the error...
/Users/owner1/Library/Developer/Xcode/DerivedData/Effortflex-bmtqbbukvlosxpbraqoiwplpcfyj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/nanopb.build/Objects-normal/x86_64/pb_encode.o
duplicate symbol '_pb_encode_fixed32' in:
/Users/owner1/Library/Developer/Xcode/DerivedData/Effortflex-bmtqbbukvlosxpbraqoiwplpcfyj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/nanopb.build/Objects-normal/x86_64/pb_encode 2.o
/Users/owner1/Library/Developer/Xcode/DerivedData/Effortflex-bmtqbbukvlosxpbraqoiwplpcfyj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/nanopb.build/Objects-normal/x86_64/pb_encode.o
ld: 34 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any help would be greatly apprecaited!
Something that helped me was to the following -
In terminal navigate to your project folder
Run 'pod deintegrate'
Run 'pod install'
After that my project was able to compile. Hope that works for you!
error: no such module 'RealmSwift'
import RealmSwift
While building a project from Xcode, it's working fine. Building it from Jenkins,gives me the above mentioned error.
** BUILD FAILED **
The following build commands failed:
CompileSwift normal arm64
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
Build step 'Xcode' marked build as failure
Finished: FAILURE
My Pod file looks like below
target 'MyProject' do
use_frameworks!
# Pods for MyProject
pod 'Google/Analytics'
pod 'GoogleTagManager','~> 3.15.0'
pod 'RealmSwift','~> 2.1'
target 'MyProjectTests' do
# Pods for testing
end
target 'MyProjectUITests' do
# Pods for testing
end
end
You may not have versioned your Pods directory.
You can either remove Pods from your .gitignore, or add a pod install command inside each jenkins script.
This is what I see when trying to run tests under test target in my iOS App:
ld: framework not found AFNetworking for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is how my podfile looks like:
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "8.2"
def pods
pod 'AFNetworking'
pod 'Fabric'
pod 'Crashlytics'
pod 'MagicalRecord'
pod 'SDWebImage'
pod 'SVProgressHUD'
end
target 'MySoberRoomMate' do
pods
end
inhibit_all_warnings!
I am new on IOS development and did not have the required reputation to add comment so that I am posting answer.
I did a little work with pod file and i think the pods for the test target is not added in pod file so that the compiler showing the error.
do some thing like this in the pod file for the test target
target 'TestTarget' do
pods
end
add your test target name in place of 'TestTarget'
Hope it works.
I have added Braintree with other lib using pods. My build is failed because it can't find library for Braintree. Here's what I have:
ld: library not found for -lBraintree
clang error: linker command failed with exit code 1 (use -v to see
invocation)
Things I've tried:
Used .xcworkspace instead of .xcodeproj
Set build active architecture NO
Removed any red lib.a
This is what my project looks like:
I don't see a -lBraintree flag in the last picture yet it shows here -ObjC -ObjC -l"AdIdAccessLibrary" -l"Braintree" -l"DI... why?
Podfile
target 'MyProject' do
pod 'Braintree', '3.9.3'
pod 'Google/Analytics', '~> 1.0.0'
pod 'GoogleIDFASupport'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
pod 'GoogleMaps'
end
target 'MyProjectTests' do
end