pod in testing target return no such module error - cocoapods

I have the following pod file, which works fine for my normal code but as soon as I want to import a pod from the test target in one of my tests it says No such module. I have tried building for testing, building for normal, I literally tried everything that came up in my mind without luck. What am I doing wrong here?
target 'MyApp' do
use_frameworks!
pod 'RxSwift'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
pod 'RxTest'
pod 'RxBlocking'
end
end
I use CocoaPods 1.2.1

I found this post helpful. By making sure I had the same path values and user defined variables in both targets, I was able to get passed this error.

Related

Cocoapods curl: (22) The requested URL returned error: 403 Forbidden

I am facing an issue when trying to get the "SpotX" dependency from Cocoapods that only affects a particular computer. I have tried it on my personal MacBook Pro and it works. However, my Mac Mini is failing.
The Podfile looks like that:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Demo' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Demo
pod 'SpotX-SDK'
pod 'SuperAwesome', '7.2.13'
pod 'SpotX-SDK-AVPlayer'
target 'DemoTests' do
inherit! :search_paths
# Pods for testing
end
target 'DemoUITests' do
# Pods for testing
end
end
target 'DemoTV' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for DemoTV
pod 'SpotX-SDK-AVPlayer'
target 'DemoTVTests' do
inherit! :search_paths
# Pods for testing
end
target 'DemoTVUITests' do
# Pods for testing
end
end
According to Here, the version is available
The error message given is:
The weird part is that is working on other computers with the same Xcode version...
Any ideas?
DATA:
git version 2.24.3 (Apple Git-128)
Cocoapods version = 1.10.1
Make sure you have access to the url of the cocoapod zip file (try it opening it on your browser)
In my case it was a VPN issue, i had to disable VPN to have access to the url, then i tried pod install again and it worked
I also got the same error. Then I referred release notes of Spot SDK here and updated my podfile accordingly with 4.10.0.
Then tried pod install again and it worked.

How to fix "The target [...] is declared multiple times" after pod install?

Working on a react-native(version 0.59.5) project, just installed cocoapods(version 1.7.5)
Installation process:
(from within project directory)
-sudo gem install cocoapods
(from within iOS directory of project)
-pod init
-pod install --repo-update
Result:
Analyzing Dependencies
[!] The Target 'ProjectName-tvOSTests' is declared multiple times.
then tried pod update which resulted in the same 'Analyzing Dependencies' warning. There is only a Podfile and a 'Pods' directory in iOS directory. the pods directory has three sub-directories which are all empty. It seems there was a hangup during pod install but I don't know where to look for the duplicate declaration.
I'm aware you should be working from within the ProjectName.xcworkspace file after a installing cocoapods, but there is no .xcworkspace file in my iOS directory of project. How do I fix this?
EDIT:
Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'TicTacWHOA' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for TicTacWHOA
pod 'Google-Mobile-Ads-SDK'
target 'TicTacWHOA-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
target 'TicTacWHOATests' do
inherit! :search_paths
# Pods for testing
pod 'Google-Mobile-Ads-SDK'
end
end
target 'TicTacWHOA-tvOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for TicTacWHOA-tvOS
target 'TicTacWHOA-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
The issue was that the "Target" was literally declared twice in the Podfile. so simple and right in front of your face potentially. I Just didn't think anything of it because it was a completely generated file except the one line I added.
All you need to do is go to podfile and look for the code in the error
for example my error was
[!] The target fifty-tvOSTests is declared multiple times.
now i have deleted this piece of code from the podfile once.
target 'fifty-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
fifty is the name of my project you know well what is yours
the above piece of code was twice in the Podfile so delete if you find multiple just keep only once

Adding Mongodb to ios project

I am currently adding monogodb to my ios project. Just after following the instruction stitch mongodb offered, I am stuck at when pod installing StitchCoreSDK. It supposed to create a xcworkspace file, but it didn't. Instead, I got the following message.
enter image description here
The podfile I create is like following
# Uncomment the next line to define a global platform for your project
platform :ios, '11.4'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'paotuaniOS' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
# Pods for paotuaniOS
pod 'Nexmo-Stitch'
pod 'StitchSDK', '~> 4.0.5'
target 'paotuaniOSTests' do
inherit! :search_paths
# Pods for testing
end
target 'paotuaniOSUITests' do
inherit! :search_paths
# Pods for testing
end
end
Can any one help me with this issue?
Thanks!!!
I had this issue before. The repo had problems. The repo has been updated. Please use
pod 'StitchSDK', '~> 4.1.1'

Trying to Rebuild a Legacy IOS App, Getting Error in Facebook-IOS-SDK Cocoapod

I've been asked to rebuild an existing IOS app that uses Facebook-IOS-SDK. The app is at least 5 years old so I expected things to be deprecated. I have some limited experience with XCode and IOS but I'm far from an expert. I've never used cocapods until today. I installed cocoapods and ran pod init. Facebook-IOS-SDK ver 3.24.4 loaded with no errors (other pods too, including Bolt, with no errors).
I've read the migration notes on the FB dev page regarding the versions and it's implied that I should be able to use 3.24. When I do a clean build I get the error:
(FBRequest *)requestForUpdateOpenGraphObject(id<FBOpenGraphObject>)object
{
return [FBRequest requestForUpdateOpenGraphObjectWithId:object[#"id"] graphObject:object];
}
Expected method to read dictionary element not found on object of type 'id<FBOpenGraphObject>'
This error is in FBRequest.m, the cocoapod code, not in my clients code. This code is marked read only. If this is the correct pod version, and I can't change it then is there some other dependency in the (large) project that needs to be updated?
Podfile:
# Uncomment this line to define a global platform for your project
platform :ios, "9.0"
target "tbd" do
pod 'IQKeyboardManager'
pod 'UICKeyChainStore'
pod 'CocoaLumberjack', '~> 2.0.0-beta'
pod 'SDURLCache'
pod 'HockeySDK'
pod 'Facebook-iOS-SDK', '~> 3.23'
pod 'GoogleAnalytics-iOS-SDK'
pod 'UIActionSheet-Blocks', '~> 1.0'
end
target "tbdTests" do
end
The only, nasty, solution I found is to change the code inside FBRequest.m manually.
Change line 370 from:
return [FBRequest requestForUpdateOpenGraphObjectWithId:object[#"id"] graphObject:object];
to
return [FBRequest requestForUpdateOpenGraphObjectWithId:object.objectID graphObject:object];
this should make you project runs again.
Again, this is not a nice solution, but it works :)
Emilio
if you don't have the need to use Facebook-IOS-SDK ver 3.24.4 you can simply use the latest version 4.36.0.
have a look at your Podfile and see if there is any reference to Facebook-IOS-SDK, if there is something like:
pod 'Facebook-IOS-SDK', '~> 3.0'
you can replace it with:
pod 'Facebook-IOS-SDK', '~> 4.0'
otherwise post your Podfile and we can have a look.
Cheers

Update / Install CocoaPods for specific target

Is it possible to do pod install #targetName?
I stuck with a problem that I do not have an option to update pods for my project but I have to install new pods for my unit tests target.
I don´t think there is any pod update #targetName command in CocoaPods. What you can do is to add the desired pod in your unit test target only and then run a pod update, since there is not any changes in the other targets then they will not be affected by this update.
And if you add targets after you have made your pod init you can just append these targets to your podfile, like this:
target 'ANewTargetAdded' do
inherit! :search_paths
pod 'SomePOD'
end
If you now add a new pod to ANewTargetAdded and run pod update, then this will only affect ANewTargetAdded if you haven´t made any changes to your other targets in your podfile.
There isn't any like pod update #targetName but you can specify different pods for different targets and unit tests and run pod update.
Something like this.
target 'TestProject' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for TestProject
target 'TestProjectTests' do
inherit! :search_paths
# Pods for testing
end
target 'TestProjectUITests' do
inherit! :search_paths
# Pods for testing
end
end

Resources