iOS unit tests fail on CocoaPods Google Maps SDK - ios

Since migrating our code base to Swift 3 using Xcode 8 we've been unable to get our unit tests to run. The app compiles and archives fine for the store, but when we try to run tests it fails to build complaining of:
framework not found GoogleMapsBase for architecture x86_64
I've checked our podfile and everything appears to be set correctly according to the latest documentation.
Edit: Podfile below
source 'https://github.com/CocoaPods/Specs.git'
target "Borked" do
platform :ios, '9.3'
use_frameworks!
pod 'GoogleMaps'
pod 'GoogleAnalytics'
target "Unit Tests" do
inherit! :search_paths
end
target "UI Tests" do
inherit! :search_paths
end
end

Something like this should work!
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.3'
use_frameworks!
target 'MyApp' do
pod 'GoogleMaps'
pod 'GoogleAnalytics'
target "Unit Tests" do
inherit! :search_paths
end
target "UI Tests" do
inherit! :search_paths
end
end
or this
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.3'
use_frameworks!
target 'MyApp' do
target 'MyExtension' do
pod 'GoogleMaps'
pod 'GoogleAnalytics'
target "Unit Tests" do
inherit! :search_paths
end
target "UI Tests" do
inherit! :search_paths
end
end
end

Related

Starscream on iOS and WatchOS - Cocoapods

im trying to use Starscream both on iOS and WatchOS with Cocoapods.
here's my podfile:
inhibit_all_warnings!
def all_pods
pod 'Starscream', '~>3.0.5'
end
target ‘ProjTest’ do
platform :ios, '10.0'
use_frameworks!
all_pods
end
target 'ProjTestTests' do
inherit! :search_paths
end
target 'ProjTestUITests' do
inherit! :search_paths
end
target 'ProjTestWatch' do
platform :watchos, '5.0'
all_pods
end
I have a class, SocketManager, that I use on the app already, I just want to use that same class on the watchApp Target, but the only error im getting is : No such module 'Starscream' on the import line.
The most weird for me, is if im go look the Framework Search paths, and Header Search Paths on the Watch Target, they're both empty. But if I try to do the same as the iOS app target. and put an $(inherited), they inherit the libs from the iOS App.

No such file or directory Command PhaseScriptExecution failed with a nonzero exit code

I am getting the following error:
/Users/avivelkayam/Library/Developer/Xcode/DerivedData/ProjectName-evucwwryclirvdbauuppyncmdfyp/Build/Intermediates.noindex/TrendyPalCustomer.build/Debug-iphoneos/ProjectName.build/Script-F4E471CC20FB2640005A6092.sh: line 2: /Users/avivelkayam/TrendyPal: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code
I tried remove and reinstall cocoa pods but it didn't work. Any ideas?
In my case, it had something to do with Podfile and UITest dependencies, after I removed UITests pods the problem was solved.
Here is the problematic Podfile:
target 'YourApp' do
use_frameworks!
inhibit_all_warnings!
# Pods for YourApp
pod 'Whathever'
target 'YourAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'YourAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
and here is the fixed one:
target 'YourApp' do
use_frameworks!
inhibit_all_warnings!
# Pods for YourApp
pod 'Whathever'
target 'YourAppTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'YourAppUITests'
Then run pod install again

Xcode 10 UI Tests Reason: Image Not Found with Cocoapods

I'm trying to run a UI Test in my app but as soon as the simulator launches I get:
The bundle “AppUITests” couldn't be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2018-10-05 11:04:59.772078-0500 AppUITests-Runner[53273:1645870] (dlopen_preflight(/Users/John/Library/Developer/Xcode/DerivedData/app-ios-client-ewtlrcqcxoeiaudgmthymuhcuxfz/Build/Products/Debug-iphonesimulator/AppUITests-Runner.app/PlugIns/AppUITests.xctest/AppUITests): Library not loaded: #rpath/libswiftSwiftOnoneSupport.dylib
Referenced from: /Users/John/Library/Developer/Xcode/DerivedData/app-ios-client-ewtlrcqcxoeiaudgmthymuhcuxfz/Build/Products/Debug-iphonesimulator/AppUITests-Runner.app/PlugIns/AppUITests.xctest/Frameworks/Alamofire.framework/Alamofire
Reason: image not found)
My UITest is the template created by Xcode 10, I'm using Cocoapods 1.5.3 and Swift 4.2
My project structure:
Workspace
Custom Framework (The Podfile is here)
App A (Here I'm running the UITests)
App B
My podfile looks like this:
platform :ios, '10.0'
inhibit_all_warnings!
use_frameworks!
target 'App Library' do
use_frameworks!
pod 'Intercom'
pod 'Spreedly'
pod 'Alamofire'
pod 'IGListKit'
pod 'CardIO'
pod 'SwiftKeychainWrapper'
pod 'OneTimePassword', :git => 'https://github.com/john/OneTimePassword.git', :branch => 'develop'
pod 'SnapKit'
pod 'DateToolsSwift'
pod 'BetterSegmentedControl'
pod 'SDWebImage'
pod 'SwiftLocation'
pod 'Nuke'
pod 'Instabug'
pod 'Mixpanel-swift'
target 'App LibraryTests' do
inherit! :search_paths
# Pods for testing
end
target 'App' do
project '../App/App'
inherit! :complete
use_frameworks!
pod 'FacebookCore'
pod 'FacebookLogin'
target 'AppTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'App Business' do
project '../App Business/App Business'
inherit! :complete
use_frameworks!
target 'App BusinessTests' do
inherit! :search_paths
# Pods for testing
end
target 'App BusinessUITests' do
inherit! :search_paths
# Pods for testing
end
end
end
# The UI Test target I'm trying to run
target 'AppUITests' do
inherit! :search_paths
use_frameworks!
# Pods for testing
project '../App/App'
pod 'Intercom'
pod 'Spreedly'
pod 'Alamofire'
pod 'IGListKit'
pod 'CardIO'
pod 'SwiftKeychainWrapper'
pod 'OneTimePassword', :git => 'https://github.com/john/OneTimePassword.git', :branch => 'develop'
pod 'SnapKit'
pod 'DateToolsSwift'
pod 'BetterSegmentedControl'
pod 'SDWebImage'
pod 'SwiftLocation'
pod 'Nuke'
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'Instabug'
pod 'Mixpanel-swift'
end
workspace '../app-ios-client'
I have tried putting the UI test target inside the target app with !inherit:complete and !inherit:search_paths, moving it outside like in the code posted above. I have also cleaned the build folders, deleted derived data and restarted Xcode and I still have this problem. I have also tried adding import UIKit and import Alamofire and nothing has worked. Between all this possible fixes I have run pod deintegrate followed by pod install. I think the problem may be related to the podfile being inside my custom framework but honestly I have no idea. Any ideas? Thank you!
My fix was similar to https://stackoverflow.com/a/54034832/883413 except I didn't bother with the post_install section.
Previously my podfile structure was similar to that in the question:
platform :ios, '10.0'
target 'AppName' do
use_frameworks!
pod 'PodName'
target 'AppNameTests' do
inherit! :search_paths
end
target 'AppNameUITests' do
inherit! :search_paths
end
end
Changing it to (the newer?) structure like this resolved the issue:
platform :ios, '10.0'
use_frameworks!
def all_pods
pod 'PodName'
end
target 'AppName' do
all_pods
end
target 'AppNameTests' do
inherit! :search_paths
all_pods
end
target 'AppNameUITests' do
inherit! :search_paths
all_pods
end
I fixed it by changing that target in my podfile to this:
target 'AppUITests' do
inherit! :search_paths
use_frameworks!
# Pods for testing
project '../App/App'
end
Try beside of adding inherit! :search_paths
also changing ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES in post_install
use_frameworks!
def shared_pods
pod 'SomePod'
end
target 'App_name' do
shared_pods
end
target 'App_nameTests' do
inherit! :search_paths
shared_pods
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
end
end
end

OBJC_META_CLASS Issue

Hi Team i am using following pod file in my single view application project
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'projectbase' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for projectbase
target 'projectbaseTests' do
inherit! :search_paths
pod 'AFNetworking'
pod 'LGSideMenuController'
pod 'SDWebImage'
pod 'MBProgressHUD'
end
target 'projectbaseUITests' do
inherit! :search_paths
# Pods for testing
end
end
But As i am using "LGSideMenuController" in viewcontroller.h i am getting the Meta class error following is the code and screen shot of error
#import <UIKit/UIKit.h>
#import <LGSideMenuController.h>
#interface ViewController : LGSideMenuController
#end
Compilation with following line is OK
#import <LGSideMenuController.h>
But as i used
#interface ViewController : LGSideMenuController
error occurred
Can any one please help me to resolve this issue
Xcode version is 8.3.2
Please replace pod file with following code.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'projectbase' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
pod 'AFNetworking'
pod 'LGSideMenuController'
pod 'SDWebImage'
pod 'MBProgressHUD'
target 'projectbaseTests' do
inherit! :search_paths
end
target 'projectbaseUITests' do
inherit! :search_paths
# Pods for testing
end
end

I got error message Unable to find a target named `YOUR_APPLICATION_TARGET_NAME_HERE`, did find `FoodTracker` and `FoodTrackerTests`. how

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'FoodTracker' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for FoodTracker
target ‘FoodTrackerTests’ do
inherit! :search_paths
# Pods for testing
end
source 'https://github.com/CocoaPods/Specs.git'
target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
pod 'GoogleMaps'
pod 'GooglePlaces'
end
end
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'FoodTracker' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
# Pods for FoodTracker
pod 'GoogleMaps'
pod 'GooglePlaces'
end
target ‘FoodTrackerTests’ do
inherit! :search_paths
# Pods for testing
end

Resources