I've been working on some iOS projects recently and stumbled upon the idea of creating my own CocoaPods. It seems complicated, but it's actually quite simple. Here's a guide:
Assuming you have already:
- Installed Xcode
- Installed Cocoapods
Step 1: Create an empty git.
I won't go into detail about that. After creating it, clone it locally, then navigate to the directory and run it:
git add README.md git commit -m "first commit" git remote add origin https://github.com/xxx/xxx.git git push -u origin master
Step 2: Create the pod
Then run it in that directory:
pod lib create xxx
Some questions will arise afterward; just answer them truthfully.
Step 3: Modify the .podspecs file
After completing the previous step, Xcode and the created project will open automatically. In the project, there's a `.podspecs` file. Modify the parameters inside, especially the Git address. Then run:
pod lib lint
There's a high chance of an error; just modify the corresponding file based on the error.
Step 4: Add your lib file
In your pod directory, you'll find a file named `replaceMe`. Place your `lib` directory in that directory. Remember to delete `replaceMe` afterwards.
Step 5: Upload tags
git add . git commit -m'Initial Commit' git remote add origin https://github.com/xxx/xxx.git git tag 0.1.0 git push origin 0.1.0
After completing this, run the following:
pod repo add XXX https://github.com/xxx/xxx.git pod repo push XXX #Your naming convention
Step 6: Use
The above five steps basically complete the entire release process. Now you can directly test and use it:
source 'https://github.com/xxx/xxx.git' pod 'XXXX' #Previously defined name
This websiteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)Please retain the following annotations when sharing or adapting:
Original author:Jake Tao,source:How to create your own Cocoapods and publish it to GitHub (Swift)