1. Local warehouse production
Components: Base components, functional components, and business components can all be made into POD references.
1.1. Creating files
Terminal input: pod lib create name, name is the name of its own component.
1.2. Add components and libraries to reference
Find the DeveLopment Pods folder and put the files you made with your components under it. In this case, we can use Example to test whether the component is usable. If the component does not depend on a third party, do not add it.
RegexKitLite is only tested in this Example.
The path of pod YaoChuFaKit is the path of the component.
1.3. Components are used in projects
Find your project’s Podfile file, path is a relative path, and see where you put it. If the component depends on a third-party library, use the library that pod depends on. If not, don’t use it. Run.
pod 'YaoChuFaKit', :path => '.. /LGLib/YaoChuFaKit' pod 'RegexKitLite'Copy the code
2. Remote warehouse production
2.1. Modify the. Podspec file
- S. passion: Indicates the version number corresponding to the tag
- S. Summary: It’s a short description
- S. description: description
- S.hemepage: Home page path
- S.ource: enter the git directory, which is used by the remote repository
- S.ource_files: directory of resource files
- S. dependency: dependent third-party library
2.2. Remote repository creation
To create a remote private repository, such as the code cloud, create the repository directly. Copy path.
Local terminal operations:
- Terminal: Git Add.
- Git commit -m ‘description’
- Git remote add Origin [gitee.com.\
- Terminal: Git push Origin master, push code to remote warehouse
- Terminal: Git tag 0.1.0, add the local tag, this tag should be the same as s. passion.
- Terminal: Git push –tags, push all local tags to the remote repository.
2.3. Add remote private Specs
Any private components that we used to use can be put on our specs.
This Specs is also a remote warehouse. Just create it as in 2.2, and you can name it whatever you want, for example XXSpecs.
Terminal: Pod repo add XXSpecs gitee.com/xxx/XXSpecs… Repo add [warehouse name][warehouse path] to add XXSpecs to the local repo.
At this point we will find the XXSpecs file locally.
Terminal: pod lib Lint –allow-warnings –use-libraries. To verify that the. Specs file is ok, we remove the warning here and display an error if there is a problem. This is where the error statement comes in.
The occurrence of this error, mainly see the error description, normal is no problem, see the submitted version, and the tag version is consistent.
Terminal: Pod Repo push XXSpecs Local repo name. Podspec –verbose –allow-warnings. Again, remove the warning. If you don’t remove the warning, you might get an error.
Once done, you can go to the remote XXSpecs and see if the components are used on that repository. Then we can directly use the POD component library on our own projects.
3. CTMediator
There are a variety of componentization schemes to operate, such as URL redirect scheme, target-action scheme, service registration, notification broadcast and so on. It is not said which is better, depending on the actual needs of the business. Here is an example of target-action analysis, using CTMediator.
Github download: github.com/casatwy/CTM… , download the source code directly simple analysis.
The Categories folder contains the Categories of CTMediator, which in practice is also a separate REPo, responsible by Actions. CTMediator+CTMediatorModuleAActions is equivalent to providing only the external exposure interface.
The classification here calls the core methods of the core CTMediator file, which in this case serves as an intermediary.
After entering method, the target will be joining together for Target_A, actionString stitching for Action_nativeFetchDetailViewController.
Ran down to go to the system performSelector: withObject: method. It becomes
[Target_A performSelector: Action_nativeFetchDetailViewController withObject: params]
Copy the code
At this point, we need a Module to handle the method, which is also a Repo that holds the business layer information, Target_A Action_nativeFetchDetailViewController method of this class will be returned to us detailed DemoModuleDtailViewController controller. At this point, the entire route is completed.
Can clearly, such are the benefits of viewcontrollers and DemoModuleADetailViewController is not directly linked, their routing through the middleware CTMediator to coordinate, the coupling decreased.
The basic flowchart is as above, whose business, who is responsible for the CTMediator_category, to provide external methods can be.