美文网首页
Reference/Podspec

Reference/Podspec

作者: 李永开 | 来源:发表于2021-12-09 20:24 被阅读0次

    一.这就是Podspec

    Podspec全程 pods specification,即pod的说明文件


    图片.png

    里面可以描述的很详细

    Pod::Spec.new do |spec|
    spec.name = 'Reachability'
    spec.version = '3.1.0'
    spec.license = { :type => 'BSD' }
    spec.homepage = 'https://github.com/tonymillion/Reachability'
    spec.authors = { 'Tony Million' => 'tonymillion@gmail.com' }
    spec.summary = 'ARC and GCD Compatible Reachability Class for iOS and OS X.'
    spec.source = { :git => 'https://github.com/tonymillion/Reachability.git', :tag => 'v3.1.0' }
    spec.module_name = 'Rich'
    spec.swift_version = '4.0'

    spec.ios.deployment_target = '9.0'
    spec.osx.deployment_target = '10.10'

    spec.source_files = 'Reachability/common/.swift'
    spec.ios.source_files = 'Reachability/ios/
    .swift', 'Reachability/extensions/.swift'
    spec.osx.source_files = 'Reachability/osx/
    .swift'

    spec.framework = 'SystemConfiguration'
    spec.ios.framework = 'UIKit'
    spec.osx.framework = 'AppKit'

    spec.dependency 'SomeOtherPod'
    end

    二.Root specification vs sub-specifications

    具体字段参考https://guides.cocoapods.org/syntax/podspec.html#group_root_specification

    三. Build settings

    • dependency

    spec.dependency 'AFNetworking', '~> 1.0'
    spec.dependency 'AFNetworking', '~> 1.0', :configurations => ['Debug']
    spec.dependency 'AFNetworking', '~> 1.0', :configurations => :debug
    spec.dependency 'RestKit/CoreData', '~> 0.20.0'
    spec.ios.dependency 'MBProgressHUD', '~> 0.5'

    • info_plist
      设置pod的info plist

    spec.info_plist = {
    'CFBundleIdentifier' => 'com.myorg.MyLib',
    'MY_VAR' => 'SOME_VALUE'
    }

    • requires_arc
      是不是要使用arc,当然了,这都啥年代了。。。
    • frameworks

    spec.ios.framework = 'CFNetwork'
    spec.frameworks = 'QuartzCore', 'CoreData'

    • weak_frameworks
      A list of frameworks that the user’s target needs to weakly link against.

    spec.weak_framework = 'Twitter'
    spec.weak_frameworks = 'Twitter', 'SafariServices'

    • libraries

    spec.ios.library = 'xml2'
    spec.libraries = 'xml2', 'z'

    • compiler_flags
      !!!!!!!!这个挺重要的哎!!!!!!!

    spec.compiler_flags = '-DOS_OBJECT_USE_OBJC=0', '-Wno-format'

    • pod_target_xcconfig
      Any flag to add to the final private pod target xcconfig file.

    spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' }

    • user_target_xcconfig
      不建议使用

    spec.user_target_xcconfig = { 'MY_SUBSPEC' => 'YES' }

    • prefix_header_contents
      不建议使用

    spec.prefix_header_contents = '#import <UIKit/UIKit.h>'
    spec.prefix_header_contents = '#import <UIKit/UIKit.h>', '#import <Foundation/Foundation.h>'

    • prefix_header_file
      不建议使用

    spec.prefix_header_file = 'iphone/include/prefix.pch'
    spec.prefix_header_file = false

    • module_name

    spec.module_name = 'Three20'

    • script_phases

    spec.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"' }

    spec.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :before_compile }

    spec.script_phase = { :name => 'Hello World', :script => 'puts "Hello World"', :shell_path => '/usr/bin/ruby' }

    spec.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"',
    :input_files => ['/path/to/input_file.txt'], :output_files => ['/path/to/output_file.txt']
    }

    spec.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"',
    :input_file_lists => ['/path/to/input_files.xcfilelist'], :output_file_lists => ['/path/to/output_files.xcfilelist']
    }

    spec.script_phases = [
    { :name => 'Hello World', :script => 'echo "Hello World"' },
    { :name => 'Hello Ruby World', :script => 'puts "Hello World"', :shell_path => '/usr/bin/ruby' },
    ]

    四. File patterns

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

    五.Subspecs

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

    相关文章

      网友评论

          本文标题:Reference/Podspec

          本文链接:https://www.haomeiwen.com/subject/ebfqfrtx.html