I have a problem with my swift project on XCode. I use Cocoapods for the frameworks.
My project don't build. I have this error : No such module 'ObjectMapper'.
I have tried pod install, pod update, pod deintegrate, clean build folder, delete .xcworkspace file, delete derived data, update XCode, but nothing work.
The problem isn't the code because it had work well for this mac last week and today on other mac. It appeared after changing branches on my git.
Here is my pod file:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
def pods
platform :ios, '13.2'
pod 'RESideMenu'
pod 'Alamofire', '~> 4.5'
pod 'AlamofireImage', '~> 3.1'
pod 'JSONHelper'
pod 'SwiftyJSON'
pod 'Google/Analytics'
pod 'ObjectMapper', '~> 3'
pod 'AlamofireObjectMapper', '~> 5.0'
pod 'RealmSwift', '~> 3.18.0'
pod 'KVNProgress'
pod 'CalendarLib'
pod 'Charts', '3.2.1'
pod 'SwiftEventBus', :tag => '2.2.0', :git => 'https://github.com/cesarferreira/SwiftEventBus.git'
pod 'RichEditorView', :git => 'https://github.com/T-Pro/RichEditorView.git', :branch => 'master'
pod 'SwiftHSVColorPicker'
pod 'Crashlytics'
pod 'Toucan'
pod 'RFQuiltLayout'
pod 'Kingfisher'
pod 'CropViewController', :tag => '2.4.0', :git => 'https://github.com/TimOliver/TOCropViewController.git'
pod 'MatomoTracker', '~> 7'
pod 'MaterialShowcase'
pod 'UIDeviceIdentifier', :git => 'https://github.com/squarefrog/UIDeviceIdentifier.git'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if ['RichEditorView', 'Toucan'].include? target.name
config.build_settings['SWIFT_VERSION'] = '4.0'
else
config.build_settings['SWIFT_VERSION'] = '4.2'
end
end
end
end
target 'targetName' do
pods
end
I'm running pod install on terminal for the first time and it's been taking a very long time (longer than 20 minutes). When i ran pod install --verbose it's getting stuck on this. Not sure if it should be taking this long, any ideas on how to fix it? enter image description here
// Podfile
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
target 'UberEATS' do
pod 'GoogleMaps'
pod 'GooglePlaces'
pod 'SwiftyJSON', '~> 4.0'
pod 'Alamofire', '~> 4.7'
pod 'SDWebImage', '~> 4.0'
pod 'Fabric'
pod 'Crashlytics'
end
Delete source 'https://github.com/CocoaPods/Specs.git' from the Podfile.
Recent versions of CocoaPods use a much faster cdn as the default source location.
I was using FBSDKLoginKit without any problem until morning.
I imported FBSDKLogin kit using cocoapod :
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'LePhoceen' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for LePhoceen
pod 'Alamofire', '~> 3.4'
pod 'GoogleMobileAds'
pod 'Google/Analytics'
pod 'Toast-Swift', '~> 1.3.0'
pod 'SwiftyJSON', '~> 2.3'
pod 'TwitterKit'
pod 'Crashlytics', '~> 3.7'
pod 'ATInternet-iOS-Swift-SDK', '~> 2.2'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
pod 'FBAudienceNetwork'
pod 'AFNetworking', '~> 3.0'
pod 'MBProgressHUD', '~> 0.9.2'
end
and I created a bridge :
#import <Google/Analytics.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <CommonCrypto/CommonCrypto.h>
#import <AFNetworking/AFNetworking.h>
But now when I import 'FBSDKLoginKit' I get the error
/Users/maxmargheriti/Desktop/LePhocéen/LePhoceeniOS/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginButton.h:23:9: 'FBSDKLoginKit/FBSDKLoginManager.h' file not found
and
/Users/maxmargheriti/Desktop/LePhocéen/LePhoceeniOS/LePhoceen/Views/Login/LoginVC.swift:13:8: Could not build Objective-C module 'FBSDKLoginKit'
Thanks for your help !
The question is how to cleanly remove Test in cocoapods PodFile ?
I'ved just recently updated cocoapods 1.0.0 to my project
I ran "pod init" to generate a sample PodFile then put in my pods.
Whole bunch of error generated by the xcode test project ProjectNameTests
http://imgur.com/fUOF18i
How can I cleanly remove the tests ? Even if comment it out there is other problems like Bridging-Header.h cannot find dependent header.
In my current PodFile for 1.0.0:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'ProjectName' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ProjectName
pod 'FBSDKCoreKit', '~> 4.9'
pod 'FBSDKLoginKit', '~> 4.9'
pod 'FBSDKShareKit', '~> 4.9'
pod 'SwiftyJSON', '~> 2.3.1'
pod 'Alamofire', '~> 3.0'
pod 'Google/Analytics', '~> 1.0.0'
pod 'Fabric'
pod 'Crashlytics'
pod 'AWSS3'
target 'ProjectNameTests' do
inherit! :search_paths
# Pods for testing
end
end
my previous PodFile, no mention for target project or test:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'FBSDKCoreKit', '~> 4.9'
pod 'FBSDKLoginKit', '~> 4.9'
pod 'FBSDKShareKit', '~> 4.9'
pod 'SwiftyJSON', '~> 2.3.1'
pod 'Alamofire', '~> 3.0'
pod 'Google/Analytics', '~> 1.0.0'
pod 'Fabric'
pod 'Crashlytics'
pod 'AWSS3'
The type of errors you'r defining are not because you have a target to the tests in your Podfile. inherit! :search_paths indicates that this target inherits the pods from the target above it.
One thing you might be getting wrong is that the "target 'ProjectName' do" is not regarding your project name but an actual target of your project.
A target can have a different name then your project.
You can also check the official migration guide Migration Guide.
I'm using CocoaPods with my Xcode 4 project and I have three targets for my project (the default, one for building a lite version and one for building a demo version). All the targets use the same libraries, but CocoaPods is only adding the static library and search paths to the primary target. My podfile looks like this:
platform :ios, '5.0'
pod 'TestFlightSDK', '>= 1.1'
pod 'MBProgressHUD', '0.5'
pod 'iRate', '>= 1.6.2'
pod 'TimesSquare', '1.0.1'
pod 'AFNetworking', '1.1.0'
pod 'KKPasscodeLock', '0.1.5'
pod 'iCarousel', '1.7.4'
The only way I was get this to work was to specify each target individually with all the the pods listed again.
platform :ios, '5.0'
target :default do
pod 'TestFlightSDK', '>= 1.1'
pod 'MBProgressHUD', '0.5'
pod 'iRate', '>= 1.6.2'
pod 'TimesSquare', '1.0.1'
pod 'AFNetworking', '1.1.0'
pod 'KKPasscodeLock', '0.1.5'
pod 'iCarousel', '1.7.4'
end
target :lite do
link_with 'app-lite'
pod 'TestFlightSDK', '>= 1.1'
pod 'MBProgressHUD', '0.5'
pod 'iRate', '>= 1.6.2'
pod 'TimesSquare', '1.0.1'
pod 'AFNetworking', '1.1.0'
pod 'KKPasscodeLock', '0.1.5'
pod 'iCarousel', '1.7.4'
end
target :demo do
link_with 'app-demo'
pod 'TestFlightSDK', '>= 1.1'
pod 'MBProgressHUD', '0.5'
pod 'iRate', '>= 1.6.2'
pod 'TimesSquare', '1.0.1'
pod 'AFNetworking', '1.1.0'
pod 'KKPasscodeLock', '0.1.5'
pod 'iCarousel', '1.7.4'
end
Is there a better way to do this?
Since CocoaPods 1.0 has changed the syntax, instead of using link_with, do something like:
# Note; name needs to be all lower-case.
def shared_pods
pod 'SSKeychain', '~> 0.1.4'
pod 'INAppStoreWindow', :head
pod 'AFNetworking', '1.1.0'
pod 'Reachability', '~> 3.1.0'
pod 'KSADNTwitterFormatter', '~> 0.1.0'
pod 'MASShortcut', '~> 1.1'
pod 'MagicalRecord', '2.1'
pod 'MASPreferences', '~> 1.0'
end
target 'Sail' do
shared_pods
end
target 'Sail-iOS' do
shared_pods
end
Old answer Pre CocoaPods 1.0:
Yes there is a better way! Check out link_with where you can do link_with 'MyApp', 'MyOtherApp' to specify multiple targets.
I use this with unit tests like link_with 'App', 'App-Tests' (beware of spaces in target's names).
Example:
platform :osx, '10.8'
link_with 'Sail', 'Sail-Tests'
pod 'SSKeychain', '~> 0.1.4'
pod 'INAppStoreWindow', :head
pod 'AFNetworking', '1.1.0'
pod 'Reachability', '~> 3.1.0'
pod 'KSADNTwitterFormatter', '~> 0.1.0'
pod 'MASShortcut', '~> 1.1'
pod 'MagicalRecord', '2.1'
pod 'MASPreferences', '~> 1.0'
Approach using abstract_target:
In below example, the 'ShowsiOS', 'ShowsTV' and 'ShowsTests' targets have their own separate pods, plus ShowsKit inherited, because they are all child of the dummy target 'Shows'.
# Note: There are no targets called "Shows" in any of this workspace's Xcode projects.
abstract_target 'Shows' do
pod 'ShowsKit'
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
target 'ShowsTV' do
pod 'ShowTVAuth'
end
# Our tests target has its own copy
# of our testing frameworks
# (beside inheriting ShowsKit pod).
target 'ShowsTests' do
inherit! :search_paths
pod 'Specta'
pod 'Expecta'
end
end
I think better solution is
# Podfile
platform :ios, '8.0'
use_frameworks!
# Available pods
def available_pods
pod 'AFNetworking', '1.1.0'
pod 'Reachability', '~> 3.1.0'
end
target 'demo' do
available_pods
end
target 'demoTests' do
available_pods
end
Reference from : http://natashatherobot.com/cocoapods-installing-same-pod-multiple-targets/
If you want multiple targets to share the same pods, use an abstract_target.
# There are no targets called "Shows" in any Xcode projects
abstract_target 'Shows' do
pod 'ShowsKit'
pod 'Fabric'
# Has its own copy of ShowsKit + ShowWebAuth
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
# Has its own copy of ShowsKit + ShowTVAuth
target 'ShowsTV' do
pod 'ShowTVAuth'
end
end
or just
pod 'ShowsKit'
pod 'Fabric'
# Has its own copy of ShowsKit + ShowWebAuth
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
# Has its own copy of ShowsKit + ShowTVAuth
target 'ShowsTV' do
pod 'ShowTVAuth'
end
source: https://guides.cocoapods.org/using/the-podfile.html
Easiest way is to use an abstract target, where each pod specified will be linked with all targets.
abstract_target 'someNameForAbstractTarget' do
pod 'podThatIsForAllTargets'
end
target 'realTarget' do
pod 'podThatIsOnlyForThisTarget'
end