How to add one pod to multiple targets in Cocoapods? - ios

Right now I need to add LiveSDK to multiple targets. Please see below:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
target :CalDoKit do
pod 'LiveSDK'
end
pod 'Google-API-Client/Calendar'
pod 'LiveSDK'
As you can see the LiveSDK pod added twice. And I am getting warning from the console output when I run the application: One of the two will be used. Which one is undefined.
What's the correct way to add one pod to multiple targets?
New code:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
link_with 'CalDo', 'CalDoKit'
pod 'LiveSDK'
target :CalDo do
pod 'SVProgressHUD'
end
But I am getting warning:
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `TestKit` to `Pods/Target Support Files/Pods/Pods.debug.xcconfig` or include the `Pods/Target Support Files/Pods/Pods.debug.xcconfig` in your build configuration.

Solution 1:
Remove that 'target :xx do ... end' and add pod without defining targets. It will add the pod for all targets.
Solution 2:
Delete that podfile and run pod init command from terminal. this will make a new podfile with all the targets used in the project and then you can add pods separately for each target

Add this to the Podfile
target :AnotherTarget do
pod 'LiveSDK'
end
EDIT
This is the final Podfile source
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
target :CalDoKit do
pod 'LiveSDK'
end
target :OtherTarget do
pod 'LiveSDK'
end
If you execute pod init console command on your project folder, it will create the Podfile with built in code.
See here: http://guides.cocoapods.org/syntax/podfile.html#target

Related

Cocoapods install error- Unable to find a specification for pod

I am trying to install two pods to my Xcode project from terminal. I initially had installed a pod called PRAugmentedReality, and it worked fine. Then I tried adding the pod BFTransmitter, and started getting the following error message:
[!] Unable to find a specification for 'PRAugmentedReality'
If I remove the PRAugmentedReality pod and install with just BFTransmitter, it also works fine. So basically I am able to install either on their own, but not together.
My podfile looks like this:
#source for BFTransmitter
source 'https://bitbucket.org/bridgefy/bridgefypods.git'
target 'FWF' do
pod 'BFTransmitter'
pod 'PRAugmentedReality'
target 'FWFTests' do
inherit! :search_paths
end
end
I have tried repo remove master pod setup and then pod install, still no luck.
just add source to install both pods together check my podFile and add sourced before your target as I did
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
source 'https://bitbucket.org/bridgefy/bridgefypods.git'
target 'pod' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
pod 'BFTransmitter'
pod 'PRAugmentedReality'
# Pods for pod
end
Result
I encounter the same problem in my project.
When I was editing pod file, I changed pod 'SCSoftKycSolutionSdkSource' to pod 'MyprojectName'.
I fixed the below, issue fixed.
pod 'SCSoftKycSolutionSdkSource'

The dependency `SinchVerification-Swift` is not used in any concrete target

I am trying to use SinchVerification in my IOS app. However after I do pod install I get this error:
The dependency SinchVerification-Swift is not used in any concrete target.
What does this mean? What should I do?
You should write your pod after do
target 'Your-Project' do
pod 'SinchVerification-Swift'
end
Here is usually caused by lost the target in Podfile. And if the Podfile is not in the same dir wiht .xcodeproj, you have also to add project 'path/to/Project.xcodeproj' to specify it.
platform :ios, '8.1'
use_frameworks!
pod 'SinchVerification-Swift'
target 'your target name.'

Build fails after updating cocoapods to 1.0.1

I updated cocoapods today, deleted the Pods folder entirely and executed pod install.
When i am trying to build now, i receive the error in the attached image.
My podfile looks the following:
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/artsy/Specs.git'
platform :ios, '9.0'
inhibit_all_warnings!
use_frameworks!
target 'MyTarget' do
pod '....'
end
I tried adding #define LOG_OBJC_MAYBE(...) to my pch file but it did not help. What might be the issue?

COCOAPOD file not found for Xcode unit tests only

I have added PLCrashReporter using POD
use_frameworks!
pod 'PLCrashReporter'
I have imported following files in Briding Header to use in my swift project
#import <CrashReporter/CrashReporter.h>
#import <CrashReporter/PLCrashReport.h>
If I run the project, then I don't get any problem and it works as expected
If I do xcode unit-test I get the following error
(Xcode->Product->Test)
Add the pods separately for Target and TargetTests
Make the following changes in POD file
target ‘Target’ do
platform :ios, ‘8.0’
use_frameworks!
pod 'PLCrashReporter'
end
target 'TargetTests' do
platform :ios, ‘8.0’
use_frameworks!
pod 'PLCrashReporter'
end
Go to the Build Settings of TargetTests
and set the value for “Other Linker Flags” as $(inherited)
Do a POD install then do Clean Build Folder and run

Unable to find a target named `ProjectName`

I added new pod in PodFile and ran command
pod install
It deleted all previous pods and failed with following error
Unable to find a target named `ProjectName`
However I recovered all deleted pods by using Git, but now my project is not being compiled, it's giving me the following error:
/Users/userName/Library/Developer/Xcode/DerivedData/Project_Name-fhktwvetozjdorboqdzfwlpzrcyw/Build/Intermediates/Project_Name.build/Debug-iphonesimulator/Project_Name.build/Script-D7BB987C75C5AEC6033AA28E.sh:
/Users/userName/Desktop/iOS_Workspace/Project_Name/Pods/Target Support
Files/Pods-Project_Name/Pods-Project_Name-resources.sh: /bin/sh^M: bad
interpreter: No such file or directory
I tried every solution regarding pods, but neither worked for me.
Any help will be appreciated. Thanks
After spending hours on Google just opened Podfile and found that project name is wrong. So I have just written correct project name in Podfile and issue has been resolved.
Before:
target 'Wrong Project Name' do
pod 'Parse'
pod 'SDWebImage'
end
After:
target 'Correct Project Name' do
pod 'Parse'
pod 'SDWebImage'
end
According to the error, you specify a target named ProjectName but this does not exist in your project. Read the podfile syntax reference carefully and make sure you add the right target name (in my case it's called Tester:)
It is due to target name changed.
just opened Podfile and replace target name with new target name.
(In my case “GoogleMapSample” was “Map Sample”,
“GoogleMapSampleTests” was “Map SampleTests”,
“GoogleMapSampleUITests” was “Map SampleUITests”,
means I just replace “Map Sample” with “GoogleMapSample” for all targets)
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'GoogleMapSample' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'GoogleMaps'
pod 'GooglePlaces'
pod 'Alamofire', '~> 4.4’
pod 'SwiftyJSON', '~> 4.0'
# Pods for GoogleMapSample
target 'GoogleMapSampleTests' do
inherit! :search_paths
# Pods for testing
end
target 'GoogleMapSampleUITests' do
inherit! :search_paths
# Pods for testing
end
end
Take backup of podfile (copy paste at specified location).
Remove pod file. Move to Trash (from) Xcode.
Go to terminal, After locating your pods directory, Hit: pod init
Paste contents from backup-ed file (1st step)...Copy only pod libs. ex. pod 'Firebase/Core'
pod install
Re-start your project then open YourProjectName.xcworkspace.
In my case, the target name was the same,
but it was case sensitive wrong.
"myTarget" // podfile
"MyTarget" // Xcode
make sure your current name for project in Podfile Matching with right name
target 'Project name' do
use_frameworks!
# Pods for Project name
pod 'SwiftMessages'
end
I have a lot of schemas like below. So, we should map a schema in pod file.
Wrong : target 'MobileBranch' do
Correct : target 'Test-MobileBranch' do
Correct : target 'Main-MobileBranch' do
If you are here in 2022 using SwiftUI, I just uncomment the line and specified the latest iOS version. I am using Xcode 14.0.1.
# Uncomment the next line to define a global platform for your project
platform :ios, '16.0'
FIXED
Just I changed App to the correct name of the product which is Mevenda:
target 'Mevenda' do
capacitor_pods
# Add your Pods here
pod 'FirebaseStorage'
end

Resources