Recently, I was going about modularization of my company's iOS app, and we chose to use cocoapods to manage modules.
----- this is background -----
Yesterday, I tried to upload a module to our private spec repo, thus I executed the following command (in the podspec directory)
pod repo push [private repo name] --allow-warnings --sources='[private repo git address]' --verbose --use-libraries
However, when the cocoapods was downloading some private dependencies, I found some of the dependencies' version were not the latest, which result in the failure of xcodebuild step (Because we changed the name of some functions in the latest version).
The module's podspec file dependency part: (I didn't specify the version of dependencies, cause I want latest)
...
s.dependency 'HomeJump'
...
(The latest version of HomeJump in my private spec repo is 0.1.6, but every time I executed pod repo push xxx, the version of HomeJump it installed was 0.1.5)
PS:
When I execute pod spec lint xxx, the HomeJump version is 0.1.6, which is correct.
And I've already tried to run pod repo update, rm -rf /Library/Cache/Cocoapods, reinstall my private repo ...
Somebody has any ideas?
Well... finally I found out the reason.
Every time the pod repo push xxx command is executed, cocoapods will find the corresponding version for each dependency in a automatically created spec repo, which has different name with your private spec repo (the name form is kind of like 'git server name - group name - repo name'). This temporary spec repo is related to your private spec repo.
The solution is: delete the temporary spec repo and run pod repo push xxx again
list your cocoapods repo by running pod repo list
find the one which is not created manually by yourself which is also related to your private spec repo
run rm -rf [the repo directory name]
Related
I'm using gh-pages to serve as a helm chart repo. At one point, it was working fine. Now, it doesn't. I package the chart, upload it, and update and push the index.yaml file in the gh-pages branch. I can go to the gh-pages url (effectively, the repo url) and examine the index.yaml file...I see the updated version listed there. I can copy the file url from index.yaml and the tgz downloads successfully. Looking inside the tgz, it has the correct version in Chart.yaml. All seems well.
But, when I run helm repo update [repo], none of the recent versions will show up. helm repo search shows only older versions. I've verified that the repo url is correct...it's the same one that I'm able to pull the valid index.yaml file from. I've also tried just upgrading a release using one of the newer 'missing' versions and it complains that it can't find the chart.
What am I forgetting?
Ive been trying to add a Xcode project to a repository on GitHub and it worked however the pods are not within the project and says they are missing. What is the proper way to add a project with the pods to GitHub?
It depends on what your project needs are.
Benefits of checking in the Pods directory
After cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine. There is no need to run pod install, and no Internet connection is necessary.
The Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down.
The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.
Benefits of ignoring the Pods directory
The source control repo will be smaller and take up less space.
As long as the sources (e.g. GitHub) for all Pods are available, CocoaPods is generally able to recreate the same installation. (Technically there is no guarantee that running pod install will fetch and recreate identical artifacts when not using a commit SHA in the Podfile. This is especially true when using zip files in the Podfile.)
There won't be any conflicts to deal with when performing source control operations, such as merging branches with different Pod versions.
Source
I personally have the following in my .gitignore file:
# CocoaPods
#
Pods/
If you want to create you own cocoapods with storyboards, XIBs, resources and with other frameworks such as Alamofire, MBProgressHUD etc.
Easy steps to create Cocoapod from existing xcode project
Create a repository on your git account (Repo name, check README,
choose MIT under license).
Copy the url of your repository.Open terminal and run following command.
git clone copied your repository url
Now copy your Xcode project inside the cloned repository folder on
your Mac. Now run following commands
git add -u to add all files (if not added use: git add filepath/folder)
git commit -m "your custom message"
git push origin master
Create a new release to go to your git repository or run following commands
git tag 1.0.0
git push --tags
First, we need to make sure that you have CocoaPods installed and
ready to use in your Terminal. run the following command:
sudo gem install cocoapods --pre
Creating a Podspec
All Pods have a podspec file. A podspec, as its name suggests,
defines the specifications of the Pod! Now let’s make one, run
following command on terminal
touch PodName.podspec
After adding and modifying your .podspec file. Validate your .podspec
file by hitting following command on terminal
pod lib lint
Once you validate it successfully without errors run following
command to register you and build cocoapod respectively
pod trunk register
pod trunk push PodName.podspec
If all goes well, you will get this on terminal
🚀 PodName (1.0.0) successfully published
📅 February 5th, 02:32
🌎 https://cocoapods.org/pods/PodName
👍 Tell your friends!
Yeah!!!!! congrats you have got your pod link. Use wherever you want to use it.
Here is some useful links . You can follow the same.
https://www.appcoda.com/cocoapods-making-guide/
https://www.raywenderlich.com/5823-how-to-create-a-cocoapod-in-swift
So I'm using a library that's been abandoned but I've made quite a few changes within its files under Pods. If the pods are reinstalled, the library won't work. What's the best practice for this sort of thing?
I have forked the project over and updated it with my changes.
Instead of having the line:
pod "PodToIntall"
I have
pod "PodToInstall", git: => "the url to my fork", branch: => "master"
If I try to pod install I get the error
[!] Unable to find a specification for 'PodToInstall'
The project is dead so if I can't get the owner to merge my changes is there any way to pull it off my github?
Check that all steps are done from the following list:
Change the source files from your forked pod project.
Commit it & push to GitHub (if pod is hosted here).
Update the Podfile within your main project to use forked pod.
Run in terminal pod update PodToInstall.
Also CocoaPods and GitHub forks might be useful.
This is my first time forking a GitHub project, and I'm not too competent with CocoaPods either, so please bear with me.
Basically, I forked a project on GitHub using the following in my Podfile:
pod 'REActivityViewController', '~> 1.6.7', :git => 'https://github.com/<username>/REActivityViewController.git'
I then made some changes to the fork, and of course when I did a pod install to install another pod it reinstalled the original REActivityViewController and erased my changes.
I'm realizing I need to push my changes to my fork before another pod install, but how do I know it is the fork being installed, considering that this is a repo installed by CocoaPods? I looked in the REActivityViewController folder installed under the Pods folder and there aren't any git files.
Do I need to work on my fork outside of my project and then use CocoaPods to install the changes? That's too cumbersome of a workflow.
Or do I need to do something with submodules?
I will answer this question using an example. I have a fork of TTTAttributedLabel with some extra functionality I added here:
https://github.com/getaaron/TTTAttributedLabel
In order to use this in a Cocoapods project, I:
Push my changes to my fork
Configure my Podfile to get the changes & update
Once you've pushed your changes to your fork, get the SHA of your last commit. You can do this using git rev-parse origin/master | pbcopy or on the GitHub commits page for your project:
Then, you can specify the specific commit on your fork in your Podfile like this:
pod 'TTTAttributedLabel', :git => 'https://github.com/getaaron/TTTAttributedLabel.git', :commit => 'd358791c7f593d6ea7d6f8c2cac2cf8fae582bc1'
After that, pod update will update this particular commit from your fork. If you want, you can also make a podspec for your fork, but I find this approach simpler and I don't make changes frequently enough to justify a new workflow.
Do I need to work on my fork outside of my project and then use Cocoapods to install the changes? That's way to cumbersome of a workflow.
You can do it this way, but I usually:
Edit the code inside my project and make sure it works
Copy the changes over to my fork, by
exporting a patch, or
copying over the entire source code file
Commit & push to GitHub
Update the Podfile with the new SHA
Run pod update.
Or do I need to do something with submodules?
No, you don't need to.
Another option is to have your project reference the pod directly and not via github. This way you don't have to keep committing your fork or copying/pasting code just to test your changes. You can work with two different Xcode projects simultaneously and commit separately into their respective projects.
pod 'AFNetworking', :path => '~/Documents/AFNetworking'
CocoaPods Documentation:
http://guides.cocoapods.org/using/the-podfile.html#using-the-files-from-a-folder-local-to-the-machine
CocoaPods and GitHub fork
You have two variants to work with fork
[Podfile specific branch]
[Podspec specific branch]
The difference is in the first variant you must push changes into remote/origin branch, while the second variant allows you just commit changes in a local branch