pod-builder 0.1.8.beta ā 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.vscode/launch.json +67 -12
- data/README.md +105 -35
- data/exe/pod_builder +137 -21
- data/lib/core_ext/string.rb +5 -0
- data/lib/pod_builder/command.rb +3 -0
- data/lib/pod_builder/command/build.rb +64 -13
- data/lib/pod_builder/command/clean.rb +24 -7
- data/lib/pod_builder/command/deintegrate.rb +33 -5
- data/lib/pod_builder/command/generate_lfs.rb +66 -0
- data/lib/pod_builder/command/generate_podspec.rb +3 -1
- data/lib/pod_builder/command/init.rb +41 -42
- data/lib/pod_builder/command/install_sources.rb +2 -2
- data/lib/pod_builder/command/switch.rb +165 -0
- data/lib/pod_builder/command/synch_podfile.rb +30 -0
- data/lib/pod_builder/configuration.rb +137 -55
- data/lib/pod_builder/core.rb +37 -18
- data/lib/pod_builder/install.rb +5 -2
- data/lib/pod_builder/podfile.rb +203 -65
- data/lib/pod_builder/podfile/post_actions.rb +2 -6
- data/lib/pod_builder/podfile_item.rb +181 -27
- data/lib/pod_builder/podspec.rb +118 -33
- data/lib/pod_builder/templates/build_podfile.template +2 -2
- data/lib/pod_builder/templates/build_podspec.template +1 -1
- data/lib/pod_builder/version.rb +1 -1
- data/pod-builder.gemspec +1 -0
- metadata +22 -4
data/lib/pod_builder/command.rb
CHANGED
@@ -7,3 +7,6 @@ require 'pod_builder/command/clean'
|
|
7
7
|
require 'pod_builder/command/deintegrate'
|
8
8
|
require 'pod_builder/command/generate_podspec'
|
9
9
|
require 'pod_builder/command/install_sources'
|
10
|
+
require 'pod_builder/command/switch'
|
11
|
+
require 'pod_builder/command/generate_lfs'
|
12
|
+
require 'pod_builder/command/synch_podfile'
|
@@ -14,6 +14,8 @@ module PodBuilder
|
|
14
14
|
return false
|
15
15
|
end
|
16
16
|
|
17
|
+
check_not_building_subspecs(argument_pods)
|
18
|
+
|
17
19
|
update_repo = options[:update_repos] || false
|
18
20
|
installer, analyzer = Analyze.installer_at(PodBuilder::basepath, update_repo)
|
19
21
|
|
@@ -22,10 +24,11 @@ module PodBuilder
|
|
22
24
|
buildable_items = all_buildable_items - prebuilt_items
|
23
25
|
|
24
26
|
if argument_pods.first == "*"
|
25
|
-
argument_pods = buildable_items.map(&:
|
27
|
+
argument_pods = buildable_items.map(&:root_name)
|
26
28
|
end
|
27
29
|
|
28
|
-
argument_pods.select! { |x| buildable_items.map(&:
|
30
|
+
argument_pods.select! { |x| buildable_items.map(&:root_name).include?(x) }
|
31
|
+
argument_pods.uniq!
|
29
32
|
|
30
33
|
unless argument_pods.count > 0
|
31
34
|
puts "\n\nNo pods to build found, `#{ARGV.join(" ")}` is/are prebuilt\n".yellow
|
@@ -34,9 +37,10 @@ module PodBuilder
|
|
34
37
|
return true
|
35
38
|
end
|
36
39
|
|
40
|
+
check_splitted_subspecs_are_static(all_buildable_items, options)
|
37
41
|
check_pods_exists(argument_pods, buildable_items)
|
38
42
|
|
39
|
-
pods_to_build = buildable_items.select { |x| argument_pods.include?(x.
|
43
|
+
pods_to_build = buildable_items.select { |x| argument_pods.include?(x.root_name) }
|
40
44
|
pods_to_build += other_subspecs(pods_to_build, buildable_items)
|
41
45
|
|
42
46
|
buildable_items -= pods_to_build
|
@@ -49,11 +53,11 @@ module PodBuilder
|
|
49
53
|
pods_to_build.select! { |x| !all_dependencies_name.include?(x.name) }
|
50
54
|
|
51
55
|
# We need to split pods to build in 3 groups
|
52
|
-
# 1. subspecs: because the resulting .framework path is treated differently
|
56
|
+
# 1. subspecs: because the resulting .framework path is treated differently when added to Configuration.subspecs_to_split
|
53
57
|
# 2. pods to build in release
|
54
58
|
# 3. pods to build in debug
|
55
59
|
|
56
|
-
pods_to_build_subspecs = pods_to_build.select { |x| x.is_subspec }
|
60
|
+
pods_to_build_subspecs = pods_to_build.select { |x| x.is_subspec && Configuration.subspecs_to_split.include?(x.name) }
|
57
61
|
pods_to_build -= pods_to_build_subspecs
|
58
62
|
pods_to_build_debug = pods_to_build.select { |x| x.build_configuration == "debug" }
|
59
63
|
pods_to_build_release = pods_to_build - pods_to_build_debug
|
@@ -80,17 +84,20 @@ module PodBuilder
|
|
80
84
|
|
81
85
|
write_license_files(licenses, all_buildable_items)
|
82
86
|
|
83
|
-
|
87
|
+
GenerateLFS::call(nil)
|
88
|
+
Podspec::generate(analyzer)
|
84
89
|
|
85
90
|
builded_pods = podfiles_items.flatten
|
86
91
|
builded_pods_and_deps = add_dependencies(builded_pods, all_buildable_items).select { |x| !x.is_prebuilt }
|
87
92
|
Podfile::write_restorable(builded_pods, all_buildable_items, analyzer)
|
88
93
|
if !options.has_key?(:skip_prebuild_update)
|
89
|
-
Podfile::
|
94
|
+
Podfile::write_prebuilt(all_buildable_items, analyzer)
|
90
95
|
end
|
91
96
|
|
92
97
|
Podfile::deintegrate_install
|
93
98
|
|
99
|
+
sanity_checks(options)
|
100
|
+
|
94
101
|
puts "\n\nš done!\n".green
|
95
102
|
return true
|
96
103
|
end
|
@@ -112,7 +119,8 @@ module PodBuilder
|
|
112
119
|
end
|
113
120
|
|
114
121
|
def self.write_license_files(licenses, all_buildable_items)
|
115
|
-
|
122
|
+
puts "Writing licenses".yellow
|
123
|
+
license_file_path = PodBuilder::project_path(Configuration.license_filename) + ".plist"
|
116
124
|
|
117
125
|
current_licenses = []
|
118
126
|
if File.exist?(license_file_path)
|
@@ -186,8 +194,9 @@ module PodBuilder
|
|
186
194
|
next
|
187
195
|
end
|
188
196
|
|
189
|
-
if buildable_pod.dependency_names.include?(dependency) && !buildable_pod.has_subspec(dependency) && !buildable_pod.has_common_spec(dependency)
|
190
|
-
|
197
|
+
if buildable_pod.dependency_names.include?(dependency) && !buildable_pod.has_subspec(dependency) && !buildable_pod.has_common_spec(dependency) then
|
198
|
+
expected_pod_list = pods_to_build.map(&:root_name).uniq
|
199
|
+
raise "\n\nCan't build #{pod_to_build.name} because it has common dependencies (#{dependency}) with #{buildable_pod.name}.\n\nUse `pod_builder build #{expected_pod_list.join(" ")} #{buildable_pod.name}` instead\n\n".red
|
191
200
|
end
|
192
201
|
end
|
193
202
|
end
|
@@ -199,7 +208,15 @@ module PodBuilder
|
|
199
208
|
pods_to_build.each do |pod_to_build|
|
200
209
|
if buildable_items_dependencies.include?(pod_to_build.name)
|
201
210
|
parent = buildable_items.detect { |x| x.dependency_names.include?(pod_to_build.name) }
|
202
|
-
raise "\nCan't build #{pod_to_build.name} because it is a dependency of #{parent.name}.\n\nUse `pod_builder build #{parent.name}` instead\n\n".red
|
211
|
+
raise "\n\nCan't build #{pod_to_build.name} because it is a dependency of #{parent.name}.\n\nUse `pod_builder build #{parent.name}` instead\n\n".red
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def self.check_not_building_subspecs(pods_to_build)
|
217
|
+
pods_to_build.each do |pod_to_build|
|
218
|
+
if pod_to_build.include?("/")
|
219
|
+
raise "\n\nCan't build subspec #{pod_to_build} refer to podspec name.\n\nUse `pod_builder build #{pods_to_build.map { |x| x.split("/").first }.uniq.join(" ")}` instead\n\n".red
|
203
220
|
end
|
204
221
|
end
|
205
222
|
end
|
@@ -207,9 +224,27 @@ module PodBuilder
|
|
207
224
|
def self.check_pods_exists(pods, buildable_items)
|
208
225
|
raise "Empty Podfile?" if buildable_items.nil?
|
209
226
|
|
210
|
-
buildable_items = buildable_items.map(&:
|
227
|
+
buildable_items = buildable_items.map(&:root_name)
|
211
228
|
pods.each do |pod|
|
212
|
-
raise "\nPod `#{pod}` wasn't found in Podfile.\n\nFound:\n#{buildable_items.join("\n")}\n\n".red if !buildable_items.include?(pod)
|
229
|
+
raise "\n\nPod `#{pod}` wasn't found in Podfile.\n\nFound:\n#{buildable_items.join("\n")}\n\n".red if !buildable_items.include?(pod)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def self.check_splitted_subspecs_are_static(all_buildable_items, options)
|
234
|
+
non_static_subspecs = all_buildable_items.select { |x| x.is_subspec && x.is_static == false }
|
235
|
+
non_static_subspecs_names = non_static_subspecs.map(&:name)
|
236
|
+
|
237
|
+
invalid_subspecs = Configuration.subspecs_to_split & non_static_subspecs_names # intersect
|
238
|
+
|
239
|
+
unless invalid_subspecs.count > 0
|
240
|
+
return
|
241
|
+
end
|
242
|
+
|
243
|
+
warn_message = "The following pods `#{invalid_subspecs.join(" ")}` are non static frameworks which are being splitted over different targets. Beware that this is an unsafe setup as per https://github.com/CocoaPods/CocoaPods/issues/5708 and https://github.com/CocoaPods/CocoaPods/issues/5643\n"
|
244
|
+
if options[:allow_warnings]
|
245
|
+
puts "\n\nā ļø #{warn_message}".yellow
|
246
|
+
else
|
247
|
+
raise "\n\nšØļø #{warn_message}".yellow
|
213
248
|
end
|
214
249
|
end
|
215
250
|
|
@@ -235,6 +270,22 @@ module PodBuilder
|
|
235
270
|
|
236
271
|
return buildable_subspecs - pods_to_build
|
237
272
|
end
|
273
|
+
|
274
|
+
def self.sanity_checks(options)
|
275
|
+
lines = File.read(PodBuilder::project_path("Podfile")).split("\n")
|
276
|
+
stripped_lines = lines.map { |x| Podfile.strip_line(x) }.select { |x| !x.start_with?("#")}
|
277
|
+
|
278
|
+
expected_stripped = Podfile::POST_INSTALL_ACTIONS.map { |x| Podfile.strip_line(x) }
|
279
|
+
|
280
|
+
if !expected_stripped.all? { |x| stripped_lines.include?(x) }
|
281
|
+
warn_message = "PodBuilder's post install actions missing from application Podfile!\n"
|
282
|
+
if options[:allow_warnings]
|
283
|
+
puts "\n\nā ļø #{warn_message}".yellow
|
284
|
+
else
|
285
|
+
raise "\n\nšØļø #{warn_message}".red
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
238
289
|
end
|
239
290
|
end
|
240
291
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pod_builder/core'
|
2
|
+
require 'highline/import'
|
2
3
|
|
3
4
|
module PodBuilder
|
4
5
|
module Command
|
@@ -16,31 +17,34 @@ module PodBuilder
|
|
16
17
|
|
17
18
|
base_path = PodBuilder::basepath("Rome")
|
18
19
|
framework_files = Dir.glob("#{base_path}/**/*.framework")
|
20
|
+
puts "Looking for unused frameworks".yellow
|
19
21
|
clean(framework_files, base_path, rel_paths)
|
20
22
|
|
21
23
|
rel_paths.map! { |x| "#{x}.dSYM"}
|
22
24
|
|
23
25
|
base_path = PodBuilder::basepath("dSYM/iphoneos")
|
24
26
|
dSYM_files_iphone = Dir.glob("#{base_path}/**/*.dSYM")
|
27
|
+
puts "Looking for iPhoneOS unused dSYMs".yellow
|
25
28
|
clean(dSYM_files_iphone, base_path, rel_paths)
|
26
29
|
|
27
30
|
base_path = PodBuilder::basepath("dSYM/iphonesimulator")
|
28
31
|
dSYM_files_sim = Dir.glob("#{base_path}/**/*.dSYM")
|
32
|
+
puts "Looking for iPhone Simulator unused dSYMs".yellow
|
29
33
|
clean(dSYM_files_sim, base_path, rel_paths)
|
30
34
|
|
35
|
+
puts "Looking for unused sources".yellow
|
31
36
|
clean_sources(podspec_names)
|
32
37
|
|
33
38
|
puts "\n\nš done!\n".green
|
34
39
|
return true
|
35
40
|
end
|
36
41
|
|
37
|
-
def self.clean_sources(podspec_names)
|
38
|
-
puts "Cleaning sources".blue
|
39
|
-
|
42
|
+
def self.clean_sources(podspec_names)
|
40
43
|
base_path = PodBuilder::basepath("Sources")
|
41
44
|
|
42
45
|
repo_paths = Dir.glob("#{base_path}/*")
|
43
46
|
|
47
|
+
paths_to_delete = []
|
44
48
|
repo_paths.each do |path|
|
45
49
|
podspec_name = File.basename(path)
|
46
50
|
|
@@ -48,8 +52,14 @@ module PodBuilder
|
|
48
52
|
next
|
49
53
|
end
|
50
54
|
|
51
|
-
|
52
|
-
|
55
|
+
paths_to_delete.push(path)
|
56
|
+
end
|
57
|
+
|
58
|
+
paths_to_delete.flatten.each do |path|
|
59
|
+
confirm = ask("#{path} unused.\nDelete it? [Y/N] ") { |yn| yn.limit = 1, yn.validate = /[yn]/i }
|
60
|
+
if confirm.downcase == 'y'
|
61
|
+
PodBuilder::safe_rm_rf(path)
|
62
|
+
end
|
53
63
|
end
|
54
64
|
end
|
55
65
|
|
@@ -58,13 +68,20 @@ module PodBuilder
|
|
58
68
|
def self.clean(files, base_path, rel_paths)
|
59
69
|
files = files.map { |x| [Pathname.new(x).relative_path_from(Pathname.new(base_path)).to_s, x] }.to_h
|
60
70
|
|
71
|
+
paths_to_delete = []
|
61
72
|
files.each do |rel_path, path|
|
62
73
|
unless !rel_paths.include?(rel_path)
|
63
74
|
next
|
64
75
|
end
|
65
76
|
|
66
|
-
|
67
|
-
|
77
|
+
paths_to_delete.push(path)
|
78
|
+
end
|
79
|
+
|
80
|
+
paths_to_delete.each do |path|
|
81
|
+
confirm = ask("\n#{path} unused.\nDelete it? [Y/N] ") { |yn| yn.limit = 1, yn.validate = /[yn]/i }
|
82
|
+
if confirm.downcase == 'y'
|
83
|
+
PodBuilder::safe_rm_rf(path)
|
84
|
+
end
|
68
85
|
end
|
69
86
|
|
70
87
|
current_dir = Dir.pwd
|
@@ -7,7 +7,7 @@ module PodBuilder
|
|
7
7
|
raise "\n\nPodBuilder not initialized!\n".red if !Configuration.exists
|
8
8
|
|
9
9
|
prebuilt_podfile = File.join(Configuration.base_path, "Podfile")
|
10
|
-
restored_podfile = File.join(PodBuilder::
|
10
|
+
restored_podfile = File.join(PodBuilder::project_path, "Podfile")
|
11
11
|
|
12
12
|
FileUtils.cp(prebuilt_podfile, restored_podfile)
|
13
13
|
|
@@ -15,7 +15,7 @@ module PodBuilder
|
|
15
15
|
podfile_lines = []
|
16
16
|
pre_install_indx = -1
|
17
17
|
podfile_content.each_line.with_index do |line, index|
|
18
|
-
if Podfile::
|
18
|
+
if Podfile::PODBUILDER_LOCK_ACTION.detect { |x| Podfile::strip_line(x) == Podfile::strip_line(line) }
|
19
19
|
if pre_install_indx == -1
|
20
20
|
pre_install_indx = index
|
21
21
|
end
|
@@ -33,19 +33,47 @@ module PodBuilder
|
|
33
33
|
|
34
34
|
FileUtils.rm_f(restored_podfile)
|
35
35
|
File.write(restored_podfile, podfile_lines.join)
|
36
|
+
Podfile.update_path_entires(restored_podfile, false)
|
37
|
+
Podfile.update_project_entries(restored_podfile, false)
|
36
38
|
|
37
39
|
PodBuilder::safe_rm_rf(Configuration.base_path)
|
38
40
|
|
39
|
-
Dir.chdir(PodBuilder::
|
40
|
-
system("pod
|
41
|
+
Dir.chdir(PodBuilder::project_path)
|
42
|
+
system("pod install;")
|
41
43
|
|
42
|
-
license_base = PodBuilder::
|
44
|
+
license_base = PodBuilder::project_path(Configuration.license_filename)
|
43
45
|
FileUtils.rm_f("#{license_base}.plist")
|
44
46
|
FileUtils.rm_f("#{license_base}.md")
|
45
47
|
|
48
|
+
update_gemfile
|
49
|
+
|
46
50
|
puts "\n\nš done!\n".green
|
47
51
|
return true
|
48
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def self.update_gemfile
|
57
|
+
gemfile_path = File.join(PodBuilder::home, "Gemfile")
|
58
|
+
unless File.exist?(gemfile_path)
|
59
|
+
FileUtils.touch(gemfile_path)
|
60
|
+
end
|
61
|
+
|
62
|
+
podbuilder_line = "gem 'pod-builder'"
|
63
|
+
|
64
|
+
gemfile = File.read(gemfile_path)
|
65
|
+
|
66
|
+
gemfile_lines = gemfile.split("\n")
|
67
|
+
gemfile_lines.select! { |x| !trim_gemfile_line(x).include?(trim_gemfile_line(podbuilder_line)) }
|
68
|
+
File.write(gemfile_path, gemfile_lines.join("\n"))
|
69
|
+
|
70
|
+
Dir.chdir(PodBuilder::home)
|
71
|
+
system("bundle")
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.trim_gemfile_line(line)
|
75
|
+
return line.gsub("\"", "'").gsub(" ", "")
|
76
|
+
end
|
49
77
|
end
|
50
78
|
end
|
51
79
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'pod_builder/core'
|
2
|
+
|
3
|
+
module PodBuilder
|
4
|
+
module Command
|
5
|
+
class GenerateLFS
|
6
|
+
def self.call(options)
|
7
|
+
Configuration.check_inited
|
8
|
+
|
9
|
+
unless Configuration.update_lfs_gitattributes
|
10
|
+
return false
|
11
|
+
end
|
12
|
+
|
13
|
+
base_path = PodBuilder::basepath
|
14
|
+
framework_files = filter_files_by_size(Dir.glob("#{base_path}/Rome/**/*.framework/**/**"), 256)
|
15
|
+
dSYM_files_iphone = filter_files_by_size(Dir.glob("#{base_path}/dSYM/**/*.dSYM/**/**"), 256)
|
16
|
+
|
17
|
+
total_size = (framework_files + dSYM_files_iphone).map { |x| File.size(x) }.inject(0, :+)
|
18
|
+
puts "Total size in LFS: #{total_size / 1024 / 1024}MB"
|
19
|
+
|
20
|
+
home_path = Pathname.new(PodBuilder::home)
|
21
|
+
|
22
|
+
paths = (framework_files + dSYM_files_iphone).map { |x| Pathname.new(x) }
|
23
|
+
rel_paths = paths.map { |x| x.relative_path_from(home_path).to_s }
|
24
|
+
|
25
|
+
stop_marker = "# pb<stop>"
|
26
|
+
start_marker = "# pb<start> (lines up to `#{stop_marker}` are autogenerated, don't modify this section)"
|
27
|
+
|
28
|
+
gitattributes_items = [start_marker]
|
29
|
+
gitattributes_items += rel_paths.map { |x| "#{x} filter=lfs diff=lfs merge=lfs -text" }
|
30
|
+
gitattributes_items += [stop_marker]
|
31
|
+
|
32
|
+
gitattributes_path = File.join(PodBuilder::home, ".gitattributes")
|
33
|
+
if !File.exist?(gitattributes_path)
|
34
|
+
FileUtils.touch(gitattributes_path)
|
35
|
+
end
|
36
|
+
|
37
|
+
gitattributes_content = File.read(gitattributes_path)
|
38
|
+
|
39
|
+
podbuilder_start_line_found = false
|
40
|
+
gitattributes_content.each_line do |line|
|
41
|
+
stripped_line = line.strip
|
42
|
+
if stripped_line.start_with?(stop_marker)
|
43
|
+
podbuilder_start_line_found = false
|
44
|
+
next
|
45
|
+
elsif stripped_line.start_with?(start_marker)
|
46
|
+
podbuilder_start_line_found = true
|
47
|
+
end
|
48
|
+
|
49
|
+
unless !podbuilder_start_line_found
|
50
|
+
next
|
51
|
+
end
|
52
|
+
|
53
|
+
gitattributes_items.push(line.strip)
|
54
|
+
end
|
55
|
+
|
56
|
+
File.write(gitattributes_path, gitattributes_items.join("\n"))
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def self.filter_files_by_size(files, size_kb)
|
62
|
+
return files.select { |x| File.size(x) / 1024 > Configuration.lfs_min_file_size }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -5,75 +5,74 @@ module PodBuilder
|
|
5
5
|
class Init
|
6
6
|
def self.call(options)
|
7
7
|
raise "\n\nAlready initialized\n".red if Configuration.exists
|
8
|
-
raise "\n\nXcode
|
8
|
+
raise "\n\nXcode workspace not found\n".red if PodBuilder::project_path.nil?
|
9
9
|
|
10
10
|
options[:prebuild_path] ||= Configuration.base_path
|
11
11
|
|
12
12
|
if File.expand_path(options[:prebuild_path]) != options[:prebuild_path] # if not absolute
|
13
|
-
options[:prebuild_path] = File.expand_path(PodBuilder::
|
13
|
+
options[:prebuild_path] = File.expand_path(PodBuilder::project_path(options[:prebuild_path]))
|
14
14
|
end
|
15
15
|
|
16
16
|
FileUtils.mkdir_p(options[:prebuild_path])
|
17
17
|
FileUtils.mkdir_p("#{options[:prebuild_path]}/.pod_builder")
|
18
18
|
FileUtils.touch("#{options[:prebuild_path]}/.pod_builder/pod_builder")
|
19
|
+
|
20
|
+
source_path_rel_path = "Sources"
|
21
|
+
development_pods_config_rel_path = Configuration.dev_pods_configuration_filename
|
22
|
+
|
23
|
+
git_ignores = ["Pods/",
|
24
|
+
"*.xcworkspace",
|
25
|
+
"*.xcodeproj",
|
26
|
+
"Podfile.lock",
|
27
|
+
source_path_rel_path,
|
28
|
+
development_pods_config_rel_path]
|
19
29
|
|
20
|
-
File.write("#{options[:prebuild_path]}/.gitignore", "
|
30
|
+
File.write("#{options[:prebuild_path]}/.gitignore", git_ignores.join("\n"))
|
21
31
|
|
22
|
-
project_podfile_path = PodBuilder::
|
32
|
+
project_podfile_path = PodBuilder::project_path("Podfile")
|
23
33
|
prebuilt_podfile_path = File.join(options[:prebuild_path], "Podfile")
|
24
34
|
FileUtils.cp(project_podfile_path, prebuilt_podfile_path)
|
25
35
|
|
26
|
-
add_install_block(prebuilt_podfile_path)
|
27
|
-
|
28
|
-
|
29
|
-
add_post_install_checks(project_podfile_path)
|
36
|
+
Podfile.add_install_block(prebuilt_podfile_path)
|
37
|
+
Podfile.update_path_entires(prebuilt_podfile_path, false, PodBuilder::project_path(""))
|
38
|
+
Podfile.update_project_entries(prebuilt_podfile_path, false, PodBuilder::project_path(""))
|
30
39
|
|
31
40
|
Configuration.write
|
32
41
|
|
42
|
+
update_gemfile
|
43
|
+
|
33
44
|
puts "\n\nš done!\n".green
|
34
45
|
return true
|
35
46
|
end
|
36
47
|
|
37
|
-
private
|
48
|
+
private
|
38
49
|
|
39
|
-
def self.
|
40
|
-
|
41
|
-
|
50
|
+
def self.update_gemfile
|
51
|
+
gemfile_path = File.join(PodBuilder::home, "Gemfile")
|
52
|
+
unless File.exist?(gemfile_path)
|
53
|
+
FileUtils.touch(gemfile_path)
|
54
|
+
end
|
42
55
|
|
43
|
-
|
44
|
-
|
45
|
-
add(pre_install_actions, "pre_install", podfile_path)
|
46
|
-
end
|
56
|
+
source_line = "source 'https://rubygems.org'"
|
57
|
+
podbuilder_line = "gem 'pod-builder'"
|
47
58
|
|
48
|
-
|
49
|
-
post_install_actions = ["require 'pod_builder/podfile/post_actions'", "PodBuilder::Podfile::remove_target_support_duplicate_entries", "PodBuilder::Podfile::check_target_support_resource_collisions"]
|
50
|
-
add(post_install_actions, "post_install", podfile_path)
|
51
|
-
end
|
59
|
+
gemfile = File.read(gemfile_path)
|
52
60
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
entries.map! { |x| " #{x}\n"}
|
57
|
-
|
58
|
-
marker_found = false
|
59
|
-
podfile_lines = []
|
60
|
-
podfile_content.each_line do |line|
|
61
|
-
stripped_line = Podfile::strip_line(line)
|
62
|
-
|
63
|
-
podfile_lines.push(line)
|
64
|
-
if stripped_line.start_with?("#{marker}do|")
|
65
|
-
marker_found = true
|
66
|
-
podfile_lines.push(entries)
|
67
|
-
end
|
68
|
-
end
|
61
|
+
gemfile_lines = gemfile.split("\n")
|
62
|
+
gemfile_lines.select! { |x| !trim_gemfile_line(x).include?(trim_gemfile_line(source_line)) }
|
63
|
+
gemfile_lines.select! { |x| !trim_gemfile_line(x).include?(trim_gemfile_line(podbuilder_line)) }
|
69
64
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
65
|
+
gemfile_lines.insert(0, source_line)
|
66
|
+
gemfile_lines.push(podbuilder_line)
|
67
|
+
|
68
|
+
File.write(gemfile_path, gemfile_lines.join("\n"))
|
69
|
+
|
70
|
+
Dir.chdir(PodBuilder::home)
|
71
|
+
system("bundle")
|
72
|
+
end
|
75
73
|
|
76
|
-
|
74
|
+
def self.trim_gemfile_line(line)
|
75
|
+
return line.gsub("\"", "'").gsub(" ", "")
|
77
76
|
end
|
78
77
|
end
|
79
78
|
end
|