I'm trying to wrap my head around this complex setting:
I have two projects and a shared library. The shared library is a cocoapod.
I would like to be able to use a single workspace to develop in. There are some duplicated pod definitions, but I have this working in a single Podfile.
Here's where it gets complicated:
I want each project/library in its own git repo. Each repo must be able to live on its own; have its own Podfile, be tested/deployed via CI, etc.
Another wrench: we are the git-flow branching strategy... The master branch of project A/B must pull the master branch of the library. The develop branch of project A/B must pull the develop branch of the library.
Has anyone figured this out? Am I going about this in an ass-backwards way?
Here is a working root workspace Podfile:
platform :ios, "7.0"
inhibit_all_warnings!
workspace 'Root.xcworkspace'
xcodeproj 'SharedLibrary/SharedLibrary.xcodeproj'
xcodeproj 'ProjectA/ProjectA.xcodeproj'
xcodeproj 'ProjectB/ProjectB.xcodeproj'
target 'SharedLibrary' do
xcodeproj 'SharedLibrary/SharedLibrary.xcodeproj'
pod 'AFNetworking', '~> 2.0'
pod 'CocoaLumberjack'
end
target 'ProjectA' do
xcodeproj 'ProjectA/ProjectA.xcodeproj'
pod 'AFNetworking', '~> 2.0'
pod 'CocoaLumberjack'
pod 'MagicalRecord', '~> 2.2'
pod 'SharedLibrary', :path => './SharedLibrary/'
end
target 'ProjectB' do
xcodeproj 'ProjectB/ProjectB.xcodeproj'
pod 'AFNetworking', '~> 2.0'
pod 'CocoaLumberjack'
pod 'MagicalRecord', '~> 2.2'
pod 'SharedLibrary', :path => './SharedLibrary/'
end
Here is the shared library's podspec:
Pod::Spec.new do |s|
s.name = "SharedLibrary"
s.version = "0.0.1"
s.platform = :ios, "7.0"
s.source = { :git => "http://not.really.uploaded.anywhere.yet/SharedLibrary.git", :tag => "0.0.1" }
s.source_files = "SharedLibrary", "SharedLibrary/**/*.{h,m}"
s.public_header_files = "SharedLibrary/**/*.h"
s.dependency 'AFNetworking', '~> 2.0'
s.dependency 'CocoaLumberjack'
end
What I did was to define an "exclusive" target for the CocoaPod library. An exclusive target will not link with the rest of the Podfile pods. Basically what you're going to have to do is define your target that points to the Xcode project. Then you need to add the CocoaPod as a dependency using the podspec. Because it's an exclusive target, it won't link with itself. For example,
source 'https://github.com/CocoaPods/Specs.git'
target 'SharedLibrary', :exclusive => true do
xcodeproj 'SharedLibrary/SharedLibrary.xcodeproj'
end
pod 'SharedLibrary', :path => 'SharedLibrary/'
does what you would need it to. The only caveat is that every time you add a public header to the library, you need to run pod update to use it in your project.
Podfile Syntax on Targets
Related
I'm trying to build application from xcode.
I cloned the project from git repo.
I opened .xcodeproj file and from Product > Build I tried to build but build is failed.
From terminal I executed below commands and receiving compatible version error
I searched for solution and tried few ways like:
sudo gem intall cocoapods
sudo gem intall cocoapods --pre
pod setup
pod deintegrate
pod install
pod update
pod install --repo-update
Below is terminal output:
Analyzing dependencies
Pre-downloading: `BarcodeScanner` from `https://github.com/htothee/BarcodeScanner.git`
Pre-downloading: `MatrixKit` from `https://github.com/N-Pex/matrix-ios-kit.git`, branch `fix_apns_push`
Pre-downloading: `MatrixSDK` from `https://github.com/matrix-org/matrix-ios-sdk.git`, branch `develop`
Pre-downloading: `QRCode` from `https://github.com/brackendev/QRCode.git`
[!] CocoaPods could not find compatible versions for pod "MatrixSDK":
In Podfile:
MatrixKit (from `https://github.com/N-Pex/matrix-ios-kit.git`, branch `fix_apns_push`) was resolved to 0.10.1, which depends on
MatrixSDK (= 0.13.0)
MatrixSDK (from `https://github.com/matrix-org/matrix-ios-sdk.git`, branch `develop`)
Below is Podfile
platform :ios, '9.3'
use_frameworks!
def shared_pods
pod 'ProjectCore', :path => '../'
pod 'MatrixKit', :git => 'https://github.com/N-Pex/matrix-ios-kit.git', :branch => 'fix_apns_push'
pod 'MatrixSDK', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop'
end
target 'Project_Example' do
shared_pods
pod 'BarcodeScanner', :git => 'https://github.com/htothee/BarcodeScanner.git'
pod 'QRCode', :git => 'https://github.com/brackendev/QRCode.git'
pod 'Project', :path => '../'
target 'Project_Tests' do
inherit! :search_paths
end
end
target 'ShareExtension' do
shared_pods
pod 'ProjectExtension', :path => '../'
end
Expected:
.ipa file need to be created
Please let me know how can I solve it.
same problem for me
CocoaPods could not find compatible versions for pod "Branch"
remove Podfile.lock and Pods then do pod install
rm -rf ./Pods Podfile.lock
pod install --repo-update
try this, this worked for me. Thanks.
Your problem is explained in the error:
[!] CocoaPods could not find compatible versions for pod "MatrixSDK":
In Podfile:
MatrixKit (from https://github.com/N-Pex/matrix-ios-kit.git, branch fix_apns_push) was resolved to 0.10.1, which depends on
MatrixSDK (= 0.13.0)
The branch fix_apns_push of MatrixKit needs a fixed version of MatrixSDK, as you can see in its Podspec file
pod 'MatrixSDK', '0.13.0'
So, In order for your project to work, you need this version.
Try this:
def shared_pods
pod 'ProjectCore', :path => '../'
pod 'MatrixKit', :git => 'https://github.com/N-Pex/matrix-ios-kit.git', :branch => 'fix_apns_push'
pod 'MatrixSDK', '0.13.0'
end
insted of projectname.xcodeproj, please try to open projectname.xcworkspace.
I'm trying add add a pod by cocoapods, and I am using swift 3, while the pod(SQlite.swift).
I am trying to use doesn't have a master of the latest swift version, however there is a branch for swift 3.
So how should I set my podfile to download the specific branch? Is it possible?
Here is my podfile:
platform :ios, '10.0'
target 'RedShirt' do
use_frameworks!
# Pods for RedShirt
pod 'SQLite.swift', :git => 'https://github.com/stephencelis/SQLite.swift.git'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
The podfile guide mentions the following syntax:
To use a different branch of the repo:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev'
^^^
(the space is important)
So in your case, that would be:
pod 'SQLite.swift', :git => 'https://github.com/stephencelis/SQLite.swift.git', :branch => 'swift3-mariotaku'
If you just want to use the main branch (master), write the following command:
pod "SAConfettiView", :git => 'https://github.com/oskarko/SAConfettiView.git'
But if you want to use an alternative/different branch, this one is for you:
pod "SAConfettiView", :git => 'https://github.com/oskarko/SAConfettiView.git', :branch => 'develop'
Easy peasy! 😊
Cocoapods with specific branch
[Cocoapods]
Use :branch in Podfile
pod "SQLite.swift", :git => 'https://github.com/stephencelis/SQLite.swift.git', :branch => 'dev'
//additionally you can use :tag, :commit
Please note, that branch must contain .podspec in root directory
When you specify :branch, Cocoapods will try to find .podspec directly there instead of searching in centralized repository
[Local CocoaPods]
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 have a project on Bitbucket that builds fine on one machine. I cloned it on another machine, did a pod install, everything installed fine. I open the .xcworkspace and it won't build because of the error in the title of this post.
When the project is deleted from the original machine and cloned there (pods installed, etc.) it builds fine.
I don't don't know what's different about the other machine or what information I can provide here to ask this question.
Here's the contents of my podfile:
# Uncomment this line to define a global platform for your project
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "7.0"
link_with 'Extender', 'DefinitiveExtender'
pod 'zipzap', '~> 7.0'
pod 'SQKPieProgressView', '~> 1.0'
pod 'AFNetworking', '~> 2.3'
pod 'MBProgressHUD', '~> 0.9'
pod 'Reachability', '~> 3.1'
pod 'HockeySDK', '~> 3.5.7'
pod 'Parse', '~> 1.4'
I ran into the same issue. In my case what was happening was that for some reason libPods wasn't being linked.
Click on the project, go to General, click on your target and then scroll down to Linked Frameworks and Libraries. There I made sure to include libPods.a and then the project built fine. Hope that helps.
I am trying to use latest beta tag of MagicalRecord located here:
https://github.com/magicalpanda/MagicalRecord/releases/tag/v2.3.0-beta.5
I am using it in a sdk project that I use in another project. My sdk project will never be a true cocoapod in the repo, but I wrote a podspec to define the transitive deps.
However I am not sure how to list the beta dep of magical record. If I was pointing to the 2.2. version which is published:
s.dependency 'MagicalRecord', '~> 2.2'
But I really want something like this:
s.dependency 'MagicalRecord', '~> https://github.com/magicalpanda/MagicalRecord/releases/tag/v2.3.0-beta.5'
I don't want to have to declare MagicalRecord as a dep in both my sdk project and my main project. I would like the main project to list the local sdk as a dep, and have the sdk deps pulled as well. Works great if everything you use is published. What about things that are not published?
Cocoapoads support using git endpoints. Per the documentation (http://guides.cocoapods.org/using/the-podfile.html):
To use the master branch of the repo:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git'
To use a different branch of the repo:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :branch => 'dev'
To use a tag of the repo:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
Or specify a commit:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af'
I'd recommend using the commit number, as it will provide you with a versioning mechanism.