Cocoapods - Framework Private Library

Let your own static framework support the use of Cocoapods to add

Main process

First, create a git repository
  • The main role of the warehouse:
    -- store the spec file;
    -- store static library files, ie Framework, or SDK;
    -- store resource files that are dependent on static libraries, such as bundle files;
Second, clone the git repository to the local
git clone https://xxx
  • Enter the folder where the warehouse is located;
  • Create a folder and store the framework. The name of this folder is the spec file.s.vendored_frameworksofThe folder where the static library is located, this folder name is also the folder name where the static library is located after pods are localized;
  • Create another folder to store the bundle file. The folder name iss.resource_bundleofFolder where Bundle is located
Third, the SDK, Bundle, spec file is pushed to the warehouse
git add .
git commit -m 'sdk&bundle&spec add'
git push

 // Add a tag, which is also the version available in the Podfile when pod install
 // tag is the same as s.version in the spec file
git tag '0.0.1'
git push --tags
  • Upgrade when subsequent SDK versions are updatedspec Documentarys.version, update the tag at the same time, and then push to the remote repository
  • ~/.cocoapods/repos/master/Specs In the middle, a folder will be created for the static library, and each tag in the folder will correspond to a folder, there is only one folder.Static library name .podspec.json file
Fourth, the local verification spec file
pod spec lint --allow-warnings
  • Failure will have an error message, retry after modifying the information
5. Push the spec file to the trunk repository.
  • If you don't have a trunk account, please register first.
pod trunk register [email protected] 'xxx' --description='xxx' --verbose 
// View registration information
pod trunk me
  • After registration is successful, push the spec to the trunk server
pod trunk push xxx.podspec --allow-warnings
  • After the push is successful, you can usepod search 'xxx' View the uploaded static library;
  • If the query fails, enter~/Library/Caches/CocoaPods, deletesearch_index.jsonRetry

No other problems here, static libraries can be imported using pods

Create a demo to verify that the SDK is available
  • Create a Podfile file in the project directory
  • Edit the Podfile file
use_frameworks!

platform :ios, '8.0'

 # Use 'version number' to specify the version of the SDK
 # Use '~> version number' to specify a later version including this version
target 'project name' do
         Pod 'just uploaded SDK name', '~> 0.0.1'

end

Spec file example
Pod::Spec.new do |s|

  S.name = "static library name"
  s.version      = "0.0.1"

     # , otherwise local verification error
  s.summary      = "xxx"
     # can not write
  s.description  = "xxx" 

  s.homepage     = "https://xxx.com/"
  s.license      = { :type => "MIT" }
  s.author       = { "ChingHan" => "[email protected]" }

  s.source       = { :git => "https://gitee.com/chinghan/xxx.git", :tag => s.version }
  s.platform     = :ios, '8.0'
  s.requires_arc = true

     #Dependent system library
  s.frameworks = [
                  'AVFoundation',
                  'Accelerate',
                  'Security',
                  'SystemConfiguration',
                  'CoreMedia',
                  'AudioToolbox',
                  'CoreTelephony',
                  'ImageIO',
                  'MobileCoreServices'
                 ]

  s.libraries = 'c++', 'z'

     #All Pod contains all static library files
  s.vendored_frameworks = [
                                                       'folder name/xxx.framework',
                                                       'folder name/frameworks/*'
                           ]
     # resource 
     # Officially recommended to use s.resource_bundle; two ways to read the resources in the bundle is different
  s.resources = [
                                   'folder name/xxx.bundle',
                                   'folder name/resources/*'
                 ]

     #Dependent Tripartite SDK
  s.dependency 'AFNetworking', '~> 3.0.0'

  # s.vendored_frameworks = [
     # ' folder name / xxx.framework',
     # 'Folder name/frameworks/xxx.framework',
     # 'Folder name/frameworks/xxx.framework',
     # 'Folder name/frameworks/xxx.framework',
  #                         ]
  # s.resources = [
     # ' folder name / xxx.bundle',
     # 'folder name/resources/xxx.bundle',
     # 'folder name/resources/xxx.bundle',
  #               ]

end

spec Detailed documentation:https://guides.cocoapods.org/syntax/podspec.html

Intelligent Recommendation

CocoaPods private library creation

CocoaPods private library creation Reference link Why use private libraries and private library indexes For individuals, code accumulation is possible. We are creating new projects, many of the basic ...

Cocoapods creates a private library

1. First, simply understand the mechanism of cocoapods cocoapods has a remote index library. The description information of the frame is placed under the index library: the name of the frame, the vers...

Build a CocoaPods private library

Build a CocoaPods private library based on git 1. Create and set up a private Spec Repo. 2. Create the project project files required by the Pod, and have an accessible project version control address...

cocoaPods: public library private library

First, establish a dependent library Dependency library is a library that stores third-party code, and cocoapods is essentially a convenient tool for third-party library maintenance and import. Depend...

Cocoapods public library with private library

2019 Unicorn Enterprise Heavy Recruitment Python Engineer Standard >>> #### Why use Cocoapods to manage third-party libraries? Traditional use of third party banks Using a third-party SDK, yo...

More Recommendation

CocoaPods private library configuration notes

Recap The company's project has been using CocoaPods to manage third-party packages, and it also wants to pull out the common modules in the project out of separate packages. So I studied it. Ready to...

Cocoapods for private library version control

cocoapodsBelieve in everyoneiOSDevelopers have been exposed and used. In our project, we are usingcocoapodsTo manage public libraries such as some common components, tools, and so on. I also practiced...

Cocoapods configuration private library notes

ready Create a private library on github or other third-party server: eg heiyuTEST Start Clone to local Add the necessary README.md, LICENSE, .podspecs files and the code and resource files you want t...

Creation and use of cocoaPods private library

First, create a private pods Create a private Spec Repo (that is, a repository of all private pods) spec repo YespodsAn index of all publicpods ofpodspecA repository of files is actually a Git reposit...

Cocoapods Create Private Library Guide

Foreword CocoapodsIt is a dependency management tool that can be used to easily manage and update third-party libraries used in projects. It can also manage its own private libraries to make the proje...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top