Knowledge points involved in this article:
- Briefly describe the creation & use of static libraries
- The paper
CocoaPods
Static library creation & use
- You can also create
.framework
Static library at the end- As with dynamic libraries, modify after a new project is created
Mach-O Type
forStatic Libiary
- Modify the generated path in
Copy files
As can be seen inSubpath
, delete the previous path - Add your own file, for subsequent import convenience, delete
StaticFramework.m
In theStaticFramework.h
To import other header files.
- in
Copy files
For external use
- Compile,
Products
Found in the.a
Static 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 a
framework
Is 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.
- Subsequent iterations of third-party libraries
- This configuration is required for static library import
Xcode
Parameters.- Static libraries depend on system dynamic libraries and need to be imported manually
- Import comparison reference: Baidu map SDK
CocoaPods
The core concept
Podfile
File to write out what needs to be installedPod
librarySpecs
Warehouse, hosted atGithub
On. To query for a specificpod
Library details.podspec
Description file, used to describe apod
Warehouse information, including code address, author, version number and other information
CocoaPods
How are iOS project dependencies managed?
What has Pod Install done since then?
- right
Podfile
File parsing - 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.)
- create
Pods.xcodeproj
engineering- generate
workspace
useCocoaPods
The benefits of?
- Avoid the original way of importing files directly to facilitate subsequent code upgrades
- Simplify and automate the integration process to avoid unnecessary configuration
- Automatically handles dependencies between libraries
- 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