Include pods in main target and not in WatchKit extension
The warnings outputted by CocoaPods is due to two CocoaPods targets are trying to be linked to a single target in your application (which isn't supported).
I.e, you have an explicit target HomeHandler
and you are linking the nameless target to HomeHandler too with link_with "HomeHandler", "HomeHandler WatchKit Extension"
.
My suggestion would be to revamp your Podfile to look something like the following:
platform :ios, '8.0'
use_frameworks!
source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
def shared_pods
pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git'
pod 'CocoaLumberjack', '~> 2.0.0'
pod 'MagicalRecord', :git => "https://github.com/magicalpanda/MagicalRecord.git"
pod 'UICKeyChainStore'
end
target 'HomeHandler' do
shared_pods
pod 'XLForm', git: 'git@github.com:xmartlabs/XLForm.git'
pod 'UAProgressView'
pod 'Classy', git: 'git@github.com:depl0y/Classy.git'
pod 'Reveal-iOS-SDK', :configurations => ['Debug']
pod 'JBChartView', '~> 2.8.9'
pod 'RFQuiltLayout'
pod 'HUMSlider', '~> 1.0'
pod 'SwiftEventBus', :git => 'https://github.com/depl0y/SwiftEventBus.git'
pod 'PureLayout'
end
target 'HomeHandler WatchKit Extension' do
shared_pods
end
After adding watchkit extension to project, previously added third party frameworks no longer work
I actually found the answer myself. And as usual it was something silly but important. When I added the extension, the third party libraries and frameworks were not automatically added to the target, so I had to go back in and "add files" in order to add the Crashlytics framework into the WatchKit Extension target.
Also, it turns out this is a wider problem. My guess is it's an issue that might happen for any third party library or framework when any extension is added. I also had the issue with my cocoapods, and had to add:
link_with 'target1', 'target2'
to the podfile to make sure the pods were added to more than just the default first target.
Props to Stephen Johnson though, for this kind of issue the Header and Library search paths are excellent places to check for debugging.
Working with Cocoapods + WatchOS 2 target
There are two way to integrate pods using podfile with WathOS.
1) Add Required pods directly to watch extension as below.
target '<your watch Extension Name>' do
platform :watchos, '2.0'
pod 'RealmSwift'
pod 'Alamofire'
pod 'MMWormhole', '~> 2.0.0'
end
2) Create Shared pods and add to both watch extension and iOS target both.
def sharedPods
pod 'RealmSwift'
pod 'Alamofire'
end
target '<your watch Extension Name>' do
platform :watchos, '2.0'
sharedPods
end
target '<your iOSApp Name>' do
platform :ios, '8.0'
sharedPods
end
Add only watchOS and iOS supported pods in sharedPods
,
Do not add pods in sharedPods
which does not support watchOS.
e.g.
def sharedPods
pod 'RealmSwift'
pod 'Alamofire'
pod 'otherWatchOS&iOS supported Pod1'
pod 'otherWatchOS&iOS supported Pod2'
end
Add only iOS supported pods in target '<your iOSApp Name>'
e.g.
target '<your iOSApp Name>' do
platform :ios, '8.0'
sharedPods
pod 'otherOnlyiOS supported Pod1'
pod 'otherOnlyiOS supported Pod2'
end
So, this way you can add required pods for required targets.
Related Topics
How to Enable Only Numeric Digit Keyboard iOS Swift
My Uiviews Muck-Up When I Combine Uipangesturerecognizer and Autolayout
iOS - Send Image to Instagram - Documentinteraction
Playing an Audio File Repeatedly with Avaudioengine
How to Access Index of Tabbar Item Using Swift
Swift: Bring View from Stack View to Front
What Is Correct Way to Notify View Controller from Appdelegate
Diffabledatasource: Snapshot Doesn't Reload Headers & Footers
Swiftui Transition from Modal Sheet to Regular View with Navigation Link
How to Programmatically Check and Open an Existing App in iOS 8
App Groups Forsecurityapplicationgroupidentifier Returns Nil
How to Draw Geojson in Apple Maps as Overlay Using Swift 3
How to Center a Label Horizontally for All iOS Devices in Swift