Module: Pod::PodUtil

Included in:
Frameworker, XBuilder
Defined in:
lib/cocoapods-framework/util/pod_util.rb

Instance Method Summary collapse

Instance Method Details

#build_static_sandboxObject



32
33
34
# File 'lib/cocoapods-framework/util/pod_util.rb', line 32

def build_static_sandbox
  Sandbox.new(config.sandbox_root)
end

#generic_new_podspec_hash(spec) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/cocoapods-framework/util/pod_util.rb', line 85

def generic_new_podspec_hash spec
  spec_hash = spec.to_hash
  [
    "source_files",
    "resources",
    "resource_bundles",
    "prefix_header_contents",
    "prefix_header_file",
    "header_dir",
    "header_mappings_dir",
    "script_phase",
    "public_header_files",
    "private_header_files",
    "vendored_frameworks",
    "vendored_libraries",
    "exclude_files",
    "preserve_paths",
    "module_map",
    "subspec"
  ].each do |key|
    spec_hash.delete "#{key}"
  end
  spec_hash
end

#installation_root(sandbox, spec, subspecs, sources, use_frameworks = true, use_modular_headers = true) ⇒ Object



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
# File 'lib/cocoapods-framework/util/pod_util.rb', line 36

def installation_root sandbox, spec, subspecs, sources,use_frameworks = true,use_modular_headers = true
    podfile = podfile_from_spec(
    @path,
    spec,
    subspecs,
    sources,
    use_frameworks,
    use_modular_headers
  )

  installer = Installer.new(sandbox, podfile)
  installer.install!

  unless installer.nil? 
    installer.pods_project.targets.each do |target|
      if target.name == spec.name
        target.build_configurations.each do |configuration|
          configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
        end
      end
    end
    installer.pods_project.save
  end
  installer
end

#podfile_from_spec(path, spec, subspecs, sources, use_frameworks = true, use_modular_headers = true) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/cocoapods-framework/util/pod_util.rb', line 62

def podfile_from_spec path, spec, subspecs, sources, use_frameworks = true, use_modular_headers=true
    options = Hash.new
  options[:podspec] = path.to_s
  options[:subspecs] = subspecs if subspecs

  Pod::Podfile.new do
    sources.each {|s| source s}
    spec.available_platforms.each do |plt|
      target "#{spec.name}-#{plt.name}" do
        platform(plt.name, spec.deployment_target(plt.name))
        pod(spec.name, options)
      end
    end

    install!('cocoapods',
      :integrate_targets => false,
      :deterministic_uuids => false)

      use_frameworks! if use_frameworks
      use_modular_headers! if use_modular_headers
    end
end

#spec_with_name(name) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/cocoapods-framework/util/pod_util.rb', line 23

def spec_with_name(name)
  return if name.nil?

  set = Pod::Config.instance.sources_manager.search(Dependency.new(name))
  return nil if set.nil?

  set.specification.root
end

#spec_with_path(path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cocoapods-framework/util/pod_util.rb', line 3

def spec_with_path(path)
  return if path.nil?
  path = Pathname.new(path)
  path = Pathname.new(Dir.pwd).join(path) unless path.absolute?
  return unless path.exist?
  @path = path.expand_path

  if @path.directory?
    raise @path + ': is a directory.'
    return
  end

  unless ['.podspec', '.json'].include? @path.extname
    raise @path + ': is not a podspec.'
    return
  end

  Specification.from_file(@path)
end