1. Realization of Shell Engineering
Create a new SFUIKitDemo as a shell project
1. Create a pod project
a. cd to the root directory of the created Demo, and then execute:
pod init
Then there will be one more podFile file in the root directory folder.
b. Generate xcworkspace project, execute:
pod install
c. Create a new Lib (named by yourself) folder to store the component library
Then cd to Lib and execute:
pod lib create SFUIKit
Among them, SFUUIKit is a project name you customize, that is, one of your components or business modules, and then generate a pod project template according to the prompt. As shown below:
Then, according to the prompt, the pod project template will be automatically generated.
Open the Example in the newly created SFUUIKit project, and you can see that there is a ReplaceMe file in the pods, which means to replace it with a class that we need to provide externally.
Copy and paste the project code we need to split into the same directory as ReplaceMe, and delete the ReplaceMe.m file
Then cd to the Lib/SFUUIKit/Example/ file directory and execute:
pod install
At this time, there will be two more files under the Development Pods file, which are the locally developed pods files.
So far, the local library of a component has been created.
2. Use the local component library
First, cd to the SFUUIKit directory of the shell project, modify the Podfile of SFUIKitDemo, and add
pod 'SFUICit', :path => 'Lib/SFUICit'
implement:
pod install
In this way, the shell project will pod the content of the local component library, and the principle is the same as using the usual third-party remote library. Only this time it's local. It's just that the local pods are placed in the Development Pods folder. The contents of this folder can actually be modified, and the modification will take effect immediately.
3. Associate git
The local pod dependency is completed, but this is not what we want in the end. If you want multiple people to develop, you still need to push the components to the remote end to achieve joint development. Take the following level gitee as an example:
1. Create a warehouse
After the creation is complete, then the root directory of the cd component:
first we need to edit the podspec file:
After the change, before uploading, it is best to check locally whether the podspec is legal:
pod lib lint --verbose
Note: If the error caused by the warning can be verified by the following method:
pod lib lint --verbose --allow-warnings
If passed validation appears, it means passed and can be submitted to the remote warehouse
Initialize git, execute:
git init
Then add the code, execute:
git add .
Then, submit the initialization project:
git commit -m "xxxx"
Next, we need to associate this project with the warehouse we just created on Gitee
git remote add origin https://gitee.com/aistarfish/SFUIKit.git
Then, submit the initialization project to the remote master:
git push origin master
At this point our code has been uploaded to the warehouse.
Components need to provide external dependencies. So we have to do one more step, which is to modify the podspec file. We can perform version control and upgrade according to different tags corresponding to different podspec files. implement:
git tag 1.0.0
git push --tags
Refresh gitee, you will see one more tag branch:
Next, we need to publish the component's spec file to the spec repository we created.
pod repo push SFPodSpec SFUIKit.podspec --verbose --allow-warnings
When the spec repository is successfully added, it indicates that the current component is created successfully.
Finally, we can use pod to introduce our components:
Finally, if the components need to be updated, we only need to type the corresponding tag and update the local spec file.
pod repo update