Class: Pod::Command::Packagethk

Inherits:
Pod::Command show all
Defined in:
lib/pod/command/packagethk.rb,
lib/cocoapods-packagerthk/pod_utils.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Packagethk

Returns a new instance of Packagethk.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/pod/command/packagethk.rb', line 29

def initialize(argv)
  @embedded = argv.flag?('embedded')
  @library = argv.flag?('library')
  @dynamic = argv.flag?('dynamic')
  @local = argv.flag?('local', false)
  @package_type = if @embedded
                    :static_framework
                  elsif @dynamic
                    :dynamic_framework
                  elsif @library
                    :static_library
                  else
                    :static_framework
                  end
  @force = argv.flag?('force')
  @mangle = argv.flag?('mangle', true)
  @bundle_identifier = argv.option('bundle-identifier', nil)
  @exclude_deps = argv.flag?('exclude-deps', false)
  @name = argv.shift_argument
  @source = argv.shift_argument
  @spec_sources = argv.option('spec-sources', 'https://github.com/CocoaPods/Specs.git').split(',')

  subspecs = argv.option('subspecs')
  @subspecs = subspecs.split(',') unless subspecs.nil?

  @config = argv.option('configuration', 'Release')

  @source_dir = Dir.pwd
  @is_spec_from_path = false
  @spec = spec_with_path(@name)
  @is_spec_from_path = true if @spec
  @spec ||= spec_with_name(@name)
  @generate_spec = argv.flag?('generate-spec',false)
  super
end

Class Method Details

.optionsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pod/command/packagethk.rb', line 11

def self.options
  [
    ['--force',     'Overwrite existing files.'],
    ['--no-mangle', 'Do not mangle symbols of depedendant Pods.'],
    ['--embedded',  'Generate embedded frameworks.'],
    ['--library',   'Generate static libraries.'],
    ['--dynamic',   'Generate dynamic framework.'],
    ['--local',     'Use local state rather than published versions.'],
    ['--bundle-identifier', 'Bundle identifier for dynamic framework'],
    ['--exclude-deps', 'Exclude symbols from dependencies.'],
    ['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
    ['--subspecs', 'Only include the given subspecs'],
    ['--spec-sources=private,https://github.com/CocoaPods/Specs.git', 'The sources to pull dependent ' \
      'pods from (defaults to https://github.com/CocoaPods/Specs.git)'],
    ['--generate-spec', 'Generate spec file.']
  ]
end

Instance Method Details

#runObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/pod/command/packagethk.rb', line 74

def run
  if @spec.nil?
    help! "Unable to find a podspec with path or name `#{@name}`."
    return
  end

  target_dir, work_dir = create_working_directory
  # puts work_dir
  return if target_dir.nil?
  build_package
  # 文件迁移FileUtils
  puts "move files..."


  `rm -rf mv #{work_dir}/build/`
  
  exist = File::exists?("#{work_dir}/ios/#{@spec.name}.framework/Versions/A/Resources")
  if exist
    puts "move Resources..."
    `rm -rf mv #{work_dir}/ios/#{@spec.name}.framework/Resources`
    `mv #{work_dir}/ios/#{@spec.name}.framework/Versions/A/Resources  #{work_dir}/ios/#{@spec.name}.framework/`
  end
  `rm -rf mv #{work_dir}/ios/#{@spec.name}.framework/Headers`
  `rm -rf mv #{work_dir}/ios/#{@spec.name}.framework/#{@spec.name}`
  `mv #{work_dir}/ios/#{@spec.name}.framework/Versions/A/Headers  #{work_dir}/ios/#{@spec.name}.framework/`
  `mv #{work_dir}/ios/#{@spec.name}.framework/Versions/A/#{@spec.name}  #{work_dir}/ios/#{@spec.name}.framework/`
  `rm -rf #{work_dir}/ios/#{@spec.name}.framework/Versions`
  `mv "#{work_dir}" "#{target_dir}"`
  Dir.chdir(@source_dir)
end

#validate!Object



65
66
67
68
69
70
71
72
# File 'lib/pod/command/packagethk.rb', line 65

def validate!
  super
  help! 'A podspec name or path is required.' unless @spec
  help! 'podspec has binary-only depedencies, mangling not possible.' if @mangle && binary_only?(@spec)
  help! '--bundle-identifier option can only be used for dynamic frameworks' if @bundle_identifier && !@dynamic
  help! '--exclude-deps option can only be used for static libraries' if @exclude_deps && @dynamic
  help! '--local option can only be used when a local `.podspec` path is given.' if @local && !@is_spec_from_path
end