In the process of development projects will be used to the global macro definition, the development of the public components, for use within the project, as the business growing, more and more common components can be encapsulated, so is there a good way to unified management of these components, this is what I want to share with you today in the creation and use of the internal library. Okay, let’s jump right into today’s topic, how to create and manage internal libraries.

Create an internal library of common functional components

I will use a counterclockwise progress bar used in my own project as an example of how to create and use a component library with internal common functions. The specific operation steps are as follows:

usegiteeCreate a project andcloneTo the local

Go to the project root directory and createFrameworksFolder, go toFrameworksFolder, createPSPublibsFolder, and then inPSPublibsCreate them separately under the folderPSPublibs.podspec.LICENSE.src.assetsFolders. next, the purpose of these four folders will be introduced
  • PSPublibs.podspec

PSPublibs. Podspec is a Pod description file for the PSPublibs library that describes information about a specific version of the Pod library. It is stored in CocoaPods’ central Repo for users to find and use.

As the Pod library iterates, CocoaPods’ central Repo stores a podSpec file for each particular Pod version. Each PodSpec file contains the URL of the Pod’s Repo, the location of the source code, the supported system platform and its lowest system version, as well as the Pod’s name, version number, and description.

The configuration in pspublibs. podspec is as follows

Pod: : Spec. New do | s | s.n ame = 'PSPublibs. Podspec' s.v ersion = "1.0.0" s.s ummary = # 'project self-used common components in This description is used to generate tags and improve search results. # * Think: What does it do? Why did you write it? What is the focus? # * Try to keep it short, snappy and to the point. # * Write the description between the DESC delimiters below. # * Finally, don't worry about the indent, CocoaPods strips it! s.description = <<-DESC Contains the decomponents for Design System. DESC s.homepage = 'https://gitee.com/nbns/pspubliclib' s.license = 'MIT' s.author = 'MIT' s.source = { :path => '.' } S.iso. Deployment_target = '13.0' s.deployment_files = 'SRC /**/*' # s.resources = 'assets/**/*' endCopy the code
LICENSE

A LICENSE is a LICENSE file, and if it is an open source library, we have to select a LICENSE strictly so that other developers can use our library easily.

src

All source code files are stored under the SRC folder

assets

Store resource files such as images, XIbs, and storyboards

Drag the encapsulated internal component library tosrcFolders are classified into different folders based on the component names

usepod lib lintThe library checks whether the internal library configuration file is correct
  • It’s important to note that,CocoaPodsThere is a check for internal librariesBug, the following warning is displayed:
Missing primary key for `source` attribute
Copy the code

Since we are creating an internal library, we can ignore this warning as long as there are no other error messages.

At this point, the creation of the internal component library is complete. Now, how do you use the internal library in your project

Use the internal common function component library

Since it is an internal build library, we need to create projects at the same level as Frameworks

  • To create aXcodeProject to ensure that the project andFrameworksAt the same level, the file directories are as follows:

  • cdGo to the directory file and createpodFile, as follows:
Platform :'ios',13.0 target 'pspubliclib'do pod 'PSPublibs', :path => './Frameworks/PSPublibs', :inhibit_warnings => false endCopy the code
  • performpod installAfter the download is complete, open the project and check whether the local component library can be referenced. If it can be referenced, it is ok.

At this point, the creation and use of the internal library has been explained, if you have any questions, welcome to the comments to leave a message.