• Podfile、Podfile.lock、Manifest.lock、Podspec


    Podfile

    开发编写的文件,包含了关于工程的targets、Pods的信息,比如依赖的第三方库的版本、资源的加载路径等。主要用于描述一个或多个 Xcode Project 中各个 Targets 之间的依赖关系。

    if (repo = ENV['COCOAPODS_SPEC_REPO'])
        source "#{repo}"
    end
    
    ### Implicit target definition :-/
    project "AFNetworking Mac Example.xcodeproj"
    ####
    
    workspace 'Examples.xcworkspace'
    
    target "AFNetworking Example" do
      platform :osx, '10.8'
      project "AFNetworking Mac Example.xcodeproj"
      pod "AFNetworking", "1.3.3"
    end
    
    target "AFNetworking iOS Example" do
      platform :ios, '8.0'
      project "AFNetworking iOS Example.xcodeproj"
      pod "AFNetworking", "1.3.3"
    end
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    Podfile.lock

    该文件记录工程安装了哪些Pod以及对应的版本,是pod install的产物

    #PODS:记录所有Pod库的具体安装的版本号
    PODS:
      - AFNetworking (1.3.3)
    #DEPENDENCIES:记录各Pod库之间的相互依赖关系,
    DEPENDENCIES:
      - AFNetworking (= 1.3.3)
    #SPEC REPOS:仓库信息,即安装了哪些三方库,他们来自于哪个仓库
    SPEC REPOS:
      trunk:
        - AFNetworking
    #SPEC CHECKSUMS:记录当前各 Pod 库的 Podspec 文件 Hash 值,其实就是文件的 md5
    SPEC CHECKSUMS:
      AFNetworking: 127629aef6e631d57291c25154defc678c8a7337
    #PODFILE CHECKSUM:记录 Podfile 文件的 Hash 值,同样是 md5,确认是否有变更
    PODFILE CHECKSUM: 6f295323460330fe2653455f8ed3f15e71283613
    #记录上次所使用的 CocoaPods 版本
    COCOAPODS: 1.11.3
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    Manifest.lock

    Manifest.lock其实是Podfile.lock 文件的副本,每次运行 pod install 命令时都会更新;通常Pods文件不放到版本管理里面、Podfile.lock放到版本管理里面,这样在本地拉取代码之后是否需要更新pod,就可以通过对比本地的Manifest.lock和远程Podfile.lock是否相同即可

    如果遇见The sandbox is not in sync with the Podfile.lock报错

    原因是沙盒文件与 Podfile.lock 文件不同步,根本原因是 Manifest.lock 文件和 Podfile.lock 文件不一致所引起。

    PODS:
      - AFNetworking (1.3.3)
    
    DEPENDENCIES:
      - AFNetworking (= 1.3.3)
    
    SPEC REPOS:
      trunk:
        - AFNetworking
    
    SPEC CHECKSUMS:
      AFNetworking: 127629aef6e631d57291c25154defc678c8a7337
    
    PODFILE CHECKSUM: 6f295323460330fe2653455f8ed3f15e71283613
    
    COCOAPODS: 1.11.3
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    Podspec

    描述了一个库是怎样被添加到工程中的。它支持的功能有:列出源文件、framework、编译选项和某个库所需要的依赖等。

    Pod::Spec.new do |s|
      s.name = 'Alamofire'
      s.version = '4.6.0'
      s.license = 'MIT'
      s.summary = 'Elegant HTTP Networking in Swift'
      s.homepage = 'https://github.com/Alamofire/Alamofire'
      s.social_media_url = 'http://twitter.com/AlamofireSF'
      s.authors = { 'Alamofire Software Foundation' => 'info@alamofire.org' }
      s.source = { :git => 'https://github.com/Alamofire/Alamofire.git', :tag => s.version }
    
      s.ios.deployment_target = '8.0'
      s.osx.deployment_target = '10.10'
      s.tvos.deployment_target = '9.0'
      s.watchos.deployment_target = '2.0'
    
      s.source_files = 'Source/*.swift'
    end
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    我们简单介绍一下podspec文件内容

    第一部分是简单的内容,我们不展开介绍,大家从属性名字即可知道属性的作用

      s.name = 'Alamofire'
      s.version = '4.6.0'
      s.license = 'MIT'
      s.summary = 'Elegant HTTP Networking in Swift'
      s.homepage = 'https://github.com/Alamofire/Alamofire'
      s.social_media_url = 'http://twitter.com/AlamofireSF'
      s.authors = { 'Alamofire Software Foundation' => 'info@alamofire.org' }
      s.source = { :git => 'https://github.com/Alamofire/Alamofire.git', :tag => s.version }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    第二部分介绍一下不常用的或者需要解释一下

    (1)配置三方库的源文件

    Source_files:配置三方库的源文件,一般是.h.m.c等后缀的文件

    s.source_files  = [Class/**/*.{h,m,c},"ClassA.{h,m}", "Bridge.h”]
    
    • 1

    (2)配置工程的系统框架

    — frameworks:配置依赖的系统框架

    s.frameworks  = 'AVFoundation','QuartzCore', ‘CoreLocation'
    
    • 1

    — vendored_frameworks:配置需要引用的非系统框架

    vendored_frameworks = 'Frameworks/MyFramework.framework'
    
    • 1

    (3)配置工程的的系统库

    — vendored_libraries:配置需要引用的非系统静态库(要注意,这里的.a静态库名字必须要带lib前缀,如果引用的静态库名字没lib前缀会导致编译报错,只需要重命名加上即可)

     vendored_libraries = 'Class/libXXX.a’
    
    • 1

    — Libraries:配置依赖的系统库(要注意,这里的写法需要忽略lib前缀)

    libraries = 'c++', 'sqlite3', 'stdc++.6.0.9', 'z'
    
    • 1

    (4)配置工程的资源文件

    — resources:配置工程需要的资源文件,一般包括.bundle.png等文件,资源文件会放在mainBundle中,需要避免命名冲突

      s.resources = ['Resources/*.bundle’]
    
    • 1

    — resource_bundles来指定bundle的资源文件,不使用mainBundle中的资源文件

    resource_bundles = {
        'UIKitBundle' => ['Resources/MyUIKit.bundle'],
    }
    
    • 1
    • 2
    • 3

    (5)public_header_files:配置公有的头文件(.h文件)

    写法:
    source_files = 'Classes/UIKit.h' // 直接指定文件名
    或:
    source_files = 'Classes/*.h' // Classes文件夹下的所有匹配文件
    source_files = 'Classes/**/*.h' // Classes所有路径下的所有匹配文件
    
    • 1
    • 2
    • 3
    • 4
    • 5

    s.wb_public_header_files('PublicHeaders’)

    (6)dependency:依赖的三方库,pod库或者可以是自身的subspec

    dependency 'AFNetworking'
    
    • 1

    (7)requires_arc:用来配置哪些源文件使用ARC,

    s.requires_arc = false #没有文件使用ARC
    s.requires_arc = 'Classes/Arc'
    
    • 1
    • 2

    s.wb_resources_hook(s)

    (8)deployment_target: 配置工程支持的的平台的target的最小值

      s.ios.deployment_target = 9.0
    
    • 1

    https://guides.cocoapods.org/syntax/podspec.html

  • 相关阅读:
    Linux之进程间通信
    2.JavaSe_数据类型&标识符
    【Unity Texture】_MainTex的含义
    自动化测试面试常见技术题目
    centos 7部署Mysql8.0主从
    Elastic-Job中Zookeeper的作用
    【数据结构初阶(3)】双向带头结点循环链表
    C++ STL学习 —— 模板、泛型算法、函数对象、lambda 表达式(参数捕获)、函数适配器
    1、配置zabbix邮件报警和微信报警。 2、配置zabbix自动发现和自动注册。
    计算机操作系统-第六天
  • 原文地址:https://blog.csdn.net/u011774517/article/details/126587888