CocoaPods - podspec private library configuration

Project Reference

Add the following cocoaPods instructions to the Podfile and enter pod install in the terminal to build

source 'https://github.com/zhengmiaokai/Specs.git'

under 'JPUtils', '1.0.2'

Local storage spec directory

~/.cocoapods/rest/

pod install --repo-update (update local repo and pod install)

pod install --no-repo-update (pod install, non-updated repo)

pod repo update (updates all repo by default)

pod repo update  ~/.cocoapods/repos/master (update specification Specs)

pod search  lottie-ios (query related Specs information of lottie-ios)

git warehouse creation

1) Project git directory

2) spec directory (automatically generated through pod repo)

podspec file configuration

name : private library package name

s.name = 'JPUtils'

version : current version number

s.version = '1.0.1'

platform : minimum supported system

s.platform = :ios, '8.0'

source : git address, version number

s.source = { :git => 'git地址', :tag => '1.0.1' }  
#等价于:s.source = { 'git' => 'git地址', 'tag' => '1.0.1' }

requires_arc : whether it is arc

s.requires_arc = true

source_files : code source file path

s.source_files = 'JPUtils/utils/required/*.{h.m}', 'JPUtils/utils/optional/*.{h.m}'  

s.source_files = 'JPUtils/utils/**/*.{h.m}'

 public_header_files : public header file path (default value: header file configured by source_files)

s.public_header_files = 'JPUtils/public/header/*.h'  

libraries : system libs

s.libraries = 'sqlite3', 'stdc++'  
#等价于:s.libraries = ['sqlite3', 'stdc++']

vendored_libraries : built-in libs path

s.vendored_libraries = 'JPUtils/utils/required/tool.a', 'JPUtils/utils/optional/common.a'   

s.vendored_libraries = 'JPUtils/utils/**/*.a'  

resources : resource file address

s.resources = 'JPUtils/utils/resource.bundle'

s.resources = 'JPUtils/utils/*.bundle'

frameworks : system frameworks

s.frameworks = ['UIKit', 'Foundation']

vendored_frameworks : built-in frameworks path

s.vendored_frameworks = 'JPUtils/utils/required/tool.framework', 'JPUtils/utils/optional/common.framework'

s.vendored_frameworks = 'JPUtils/utils/**/*.framework' 

dependency : associated with third-party libraries and component libraries, s.dependency 'MKNetwork' , '~> 1.0.2' ( the version number is declared in the Podfile to avoid inconsistencies in multiple podspecs )

s.dependency  'AFNetworking'   
s.dependency  'MKNetwork'

 valid_archs : Processors supported by the current private library

valid_archs = ['x86_64', 'arm64e', 'arm64', 'armv7s', 'armv7']

# arm64e:iPHone XS,iPHone XR,iPhone 11, ...
# arm64:iPhone5s,iPhone6、7、8,iPhone6、7、8 Plus,iPhone X,...
# armv7s:iPhone5, iPhone5C,iPad4,...
# armv7:iPhone 3GS,iPhone4,iPhone 4s,iPad,iPad2,iPad3,...

pod_target_xcconfig : Build Settings configuration of the current private library

s.pod_target_xcconfig = { :OTHER_LDFLAGS => '-lObjC', 
  :CLANG_CXX_LANGUAGE_STANDARD => 'c++11', 
  :CLANG_CXX_LIBRARY => 'libc++', 
  :VALID_ARCHS => 'x86_64 arm64e arm64 armv7s armv7' }

# :OTHER_LDFLAGS等价于'OTHER_LDFLAGS'
# :VALID_ARCHS等价于'VALID_ARCHS'

user_target_xcconfig : Build Settings configuration of pod library

s.user_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC', 
  'CLANG_CXX_LANGUAGE_STANDARD' => 'c++11', 
  'CLANG_CXX_LIBRARY' => 'libc++', 
  'VALID_ARCHS' => 'x86_64 arm64e arm64 armv7s armv7' }

# user_target_xcconfig:对工程中所有 pod 的设置
# pod_target_xcconfig:对当前 pod 的设置
# 如果多个 pod 的 podspec 中对 user_target_xcconfig 同⼀个值进行了设置,会存在冲突的问题

subspec: pod submodule configuration

s.subspec 'catogerys' do |ss|
   ss.source_files = "component/catogerys/**/*.{h,m}"
   ss.dependency "JPUtils"
end

s.subspec 'controllers' do |ss|
   ss.source_files = "component/controllers/**/*.{h,m}", "component/utils/**/*.{h,m}"
   ss.dependency "component/catogerys"
end

Note: * in the file path represents the file name wildcard, ** represents the folder recursive matching; the arrays are separated by commas (for example: s.libraries = 'a', 'b' or s.libraries = ['a', 'b ']).

podspec file verification and upload

1) Create a remote warehouse 

https://github.com/zhengmiaokai/Specs.git 

2) Add the repo in the repos using the remote warehouse URL 

pod repo add  zhengmiaokai https://github.com/zhengmiaokai/Specs.git

pod repo remove zhengmiaokai ( removal repo )

3) Check the validity of the podspecs file 

pod spec lint ~/desktop/zhengmiaokai/JPUtils/JPUtils.podspec  --use-libraries --allow-warnings --verbose --sources=' Private library-git address, https://github.com/CocoaPods/Specs. git '

pod spec lint ~/desktop/zhengmiaokai/JPUtils/JPUtils.podspec --use-libraries --allow-warnings --verbose --sources='https://github.com/CocoaPods/Specs.git,https://github.com/zhengmiaokai/Specs.git'

4) Add the podspec file to the remote warehouse 

pod repo push  zhengmiaokai ~/desktop/zhengmiaokai/JPUtils/JPUtils.podspec  --use-libraries --allow-warnings --verbose --sources=' Private library-git address,CocoaPods-git address '

pod repo push zhengmiaokai ~/desktop/zhengmiaokai/JPUtils/JPUtils.podspec --use-libraries --allow-warnings --verbose --sources='https://github.com/CocoaPods/Specs.git,https://github.com/zhengmiaokai/Specs.git'

Notes: --use-libraries (use libraries and frameworks), --allow-warnings (ignore warnings), --verbose (location errors) --sources='specs address' (default is CocoaPods, multiple addresses are separated by commas open)

Guess you like

Origin blog.csdn.net/z119901214/article/details/90241251