I have an iOS project with 2 development targets and 1 unit test target. The development targets are hybrid (using Objective-c and Swift at the same time), thus I have to use Bridging-Header.h within the project.
The problem is when I want to import the module into my unit test class using the following code:
#testable import <Module>
By adding the above line, unit tests stop building and output the following error:
/Users/admin/Projects/<Project>/Tests/<TestClass>.swift:10:18: Failed to import bridging header '/Users/admin/Projects/<Project>/Core_Services_Interfaces/<Module>-Bridging-Header.h'
It seems it has some kinds of problems with imported Objective-c pods.
Any help in resolving the problem is appreciated.
P.S: My Podfile:
target '<TARGET_1>' do
platform :ios, '8.0'
inhibit_all_warnings!
pod 'GoogleAnalytics'
pod 'GoogleIDFASupport'
pod 'GoogleAPIClient/Calendar', '~> 1.0.2'
pod 'GTMOAuth2', '~> 1.1.0'
pod 'GoogleMaps'
pod 'MARKRangeSlider'
pod 'MGSwipeTableCell'
pod 'KVNProgress'
pod 'Adjust', '~> 4.11.0'
pod 'HCSStarRatingView', '~> 1.5'
pod 'SDWebImage', '~>3.8'
pod 'MMPopupView'
pod "MXPagerView"
pod 'AppAnalytics'
pod 'MXSegmentedPager'
pod 'MBProgressHUD', '~> 1.1.0'
pod 'PKHUD', '~> 4.0'
pod 'DeviceGuru'
use_frameworks!
pod 'Alamofire', '~> 4.7'
pod 'ObjectMapper', '~> 3.3.0'
pod 'RealmSwift'
pod 'netfox'
pod 'KeychainSwift', '~> 11.0'
pod 'NVActivityIndicatorView'
pod "PullToRefreshKit" , "~> 0.6.0"
pod 'MaterialShowcase'
pod 'Segmentio', '~> 3.2'
target '<TARGET_2>' do
inherit! :complete
end
target '<TEST_TARGET>' do
inherit! :complete
end
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name.include?('MaterialShowcase')
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.2'
end
end
end
end
end
Related
My iOS app is developed with Xcode 7.3.
I want to use Xcode 8, and I'm using Cocoapods to generate project.
I don't want to migrate my code to swift 3.0 for now, I want to use Swift 2.3 for my project code.
Here my Podfile:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'xxxxx' do
platform :ios, '9.3'
pod 'RESideMenu', '4.0.7'
pod 'Alamofire', '3.4.1'
pod 'AlamofireImage', '2.4.1'
pod 'JSONHelper', '2.1.0'
pod 'SwiftyJSON', '2.3.2'
pod 'ObjectMapper', '1.3.0'
pod 'AlamofireObjectMapper', '3.0.2'
pod 'RealmSwift', '~> 0.97'
pod 'KVNProgress', '2.3'
pod 'CalendarLib', '2.0'
pod 'Charts/Realm', '2.2.5'
pod 'SwiftEventBus', :tag => '1.1.0', :git => 'https://github.com/cesarferreira/SwiftEventBus.git'
pod 'RichEditorView'
pod 'SwiftHSVColorPicker'
pod 'Google/Analytics'
pod 'Fabric'
pod 'Crashlytics'
end
Getting errors event if I set Use Legacy Swift Language Version to YES
Is it possible to update pods to Swift 3 version, and still use Swift 2.3 for my project?
You can't, you either use everything in Swift 2.3 or Swift 3.0. My tip for you is, if you don't wanna update to Swift 3.0, then search all your dependencies to look for a branch or version that supports 2.3.
P.S.: It's Xcode :)
Your can use pods like this :
Please add SWIFT_VERSION in your project settings and then update your pods like this:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'xxxxx' do
platform :ios, '9.3'
pod 'RESideMenu', '4.0.7'
pod 'Alamofire', '3.4.1'
pod 'AlamofireImage', '2.4.1'
pod 'JSONHelper', '2.1.0'
pod 'SwiftyJSON', '2.3.2'
pod 'ObjectMapper', '1.3.0'
pod 'AlamofireObjectMapper', '3.0.2'
pod 'RealmSwift', '~> 0.97'
pod 'KVNProgress', '2.3'
pod "CalendarLib", '2.0'
pod 'Charts/Realm', '2.2.5'
pod 'SwiftEventBus', :tag => '1.1.0', :git => 'https://github.com/cesarferreira/SwiftEventBus.git'
pod "RichEditorView"
pod 'SwiftHSVColorPicker'
pod 'Google/Analytics'
pod 'Fabric'
pod 'Crashlytics'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3' || '3.0'
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'
end
end
end
And then use install pods command.
I have integrated Alamofire in my ios project.While am testing my app using XCTest(UITest),am getting the following issue.I have googled and tried all the solutions.But not getting the solutions.Plesae help me to solve this.
Library not loaded: #rpath/Alamofire.framework/Alamofire Referenced from: /private/var/mobile/Containers/Bundle/Application/DA4702F0-6A4C-4EB6-99D0-255ABB6E3F57/Real Estate.app/Real Estate Reason: image not found Dyld Version: 353.12
this is my podfile.
target 'FreshBoss' do
use_frameworks!
# Pods for FreshBoss
pod 'Alamofire', '~> 3.4'
pod 'MBProgressHUD', '~> 0.9.2'
pod 'Google/SignIn'
target 'FreshBossTests' do
inherit! :search_paths
# Pods for testing
pod 'Alamofire', '~> 3.4'
pod 'MBProgressHUD', '~> 0.9.2'
pod 'Google/SignIn'
end
target 'FreshBossUITests' do
inherit! :search_paths
# Pods for testing
pod 'Alamofire', '~> 3.4'
pod 'MBProgressHUD', '~> 0.9.2'
pod 'Google/SignIn'
end
end
Embed Pods framework is the reason for this.UITest -> Buildphases ->
Embed Pods framework is missing.Copy from target and paste it in UITest target.It worked for me.
I have updated cocoapods today to 1.0.0 version. I got this string when I update the pods:
[!] Invalid Podfile file: [!] The specification of link_with in the Podfile is now unsupported, please use target blocks instead..
I have removed link_with in my podFile but I can't build the project because I have many Match-O-Linkers. Any one knows how should I fix this problem?
This is my Podfile right now:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
inhibit_all_warnings!
pod 'pop', '~> 1.0'
pod 'AFNetworking', '~> 1.3'
pod 'SDWebImage', '~> 3.7'
pod 'GoogleAnalytics', '~> 3'
pod 'ARAnalytics' , :subspecs => ["Crashlytics", "Amplitude", "DSL"]
pod 'FBSDKCoreKit', '~> 4.10.1'
pod 'FBSDKLoginKit', '~> 4.10.1'
pod 'FBSDKShareKit', '~> 4.10.1'
pod 'Google/SignIn'
pod 'Branch'
pod 'Leanplum-iOS-SDK'
pod 'Fabric', '1.6.7'
pod 'Crashlytics', '3.7.0'
pod 'TwitterKit'
pod 'Digits'
target 'minubeTests' do
pod 'OCMockito'
end
Try this. Works for me with more than one target.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
def myPods
pod 'pop', '~> 1.0'
pod 'AFNetworking', '~> 1.3'
pod 'SDWebImage', '~> 3.7'
pod 'GoogleAnalytics', '~> 3'
pod 'ARAnalytics' , :subspecs => ["Crashlytics", "Amplitude", "DSL"]
pod 'FBSDKCoreKit', '~> 4.10.1'
pod 'FBSDKLoginKit', '~> 4.10.1'
pod 'FBSDKShareKit', '~> 4.10.1'
pod 'Google/SignIn'
pod 'Branch'
pod 'Leanplum-iOS-SDK'
pod 'Fabric', '1.6.7'
pod 'Crashlytics', '3.7.0'
pod 'TwitterKit'
pod 'Digits'
end
target 'yourTargetOne' do
myPods
end
target 'yourTargetTwo' do
myPods
end
target 'minubeTests' do
pod 'OCMockito'
end
According to the new official CocoaPods specification since version 1.0 the new model is this:
Note that BasePods is not the actual name of any target in the project.
TargetNameOne and TargetNameTwo are the real names.
platform :ios, '8.1'
inhibit_all_warnings!
abstract_target 'BasePods' do
## Networking
pod 'AFNetworking', '~> 2.6'
# Twitter
pod 'TwitterKit', '~> 1.9'
pod 'Fabric'
# Specify your actual targets
target 'TargetNameOne'
target 'TargetNameTwo'
end
Edit - There is an implicit abstract target at the root of the Podfile now, so you could write the above example as:
platform :ios, '8.1'
inhibit_all_warnings!
## Networking
pod 'AFNetworking', '~> 2.6'
# Twitter
pod 'TwitterKit', '~> 1.9'
pod 'Fabric'
# Specify your actual targets
target 'TargetNameOne'
target 'TargetNameTwo'
This is for multiple targets which is the most common case, but can be used for single target as well and I like one universal pattern.
With the new specification. all your pod include should be specified target based.
Change your pod file to
platform :ios, '8.0'
# change minube to whatever name is of you main target
target 'minube' do
pod 'pop', '~> 1.0'
pod 'AFNetworking', '~> 1.3'
pod 'SDWebImage', '~> 3.7'
pod 'GoogleAnalytics', '~> 3'
pod 'ARAnalytics' , :subspecs => ["Crashlytics", "Amplitude", "DSL"]
pod 'FBSDKCoreKit', '~> 4.10.1'
pod 'FBSDKLoginKit', '~> 4.10.1'
pod 'FBSDKShareKit', '~> 4.10.1'
pod 'Google/SignIn'
pod 'Branch'
pod 'Leanplum-iOS-SDK'
pod 'Fabric', '1.6.7'
pod 'Crashlytics', '3.7.0'
pod 'TwitterKit'
pod 'Digits'
end
target 'minubeTests' do
pod 'OCMockito'
end
When I run pod install Cocoapods Frameworks are referring to iOS 8.3 I can't find the way to change them to iOS 9
--Screenshots
http://1drv.ms/1iTSswC
I'm currently using Xcode 7. My Podfile:
platform :ios, '9.0'
#source 'https://github.com/CocoaPods/Specs.git'
# ignore all warnings from all pods
inhibit_all_warnings!
xcodeproj 'Conversa'
link_with 'Conversa', 'ConversaTests'
pod 'AFNetworking', '~> 2.5'
pod 'JSQMessagesViewController', '~> 7.2.0'
pod 'JSQSystemSoundPlayer', '~> 2.0'
pod 'CocoaLumberjack'
pod 'Fabric'
pod 'Crashlytics'
#pod 'UIActionSheet+Blocks'
pod 'UIAlertView-Blocks'
pod 'YapDatabase/SQLCipher'
pod 'JVFloatLabeledTextField'
pod 'CRToast', '~> 0.0.7'
#pod 'Mantle', '~> 1.4'
#pod 'Navajo', '~> 0.0'
pod 'Appirater'
pod 'SIAlertView'
pod 'GCDWebServer', '~> 3.0'
I'm working on a legacy iOS project as a newbie. After I updated the CocoaPods and libraries, I've got these weird errors after building the project which never happen before.
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-Model
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-Model is not an object file (not allowed in a library)
And here is my Podfile:
platform :ios, '7.0'
link_with ['DianaViewModels']
pod 'AVOSCloud', '~> 3.0'
pod 'PixateFreestyle'
target :Model do
link_with ['DianaModels']
pod 'ReactiveCocoa', '~> 2.2'
pod 'TMCache', '~> 1.2'
pod 'SSKeychain', '~> 1.2'
pod 'Mantle', '~> 1.3'
pod 'AFNetworking', '~> 1.0'
end
target :Test do
link_with ['DianaTests']
pod 'Kiwi', '~> 2.2'
end
target :View do
link_with ['Diana']
pod 'SVPullToRefresh', '~> 0.4'
pod 'MBProgressHUD', '~> 0.7'
pod 'SWTableViewCell', '~> 0.1'
pod 'MTMigration'
pod 'Masonry'
pod 'TTTAttributedLabel'
pod 'NJKWebViewProgress'
target :ViewDebug do
link_with [
'DianaDev',
'DianaViews'
]
pod 'Reveal-iOS-SDK'
end
end
By the way, I'm using the CocoaPods plugin in the Xcode. But a lot error are output when I check the Install Docs during integration:
Error opening xar archive: /var/folders/3x/mgl299js6k13tlrspqv21n340000gn/T/Model-ReactiveCocoa.xar
Are there some wrong configurations in my CocoaPods or Build Setting in Xcode6.3? Thanks for your help!
ADDED:
Here's my Link Binary With Libraries in the Build Phases. Does the red item mean something is wrong? It looks like this is the cause.