iOS 的那些事儿

pod 中应用条件分支

2018-05-16  本文已影响6人  CodingTom

调用方式 user_lib=1 pod install


  $lib = ENV['use_lib']
  $lib_name = ENV["#{s.name}_use_lib"]
  if $lib || $lib_name
     puts '---------binary-------'
     s.ios.vendored_framework = "Framework/#{s.version}/#{s.name}.framework"
     //这种是帮你打包成bundle
     s.resource_bundles = {
       "#{s.name}" => ["#{s.name}/Assets/*.{png,xib,plist}"]
     }
     //这种是你已经打包好了bundle,推荐这种,可以省去每次pod帮你生成bundle的时间
     s.resources = "#{s.name}/Assets/*.bundle"
  else
     puts '.......source........'
     s.source_files = "#{s.name}/Classes/**/*"
     s.resources = "#{s.name}/Assets/*.bundle"
     s.public_header_files = "#{s.name}/Classes/**/*.h"
  end
  
$lib=='1' 判断 == 1
if $lib 是否有值

LocalGitPod_binary=1 pod install
#
# Be sure to run `pod lib lint LocalGitPod.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
# pod lib lint
# pod spec lint
# pod repo push TomPodRepos LocalGitPod.podspec --verbose

Pod::Spec.new do |s|
  s.name             = 'LocalGitPod'
  s.version          = '0.1.0'
  s.summary          = 'A Pod lib For Self By CodingTom name LocalGitPod.'

# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
                        这是一个私人库:https://github.com/liuyujie/TomSpecs.git
                        例子来源:https://github.com/ApterKingRepo/Verify-SwiftOC3rd.git
                        DESC

  s.homepage         = 'https://github.com/liuyujie/LocalGitPod.git'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'CodingTom' => 'liuyujieemail@163.com' }
  s.source           = { :git => 'https://github.com/liuyujie/LocalGitPod.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '8.0'
  
  s.ios.frameworks = 'Foundation', 'UIKit','Security','CoreFoundation', 'CoreText', 'CoreGraphics', 'CoreImage', 'QuartzCore', 'ImageIO', 'AssetsLibrary', 'Accelerate', 'MobileCoreServices', 'SystemConfiguration'
  
  #s.source_files = 'LocalGitPod/Classes/**/*'
  
  #s.public_header_files = 'LocalGitPod/Classes/**/*.h'
  
  s.libraries = 'z', 'sqlite3'
  # s.vendored_libraries = 'LocalGitPod/ThirdLib/*.a'
  # s.preserve_paths = 'LocalGitPod/Framework/*.framework', 'LocalGitPod/ThirdLib/*.a'
  # s.pod_target_xcconfig = {
      #'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/Verify-SwiftOC3rd/Vendors',
      #   'HEADER_SEARCH_PATHS' => '$(PODS_ROOT)/LocalGitPod/Framework/*.framework/Headers',
      #   'OTHER_LDFLAGS' => '-ObjC'
      #}
  #s.preserve_paths = 'LocalGitPod/Framework/*.framework'
  
  s.ios.vendored_frameworks =  'gitframework/*.framework'


  $uselib = ENV['binary']
  $lib_name = ENV["#{s.name}_binary"]

  if $uselib == '1' || $lib_name == '1'
      puts '---------binary-------'

     # s.ios.vendored_framework = "Framework/#{s.version}/#{s.name}.framework"
     # //这种是帮你打包成bundle
     # s.resource_bundles = {
     #   "#{s.name}" => ["#{s.name}/Assets/*.{png,xib,plist}"]
     # }
     # //这种是你已经打包好了bundle,推荐这种,可以省去每次pod帮你生成bundle的时间
     # s.resources = "#{s.name}/Assets/*.bundle"
      $depend = ENV['depend']
      $lib_depend = ENV["#{s.name}_depend"]

      if $depend == '1' || $lib_depend == '1'
          puts "------- #{s.name} Use dependency Config -------"
      end
  else
      puts '---------Source-------'
     # s.source_files = "#{s.name}/Classes/**/*"
     # s.resources = "#{s.name}/Assets/*.bundle"
     # s.public_header_files = "#{s.name}/Classes/**/*.h"
         #是否应用 dependency 配置
  end

end

上一篇下一篇

猜你喜欢

热点阅读