In the previous # Framework Project Guide (Swift) article, I chose to build the framework locally by building a POD library by referring to componentization scenarios, but didn’t write down the PodSpec configuration process in case I forgot, so I wrote the quick configuration separately.
A full PodSpec file contains a lot of content. You don’t need to know how to use each one. It takes a lot of time.
1. Create podspec
Console input $: pod Spec Create (POD name) successful - console output $: Specification created at xxx.podspecCopy the code
2. Read information quickly
Create success, to open the file and find the Pod: : Spec. New do | Spec |
There are a lot of different modules down here
Used to set the pod information - Spec Metadata -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the Spec. Name = "XXX (name)" Spec. Version = "0.0.1" (version number) spec. Summary = "A short description of XXX." (description)Copy the code
Set the support Platform for the lowest version (according to the support Platform to set up the line) - Platform Specifics -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Spec.ios. Deployment_target = "9.0" spec.osx.deployment_target = "12.0"Copy the code
Add rely on - the Project Settings -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --, the spec. The dependency "MBProgressHUD" spec.dependency "Alamofire" spec.dependency "SnapKit" spec.vendored_frameworks = "xxx.framework"Copy the code
Local items - Loction Settings -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --, spec. Vendored_frameworks = "Xxx. framework" (add local frameworks library) spec.resources = ".bundle" (add local resources)Copy the code
3. Pay attention to item
Description = << -desc # TODO: Add long description of the pod hereCopy the code
Switch type # spec.license = "MIT (example)" spec.license = {:type => "MIT", :file => "FILE_LICENSE"}Copy the code
Replace global EXAMPLE with github.com or some other domain nameCopy the code
4. Create a named folder XXX and place podSpec and framework in it
5. In the XXX project root directory, configure Podfile and run $pod Install
Pod '(library name)', :path => './(folder name, e.g. XXX)'Copy the code
6. Update failed: You need to handle ERROR
mac$ pod install Analyzing dependencies [!] The `xxx` pod failed to validate due to 2 errors: - ERROR | license: Sample license type. - WARN | github_sources: Github repositories should use an `https` link. - ERROR | description: The description is empty.Copy the code
7. Success
Installing xxx (0.0.1)
Pod installation complete!
Copy the code