Unable to access toBlocking() in xctest - swift

I am trying to write test cases and trying to access a method which returns Single object. For this I want to use toBlocking but I am not able to access it and getting following error:
Value of type 'Single<[Property]>' (aka
'PrimitiveSequence>') has no member
'toBlocking'
Following is my code
do {
let property = try viewModel.getPropertyList(city: "1530")
.toBlocking()
.single()
XCTAssertNotNil(property)
} catch {
XCTFail("Get user settings failed")
}
Already imported following frameworks:
import RxCocoa
import RxSwift
import XCTest

You need to import RxBlocking too!
if it raises error then you should add RxBlocking to your Test target in your package manager.
For example in Pod you should have something like this in your Pod file :
target 'YourProjectTests' do
pod 'RxSwift', '~> 4.0'
pod 'RxCocoa', '~> 4.0'
pod 'RxBlocking', '~> 4.0'
pod 'RxTest', '~> 4.0'
end

Related

rego opa policy to check if resources are provided for deployment in kubernetes

I'm checking if key resources.limits is provided in deployment kubernetes using OPA rego code. Below is the code, I'm trying to fetch the resources.limits key and it is always returning TRUE. Regardless of resources provided or not.
package resourcelimits
violation[{"msg": msg}] {
some container; input.request.object.spec.template.spec.containers[container]
not container.resources.limits.memory
msg := "Resources for the pod needs to be provided"
You can try something like this:
import future.keywords.in
violation[{"msg": msg}] {
input.request.kind.kind == "Deployment"
some container in input.request.object.spec.template.spec.containers
not container.resources.limits.memory
msg := sprintf("Container '%v/%v' does not have memory limits", [input.request.object.metadata.name, container.name])
}

Deprecation Warning for AppAuth

I got some warning message. Most of them disappeared after updating related Pods. But these 3 warnings are still there. I don't have the AppAuth pod but the Firebase/Auth and Firebase/Core. What should I do to get rid of them?
Thanks,
Below is the Podfile.
=========================
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
target ‘test’ do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# use_modular_headers!
# Pods for test
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'GoogleSignIn'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
pod 'Firebase/Crashlytics'
pod 'Firebase/Analytics'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Performance'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
target ‘testTests' do
inherit! :search_paths
# Pods for testing
end
target ‘testUITests' do
inherit! :search_paths
# Pods for testing
end
end
AppAuth is a dependency of GoogleSignIn that is designed to work on iOS 7 and above.
Changing the version to 10 in the post_install script in the Podfile by deleting the minimum iOS version 7 causes the warning.
Instead of deleting it, you might be able to eliminate the warning and also the Xcode 12 warning because of no iOS 8 support by changing the minimum version to 9:
post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
Thanks to https://stackoverflow.com/a/58367269/556617 for the post_install script.
As indicated Xcode, it was deprecated so use this new method instead of openUrl
open func open(_ url: URL, options: [String : Any] = [:],
completionHandler completion: (#escaping (Bool) -> Swift.Void)? = nil)
If you realize two new parameters has default values: an empty dictionary and optional closure which is nil. That is why you can easily use as openUrl

Unable to Determine Swift Version for the Following Pods Error

I am trying to use Algolia for iOS. SWIFT_VERSION is not found for the Pod and throwing an error
Disclaimer, Algolia put out a podsec that does include the SWIFT_VERSION so I am able to proceed forward but wanted to know for the future if I run into the following error again
For the old pod, I followed the instructions here
https://cocoapods.org/pods/InstantSearchClient
I received this error
Unable to determine swift version for the following pods:
‘InstantSearchClient-library’ does not specify a Swift version and none of the
targets ( ‘Pods’ ) integrating it have the ‘SWIFT_VERSION’ attribute set. Please
contact the author or set the ‘SWIFT_VERSION’ attribute in at least one of the targets that inegrate this pod
StackOverflow had the following suggestions which did not work for me
use a pre_install
error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'Starscream')
set the ENV['SWIFT_VERSION'] = '5' at the top of the Podfile
'Unable to determine Swift version for the following pod" - Error
Set the SWIFT_VERSION in code ( I received an error message that the variable SWIFT_VERSION ) was already in use
Here is my code:
ENV['SWIFT_VERSION'] = '5'
platform :ios, '9.0'
pod 'InstantSearchClient', '~> 7.0'
target 'contacts' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
project 'contacts'
# Pods for contacts
target 'contactsTests' do
inherit! :search_paths
# Pods for testing
end
target 'contactsUITests' do
# Pods for testing
end
pre_install do |installer|
installer.analysis_result.specifications.each do |s|
if s.name == 'InstantSearchClient'
s.swift_version = '5.0'
end
end
end
end

cocoapods error : ~ target has frameworks with conflicting names: ~

My problem is pretty simple and stackoverflow has many 'similar' problems but couldn't find the exact one. Maybe too easy to solve? Anyway, here is the problem:
I use X in podfile like this:
pod 'X', '3.3.4'
and when I added the follwing,
pod 'MapboxNavigation', '~> 0.17'
I got this error from pod:
[!] The ‘Pods-WayStride’ target has frameworks with conflicting names: mapbox.framework.
And yes, the X that I've been using uses 'mapbox.framework', probably part of it, already, as I can see it under 'Pods > Pods > Steerpath-Map-SDK > Frameworks > Mapbox.framework' in Project navigator of Xcode.
Because of this error, when I tried to compile using Xcode (ver 9.4, with swift), I get this error on the line of 'import MapboxDirections':
No such module 'MapboxDirections'
What can I do?
My Podfile is very simple:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.3'
# by SP
source 'https://github.com/CocoaPods/Specs.git'
source 'https://bitbucket.org/nimbledevices/steerpath-sdk-ios-podspec.git'
source 'https://bitbucket.org/nimbledevices/steerpath-mapbox-ios-podspec.git'
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
target 'WayStride' do
# platform :ios, '8.0'
pod 'Steerpath', '3.3.4'
pod 'SwiftyJSON'
pod 'Mixpanel-swift'
pod 'Toast-Swift', '~> 3.0.1'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'MapboxNavigation', '~> 0.17'
# target 'WayStrideTests' do
# inherit! :search_paths
# # Pods for testing
# end
#
# target 'WayStrideUITests' do
# inherit! :search_paths
# # Pods for testing
# end
end
How i resolved it
Step one : open Podfile under ios/App/podfile
comment this lines out
#pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
#pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'
after this, run Pod install
now should work just fine
OR, write like this, take off the CordovaPlugins, as it already installed by the first
def capacitor_pods
#Automatic Capacitor Pod dependencies, do not delete
pod 'Capacitor', :path => '../../node_modules/#capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/#capacitor/ios'
#pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
pod 'CordovaPluginsStatic', :path => '../capacitor-cordova-ios-plugins'
pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'
# Do not delete
end

Cannot import Firebase in CocoaPod

I'm creating a CocoaPod from which I'd like to import Firebase. I get the error:
"No such module 'Firebase'"
When I add import Firebase to a Swift file in my pod.
My CocoaPod Foo's pod spec file, Foo.podspec, contains:
s.dependency 'Firebase', '~> 3.6'
It seems there is a problem with the module mapping in the podspec made by Firebase for the latest version of their pod (see https://github.com/CocoaPods/CocoaPods/issues/6138).
I am currently working on a chat system based on Firebase that I have abstracted as a private CocoaPod. If I erase all traces of Firebase in my code/ podspec, all other Pods are imported flawlessly. I don't know that there is much we can do until this is fixed.
Cheers!
I recently ran into this same problem and the solution I settled on so that I could use firebase from inside both my development pod as well as apps using it was to setup the firebase sdk inside Xcode so that it can be found in the same way that a system framework is.
Download the firebase sdk
Move the frameworks you need into Xcode /Applications/Xcode.app/Contents/Developer/Library/Frameworks/
Setup your pod spec so that it knows where the frameworks are as well as add a few required dependencies.
# Specify what libraries this depends on.
s.libraries = [
'c++', # FirebaseAnalytics.
'icucore', # FirebaseDatabase.
'sqlite3', # FirebaseAnalytics.
'z', # FirebaseAnalytics.
]
# Specify what frameworks this depends on.
s.frameworks = [
'AddressBook', # FirebaseAnalytics.
'AdSupport', # FirebaseAnalytics.
'CFNetwork', # FirebaseDatabase.
'SafariServices', # FirebaseAnalytics.
'Security', # FirebaseAnalytics, FirebaseAuth, FirebaseDatabase.
'StoreKit', # FirebaseAnalytics.
'SystemConfiguration', # FirebaseAnalytics, FirebaseDatabase.
'FirebaseAnalytics',
'FirebaseInstanceID',
'FirebaseCore',
'FirebaseCoreDiagnostics',
'FirebaseNanoPB',
'GoogleToolboxForMac',
'FirebaseAuth',
'GTMSessionFetcher',
'FirebaseDatabase'
]
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/**' }
# LDFLAGS required by Firebase dependencies.
s.pod_target_xcconfig = {
'OTHER_LDFLAGS' => '$(inherited) -ObjC',
}
This example only uses firebase Analytics, Auth and Database but I'm sure other frameworks could be added as well. It isn't the best solution but it works for my situation.