I have an iOS project with a lot of pods, around twenty. I want to integrate a watchOS 2 app in, but CocoaPods requires that the podspec contain support for watchOS (as seen here: http://blog.cocoapods.org/CocoaPods-0.38/)
At first, I thought I could fork all of the pods that aren't updated, point my podfile to those forked repos, and bob's your uncle. The problem is that some of the pods that I'm using are closed/not-public. Is there a way for me to not build the main application's pods for the watchOS target? Like using target isolation like so?:
target "Watch" do
end
I can't seem to get that ^ potential solution to build, as it still tries to build the pods. I've also tried this repo, no luck: https://github.com/orta/cocoapods-expert-difficulty
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.
I've found my problem! I was using Swift for my Watch code, but my parent app is in Obj-c. Thought it wouldn't be a problem except the watch target attempts to compile the Swift bridging header that I use in my main app, which is what was leading to those pods building unnecessarily. So, the solution is either specify a different bridging header for your Watch target or using Obj-c!
Related
I am getting this error in the screenshot after trying to pod install firebase
My xcode version is 8.2
this is the content of my podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '8.0'
target 'Forsa' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Forsa
pod 'Firebase/Core'
pod 'Firebase/Messaging'
end
You need to open the file that cocoapods created: PROJECTNAME.xcworkspace (instead of the PROJECTNAME.xcodeproj file) to get access to the installed frameworks.
Or like they say in their documentation:
Make sure to always open the Xcode workspace instead of the project
file when building your project:
$ open App.xcworkspace
Here's my podfile:
source 'https://github.com/CocoaPods/Specs.git'
# Uncomment the next line to define a global platform for your project
target 'raceQs' do
platform :ios, '11.1'
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for raceQs
pod 'AppCenter'
pod 'Alamofire'
end
target 'raceQs WatchKit Extension' do
platform :watchos, '4.1'
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for raceQs WatchKit Extension
pod 'Alamofire'
end
I'm opening my project's xcworkspace and getting a compile error:
Developer/Xcode/DerivedData/raceQs-cwycjawfwoosfubowtoymeizvfln/Build/Products/Debug-iphoneos/raceQs.app/Frameworks/Alamofire.framework'
/Users/mac/Library/Developer/Xcode/DerivedData/raceQs-cwycjawfwoosfubowtoymeizvfln/Build/Products/Debug-iphoneos/raceQs.app/Frameworks/Alamofire.framework: bundle format unrecognized, invalid, or unsuitable
In my Xcode project Navigator, the Frameworks/ Pods_raceQs_WatchKit_Extension is displayed in red.
Any assistance would be greatly appreciated.
I am trying to using Cocoapods 0.39.0 for the dependencies of my project. I have followed the steps, but I end up with a red Pods.framework in my project. If I look at the path where XCode 7.2.1 says it should be, it doesn't exist:
/Users/ajmas/Library/Developer/Xcode/DerivedData/myproject-cskuurnzjrcpcxfoyaceaeepshgt/Build/Products/Debug/Pods.framework
I have looked around at other entries in Stackoverflow, but I am not find anything indicating how the framework should be generated.
The contents of my Podfile are:
source 'https://github.com/CocoaPods/Specs.git'
target 'myproject' do
platform :osx, '10.11'
use_frameworks!
pod 'Alamofire', '~> 3.0'
end
Any ideas?
Edit, also tried with Cocoapods 1.0.0.beta and no change, even after updating the Podfile to confirm to 'target' being a requirement now.
Build your project with "Generic iOS Device" selected.
If this happens it's most likely because you are using <your_project>.xcproject. When you run pod install CocoaPods creates a <your_project.xcworkspace file that you need to use to have dependencies installed via CocoaPods be available when compiling.
I am using realm.io as storage for some data. I want to share this data with my Today extension. I am using CocoaPods and I am wondering how I can share that Framework with both targets. My podfile looks like this:
platform :ios, '8.0'
use_frameworks!
pod 'RealmSwift'
pod 'MBProgressHUD'
pod 'Alamofire'
I tried with this and it worked when building to device, but not when building to the iOS simulator. It returned the error 'ld: framework not found Pods':
platform :ios, '8.0'
use_frameworks!
def shared_pods
pod 'RealmSwift'
pod 'Alamofire'
end
target 'App' do
shared_pods
pod 'MBProgressHUD'
end
target 'AppToday' do
shared_pods
end
What am I doing wrong?
Appreciate any help.
Brgds
Your Podfile looks correct and would work on a clean installation. But you found a bug in the user project integration in CocoaPods when migrating between different setups.
Background info
If you don't explicitly specify a target in the Podfile, then CocoaPods will integrate with the first target in your project. This was your app target, which worked correct as long as it was the only one.
But now you're referencing explicitly to the targets. CocoaPods will create separate so called aggregate targets. Those are in the Pods.xcodeproj and named Pods-App and Pods-AppToday. These are static framework targets (from 0.39.beta.5), which are weak linked to your targets to help Xcode finding your dependencies in the Pods project. Because CocoaPods doesn't know anything about the previous Podfile when you run pod install (and it doesn't retain this information in the Podfile.lock), it doesn't remove the old aggregate target, which was named just Pods and it's product reference in your app target.
Resolving the issue
Select your project file in Xcode in the file navigator
Select your app target in the left pane from the targets list
Go to the General tab
Remove Pods.framework from the Linked Frameworks and Libraries pane
Expected state before
How it should look like
platform :ios, '8.0'
use_frameworks!
pod 'RealmSwift'
pod 'MBProgressHUD'
pod 'Alamofire'
Add this line
link_with 'App', 'AppToday'
I got a project where I use some Pods, where one of them is Meteor.
I have installed with cocoapods with this podfile
platform :ios, '8.0'
use_frameworks!
pod 'OpenTok', '~> 2.6'
pod 'Meteor', '~> 0.1'
And then open up the .xcworkspace instead of .xcodeproj
Then in my project I import Meteor in my AppDelegate.
When I choose a simulator and try to run/build it comes with the error "No such module 'Meteor'"
But then if I take my iPad and connect it and choose it as target, I can fine run/build.
I have not be able to find a solution for this yet.
I had the same symptom after following these instructions to speed up my build:
Prevent Xcode from building subprojects every time
I was able to run on a simulator again after reverting.
Product > Scheme > Edit Schemeā¦
Build (in left column)
Make sure that "Find Implicit Dependencies" is Checked