Class: Pod::PodfileTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-vemars/hook/podfile_template.rb

Constant Summary collapse

IOS_VERSION =
'9.0'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(baseline_version, componentsList, sources) ⇒ PodfileTemplate

Returns a new instance of PodfileTemplate.



10
11
12
13
14
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 10

def initialize(baseline_version, componentsList, sources)
  @baseline_version = baseline_version
  @componentsList = componentsList
  @sources = sources
end

Instance Attribute Details

#baseline_versionObject (readonly)

Returns the value of attribute baseline_version.



6
7
8
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 6

def baseline_version
  @baseline_version
end

#componentsListObject (readonly)

Returns the value of attribute componentsList.



4
5
6
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 4

def componentsList
  @componentsList
end

#sourcesObject (readonly)

Returns the value of attribute sources.



5
6
7
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 5

def sources
  @sources
end

Instance Method Details

#platformObject



32
33
34
35
36
37
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 32

def platform
  <<-SPEC
platform :ios, #{IOS_VERSION}
inhibit_all_warnings!
  SPEC
end

#post_install_setupObject



73
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
104
105
106
107
108
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 73

def post_install_setup
  <<-SPEC
def update_deployment_config(config = nil)
  return if config.nil?
  config.build_settings['ENABLE_BITCODE'] = 'NO'
  if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 12.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
  end
end

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
update_deployment_config(config)
  end
  
  installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
  update_deployment_config(config)
end
  end
  ## for generate_multiple_pod_projects = true
  installer.generated_projects.each do |project|
project.build_configurations.each do |config|
  update_deployment_config(config)
end

project.targets.each do |target|
  target.build_configurations.each do |config|
    update_deployment_config(config)
  end
end
  end

end
  SPEC
end

#releasePodObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 44

def releasePod
  <<-SPEC
  
def release_pod
  #baseline version #{baseline_version}
  #{@componentsList.map { |component|
    result = "\tpod '#{component.name}'"
    if !component.version.nil? 
      result = result + ", '#{component.version}'"
    end
    
    if !component.subspecs.nil?
      result = result + ", :subspecs => #{component.subspecs}"
    end
    result
  }.join("\n")}
end
  SPEC
end

#source_templateObject



39
40
41
42
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 39

def source_template
  source_urls = sources.split(",")
  "#{source_urls.map{ |url| "source '#{url}'"}.join("\n")}"
end

#targetObject



64
65
66
67
68
69
70
71
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 64

def target
  <<-SPEC
target 'Template_InHouse' do
  release_pod
  pod 'App/Debug', :path => './../DevPods/', :inhibitat_warnings => false
end
  SPEC
end

#to_dslObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cocoapods-vemars/hook/podfile_template.rb', line 16

def to_dsl
  <<-SPEC

 #{platform}

#plugin 'cocoapods-vemars'
install! 'cocoapods', :deterministic_uuids => false

#{source_template}

#{releasePod}
#{target}
#{post_install_setup}
  SPEC
end