Problem: We made our own POD library, all of our files are in one directory, the default is under classes file. So it’s not easy to find files, for example, if we write a component, there must be a ViewController,View,Model folder, and if we don’t categorize it, all the files will be in one place, and it will be a mess. Difficult to maintain.

Solution: We use Subspec to divide folders into sub-libraries, and one file into one sub-library “Can be added to the project by pod. If we have many sublibraries by subspec, then when we pod a required library, we will add all the sublibraries. If we don’t need all of them, we can pod the sublibraries, which increases flexibility.

1.Example _ Here’s what AFNetworking looks like

2. Let’s just make one thing. Here I’m just going to use the pod library I built earlier, if you don’t know, check out my last post.

2.1 First create the file in the local project

2.2 After the pod install file is built, you can view the file path in the debugging Demo.

3. Write subspec files

Source_files physical path,dependency hierarchical path (see above)

source_files

"TJYNetWork/*" matches all files in the TJYNetWork directory. Does not contain subdirectories "TJYNetWork/NetWork/NSURLSession / *. {h, m}" means to match NSURLSession all. H and. M at the end of the file "TJYNetWork / * * / *" means to match all the files (home directories and subdirectories, Where ** is equivalent to omitting the middle level)Copy the code

Tip:

1. Ask if the inside of the folders in A folder reference to B class, remember to rely on, if A folder reference to B class in folder, folder B to lead the class in A folder, A common built. H file (public files can be placed in the sepc, path above), introduce the two classes. Otherwise, mutual references will be caused and the remote index library will fail to verify the push.

4. Perform

     pod repo push TJYNetWork TJYNetWork.podspec –allow-warnings

5. Next we can

pod ‘TJYNetWork’

Pod submodules are also possible

pod ‘TJYNetWork/NSURLSession’

Finally, in the project pod ‘TJYNetWork’, you will see something like this:

(If an error is reported, check the following validation parameters, which may solve the problem)

Podspec validates the effects of the parameters:

Options:

–allow-warnings: Ignore warnings –use-libraries: use the static library installation specification, which needs to be added if third-party or custom static libraries are included –use-modular headers: If is the OC and swift need plus – mixed sources=https://cdn.cocoapods.org/: library specified index of the source, multiple source must be separated by commas, local – only: Do not perform steps to push the buyback to its remote server –no-private: includes checks only for public buybacks –skip-import-validation: skips to verify that the POD can be imported –skip-tests: Skip building and running tests during validation –commit-message=”Fix bug in pod”: Add custom commit messages. If no submit message is specified, open the default editor — use-JSON: converts podSpec to JSON before pushing it to repo –swift-version= Version: SWIFT_VERSION, which should be used when marking the specification. This takes precedence over the VERSION or Swift specified in the specification. Swift version file –no-overwrite: Do not allow pushes that will overwrite existing specifications

1. An error was reported during the process, and the specific problem was not clear.

Resolve to use

Pod lib Lint XXXXX –allow-warnings –verbose –skip-import-validation

Pod repo push TJYNetWork tjynetwork. podspec –allow-warnings –verbose –skip-import-validation