Knowledge points involved in this article:

  • Briefly describe the creation & use of static libraries
  • The paperCocoaPods

Static library creation & use

  1. You can also create.frameworkStatic library at the end
  2. As with dynamic libraries, modify after a new project is createdMach-O TypeforStatic Libiary
  • Modify the generated path inCopy filesAs can be seen inSubpath, delete the previous path
  • Add your own file, for subsequent import convenience, deleteStaticFramework.mIn theStaticFramework.hTo import other header files.

  • inCopy filesFor external use

  • Compile,ProductsFound in the.aStatic library at the end,Show in Finder, copy all these files, as shown in the picture:

  • Create a new project, just drag these files in and use them

For the time being, simulators are used to operate, and different versions of the library refer to the dynamic library written before

  • How to view aframeworkIs it a dynamic or static library?

Using the file command

CocoaPods

CocoaPods is package management software in Xcode projects

Why use itCocoaPods

To save development time, we usually import some third-party libraries into the project. In the process of practice, many problems will be encountered.

  1. Subsequent iterations of third-party libraries
  2. This configuration is required for static library importXcodeParameters.
  3. Static libraries depend on system dynamic libraries and need to be imported manually
  4. Import comparison reference: Baidu map SDK

CocoaPodsThe core concept

  1. PodfileFile to write out what needs to be installedPodlibrary
  2. SpecsWarehouse, hosted atGithubOn. To query for a specificpodLibrary details.
  3. podspecDescription file, used to describe apodWarehouse information, including code address, author, version number and other information

CocoaPodsHow are iOS project dependencies managed?

What has Pod Install done since then?

  1. rightPodfileFile parsing
  2. Install dependencies
  • Resolve dependencies in podfiles
  • Download dependence (most rely on will be downloaded to the ~ / Library/Caches/CocoaPods/Pods/Release/this folder, and then copied to the project from the project directory. / the Pods, it also completes the whole CocoaPods download process.)
  • createPods.xcodeprojengineering
  • generateworkspace

useCocoaPodsThe benefits of?

  1. Avoid the original way of importing files directly to facilitate subsequent code upgrades
  2. Simplify and automate the integration process to avoid unnecessary configuration
  3. Automatically handles dependencies between libraries
  4. Simplify the code release process for developers

aboutuse_frameworks!

We use use_frameworks in our Podfile! After that, libraries under the Pods project will be introduced as dynamic libraries, and vice versa.

In Swift projects, use_frameworks must be used! Otherwise, an error is reported that the library file cannot be found