pod-builder-y 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE.txt +13 -0
  5. data/README.md +385 -0
  6. data/Rakefile +2 -0
  7. data/bin/console +16 -0
  8. data/bin/setup +8 -0
  9. data/exe/pod_builder_y +406 -0
  10. data/lib/core_ext/string.rb +5 -0
  11. data/lib/pod_builder/analyze.rb +59 -0
  12. data/lib/pod_builder/analyzer.rb +16 -0
  13. data/lib/pod_builder/command.rb +14 -0
  14. data/lib/pod_builder/command/build.rb +228 -0
  15. data/lib/pod_builder/command/build_all.rb +15 -0
  16. data/lib/pod_builder/command/clean.rb +75 -0
  17. data/lib/pod_builder/command/deintegrate.rb +101 -0
  18. data/lib/pod_builder/command/generate_lldbinit.rb +128 -0
  19. data/lib/pod_builder/command/generate_podspec.rb +22 -0
  20. data/lib/pod_builder/command/info.rb +18 -0
  21. data/lib/pod_builder/command/init.rb +148 -0
  22. data/lib/pod_builder/command/install_sources.rb +79 -0
  23. data/lib/pod_builder/command/none.rb +16 -0
  24. data/lib/pod_builder/command/restore_all.rb +33 -0
  25. data/lib/pod_builder/command/switch.rb +224 -0
  26. data/lib/pod_builder/command/sync_podfile.rb +34 -0
  27. data/lib/pod_builder/command/update.rb +43 -0
  28. data/lib/pod_builder/configuration.rb +300 -0
  29. data/lib/pod_builder/core.rb +222 -0
  30. data/lib/pod_builder/info.rb +90 -0
  31. data/lib/pod_builder/install.rb +505 -0
  32. data/lib/pod_builder/licenses.rb +73 -0
  33. data/lib/pod_builder/podfile.rb +700 -0
  34. data/lib/pod_builder/podfile/pre_actions_swizzles.rb +84 -0
  35. data/lib/pod_builder/podfile_cp.rb +99 -0
  36. data/lib/pod_builder/podfile_item.rb +530 -0
  37. data/lib/pod_builder/podspec.rb +269 -0
  38. data/lib/pod_builder/rome/post_install.rb +446 -0
  39. data/lib/pod_builder/rome/pre_install.rb +6 -0
  40. data/lib/pod_builder/templates/build_podfile.template +70 -0
  41. data/lib/pod_builder/templates/build_podspec.template +19 -0
  42. data/lib/pod_builder/version.rb +4 -0
  43. data/pod-builder.gemspec +37 -0
  44. metadata +240 -0
@@ -0,0 +1,224 @@
1
+ require 'pod_builder/core'
2
+
3
+ module PodBuilder
4
+ module Command
5
+ class Switch
6
+ def self.call
7
+ Configuration.check_inited
8
+ PodBuilder::prepare_basepath
9
+
10
+ argument_pods = ARGV.dup
11
+
12
+ unless argument_pods.count > 0
13
+ return -1
14
+ end
15
+
16
+ pod_names_to_switch = []
17
+ argument_pods.each do |pod|
18
+ pod_name_to_switch = pod
19
+ pod_name_to_switch = Podfile::resolve_pod_names_from_podfile([pod_name_to_switch]).first
20
+ raise "\n\nDid not find pod '#{pod}'".red if pod_name_to_switch.nil?
21
+
22
+ check_not_building_subspec(pod_name_to_switch)
23
+
24
+ pod_names_to_switch.push(pod_name_to_switch)
25
+ end
26
+
27
+ if OPTIONS[:resolve_parent_dependencies] == true
28
+ install_update_repo = OPTIONS.fetch(:update_repos, true)
29
+ installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo)
30
+
31
+ all_buildable_items = Analyze.podfile_items(installer, analyzer)
32
+
33
+ pod_names_to_switch.each do |pod_name|
34
+ if pod = (all_buildable_items.detect { |t| t.name == pod_name } || all_buildable_items.detect { |t| t.root_name == pod_name })
35
+ dependencies = []
36
+ all_buildable_items.each do |pod|
37
+ if !(pod.dependency_names & pod_names_to_switch).empty?
38
+ dependencies.push(pod.root_name)
39
+ end
40
+ end
41
+ pod_names_to_switch += dependencies
42
+ end
43
+ end
44
+
45
+ pod_names_to_switch.uniq!
46
+ end
47
+
48
+ dep_pod_names_to_switch = []
49
+ if OPTIONS[:resolve_child_dependencies] == true
50
+ pod_names_to_switch.each do |pod|
51
+ podspec_path = PodBuilder::prebuiltpath("#{pod}/#{pod}.podspec")
52
+ unless File.exist?(podspec_path)
53
+ next
54
+ end
55
+
56
+ podspec_content = File.read(podspec_path)
57
+
58
+ regex = "p\\d\\.dependency '(.*)'"
59
+
60
+ podspec_content.each_line do |line|
61
+ matches = line.match(/#{regex}/)
62
+
63
+ if matches&.size == 2
64
+ dep_pod_names_to_switch.push(matches[1].split("/").first)
65
+ end
66
+ end
67
+ end
68
+
69
+ dep_pod_names_to_switch.uniq!
70
+ dep_pod_names_to_switch.reverse.each do |dep_name|
71
+ podspec_path = PodBuilder::prebuiltpath("#{dep_name}/#{dep_name}.podspec")
72
+ if File.exist?(podspec_path)
73
+ if pod = Podfile::resolve_pod_names_from_podfile([dep_name]).first
74
+ pod_names_to_switch.push(pod)
75
+ next
76
+ end
77
+ end
78
+
79
+ dep_pod_names_to_switch.delete(dep_name)
80
+ end
81
+ pod_names_to_switch = pod_names_to_switch.map { |t| t.split("/").first }.uniq
82
+ dep_pod_names_to_switch.reject { |t| pod_names_to_switch.include?(t) }
83
+ end
84
+
85
+ pod_names_to_switch.each do |pod_name_to_switch|
86
+ development_path = ""
87
+ default_entries = Hash.new
88
+
89
+ case OPTIONS[:switch_mode]
90
+ when "development"
91
+ development_path = find_podspec(pod_name_to_switch)
92
+ when "prebuilt"
93
+ podfile_path = PodBuilder::basepath("Podfile.restore")
94
+ content = File.read(podfile_path)
95
+ if !content.include?("pod '#{pod_name_to_switch}")
96
+ raise "\n\n'#{pod_name_to_switch}' does not seem to be prebuit!".red
97
+ end
98
+ when "default"
99
+ podfile_path = PodBuilder::basepath("Podfile")
100
+ content = File.read(podfile_path)
101
+
102
+ current_section = ""
103
+ content.each_line do |line|
104
+ stripped_line = line.strip
105
+ if stripped_line.start_with?("def ") || stripped_line.start_with?("target ")
106
+ current_section = line.split(" ")[1]
107
+ next
108
+ end
109
+
110
+ matches = line.gsub("\"", "'").match(/pod '(.*?)',(.*)/)
111
+ if matches&.size == 3
112
+ if matches[1].split("/").first == pod_name_to_switch
113
+ default_entries[current_section] = line
114
+ end
115
+ end
116
+ end
117
+
118
+ raise "\n\n'#{pod_name_to_switch}' not found in #{podfile_path}".red if default_entries.keys.count == 0
119
+ end
120
+
121
+ if development_path.nil?
122
+ if dep_pod_names_to_switch.include?(pod_name_to_switch)
123
+ next
124
+ else
125
+ raise "\n\nCouln't find `#{pod_name_to_switch}` sources in the following specified development pod paths:\n#{Configuration.development_pods_paths.join("\n")}\n".red
126
+ end
127
+ end
128
+
129
+ podfile_path = PodBuilder::project_path("Podfile")
130
+ content = File.read(podfile_path)
131
+
132
+ lines = []
133
+ current_section = ""
134
+ content.each_line do |line|
135
+ stripped_line = line.strip
136
+ if stripped_line.start_with?("def ") || stripped_line.start_with?("target ")
137
+ current_section = line.split(" ")[1]
138
+ end
139
+
140
+ matches = line.gsub("\"", "'").match(/pod '(.*?)',(.*)/)
141
+ if matches&.size == 3
142
+ if matches[1].split("/").first == pod_name_to_switch
143
+ case OPTIONS[:switch_mode]
144
+ when "prebuilt"
145
+ indentation = line.split("pod '").first
146
+ podspec_path = File.dirname(PodBuilder::prebuiltpath("#{pod_name_to_switch}/#{pod_name_to_switch}.podspec"))
147
+ rel_path = Pathname.new(podspec_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
148
+ prebuilt_line = "#{indentation}pod '#{matches[1]}', :path => '#{rel_path}'\n"
149
+ if line.include?("# pb<") && marker = line.split("# pb<").last
150
+ prebuilt_line = prebuilt_line.chomp("\n") + " # pb<#{marker}"
151
+ end
152
+ lines.append(prebuilt_line)
153
+ next
154
+ when "development"
155
+ indentation = line.split("pod '").first
156
+ rel_path = Pathname.new(development_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
157
+ development_line = "#{indentation}pod '#{matches[1]}', :path => '#{rel_path}'\n"
158
+ if line.include?("# pb<") && marker = line.split("# pb<").last
159
+ development_line = development_line.chomp("\n") + " # pb<#{marker}"
160
+ end
161
+
162
+ lines.append(development_line)
163
+ next
164
+ when "default"
165
+ if default_line = default_entries[current_section]
166
+ if line.include?("# pb<") && marker = line.split("# pb<").last
167
+ default_line = default_line.chomp("\n") + " # pb<#{marker}"
168
+ end
169
+ lines.append(default_line)
170
+ next
171
+ elsif
172
+ raise "\n\nLine for pod '#{matches[1]}' in section '#{current_section}' not found in PodBuilder's Podfile".red
173
+ end
174
+ else
175
+ raise "\n\nUnsupported mode '#{OPTIONS[:switch_mode]}'".red
176
+ end
177
+ end
178
+ end
179
+
180
+ lines.append(line)
181
+ end
182
+
183
+ File.write(podfile_path, lines.join)
184
+ end
185
+
186
+ Dir.chdir(PodBuilder::project_path)
187
+ bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
188
+ system("#{bundler_prefix}pod install;")
189
+
190
+ return 0
191
+ end
192
+
193
+ private
194
+
195
+ def self.find_podspec(podname)
196
+ unless Configuration.development_pods_paths.count > 0
197
+ raise "\n\nPlease add the development pods path(s) in #{Configuration.dev_pods_configuration_filename} as per documentation\n".red
198
+ end
199
+
200
+ podspec_path = nil
201
+ Configuration.development_pods_paths.each do |path|
202
+ if Pathname.new(path).relative?
203
+ path = PodBuilder::basepath(path)
204
+ end
205
+ podspec = Dir.glob(File.expand_path("#{path}/**/#{podname}*.podspec*"))
206
+ podspec.select! { |x| !x.include?("/Local Podspecs/") }
207
+ podspec.select! { |x| Dir.glob(File.join(File.dirname(x), "*")).count > 1 } # exclude podspec folder (which has one file per folder)
208
+ if podspec.count > 0
209
+ podspec_path = Pathname.new(podspec.first).dirname.to_s
210
+ break
211
+ end
212
+ end
213
+
214
+ return podspec_path
215
+ end
216
+
217
+ def self.check_not_building_subspec(pod_to_switch)
218
+ if pod_to_switch.include?("/")
219
+ raise "\n\nCan't switch subspec #{pod_to_switch} refer to podspec name.\n\nUse `pod_builder switch #{pod_to_switch.split("/").first}` instead\n\n".red
220
+ end
221
+ end
222
+ end
223
+ end
224
+ end
@@ -0,0 +1,34 @@
1
+ require 'pod_builder/core'
2
+
3
+ module PodBuilder
4
+ module Command
5
+ class SyncPodfile
6
+ def self.call
7
+ Configuration.check_inited
8
+ PodBuilder::prepare_basepath
9
+
10
+ install_update_repo = OPTIONS.fetch(:update_repos, true)
11
+ installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo)
12
+
13
+ all_buildable_items = Analyze.podfile_items(installer, analyzer)
14
+
15
+ Dir.chdir(PodBuilder::project_path)
16
+
17
+ previous_podfile_content = File.read("Podfile")
18
+ Podfile::write_prebuilt(all_buildable_items, analyzer)
19
+ updated_podfile_content = File.read("Podfile")
20
+
21
+ Licenses::write([], all_buildable_items)
22
+
23
+ if previous_podfile_content != updated_podfile_content
24
+ bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
25
+ system("#{bundler_prefix}pod install;")
26
+ end
27
+
28
+ puts "\n\n🎉 done!\n".green
29
+ return 0
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,43 @@
1
+ require 'pod_builder/core'
2
+
3
+ module PodBuilder
4
+ module Command
5
+ class Update
6
+ def self.call
7
+ Configuration.check_inited
8
+ PodBuilder::prepare_basepath
9
+
10
+ info = PodBuilder::Info.generate_info()
11
+
12
+ swift_version = PodBuilder::system_swift_version
13
+
14
+ pods_to_update = []
15
+ info.each do |pod_name, info|
16
+ if info.dig(:restore_info, :version) != info.dig(:prebuilt_info, :version)
17
+ pods_to_update.append(pod_name)
18
+ end
19
+ if (prebuilt_swift_version = info.dig(:prebuilt_info, :swift_version)) && prebuilt_swift_version != swift_version
20
+ pods_to_update.append(pod_name)
21
+ end
22
+ end
23
+
24
+ pods_to_update.map! { |x| x.split("/").first }.uniq!
25
+
26
+ unless pods_to_update.count > 0
27
+ puts "Prebuilt items in sync!\n".green
28
+ return 0
29
+ end
30
+ if OPTIONS.has_key?(:dry_run)
31
+ puts "`#{pods_to_update.join("`, `")}` need to be rebuilt!\n".red
32
+ return -2
33
+ end
34
+
35
+ ARGV.clear
36
+ pods_to_update.each { |x| ARGV << x }
37
+
38
+ # OPTIONS[:resolve_parent_dependencies] = true
39
+ return PodBuilder::Command::Build.call
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,300 @@
1
+ require 'json'
2
+ require 'tmpdir'
3
+
4
+ module PodBuilder
5
+ class Configuration
6
+ # Remember to update README.md accordingly
7
+ DEFAULT_BUILD_SETTINGS = {
8
+ "ENABLE_BITCODE" => "NO",
9
+ "GCC_OPTIMIZATION_LEVEL" => "s",
10
+ "SWIFT_OPTIMIZATION_LEVEL" => "-Osize",
11
+ "SWIFT_COMPILATION_MODE" => "wholemodule",
12
+ "CODE_SIGN_IDENTITY" => "",
13
+ "CODE_SIGNING_REQUIRED" => "NO",
14
+ "CODE_SIGN_ENTITLEMENTS" => "",
15
+ "CODE_SIGNING_ALLOWED" => "NO"
16
+ }.freeze
17
+ DEFAULT_SPEC_OVERRIDE = {
18
+ "Google-Mobile-Ads-SDK" => {
19
+ "module_name": "GoogleMobileAds"
20
+ },
21
+ "glog" => {
22
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
23
+ },
24
+ "DoubleConversion" => {
25
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
26
+ },
27
+ "Folly" => {
28
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
29
+ },
30
+ "Flipper-DoubleConversion" => {
31
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
32
+ },
33
+ "Flipper-Folly" => {
34
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
35
+ }
36
+ }.freeze
37
+ DEFAULT_BUILD_SETTINGS_OVERRIDES = {
38
+ "SBTUITestTunnelClient" => {
39
+ "ENABLE_BITCODE": "NO"
40
+ }
41
+ }.freeze
42
+ DEFAULT_SKIP_PODS = ["GoogleMaps", "React-RCTFabric", "React-Core", "React-CoreModules"] # Not including React-RCTNetwork might loose some debug warnings
43
+
44
+ DEFAULT_FORCE_PREBUILD_PODS = []
45
+ DEFAULT_BUILD_SYSTEM = "Latest".freeze # either Latest (New build system) or Legacy (Standard build system)
46
+ DEFAULT_LIBRARY_EVOLUTION_SUPPORT = false
47
+ DEFAULT_PLATFORMS = ["iphoneos", "iphonesimulator", "appletvos", "appletvsimulator"].freeze
48
+ DEFAULT_BUILD_USING_REPO_PATHS = false
49
+ DEFAULT_BUILD_XCFRAMEWORKS = false
50
+
51
+ private_constant :DEFAULT_BUILD_SETTINGS
52
+ private_constant :DEFAULT_BUILD_SETTINGS_OVERRIDES
53
+ private_constant :DEFAULT_BUILD_SYSTEM
54
+ private_constant :DEFAULT_LIBRARY_EVOLUTION_SUPPORT
55
+
56
+ class <<self
57
+ attr_accessor :allow_building_development_pods
58
+ attr_accessor :build_settings
59
+ attr_accessor :build_settings_overrides
60
+ attr_accessor :build_system
61
+ attr_accessor :library_evolution_support
62
+ attr_accessor :base_path
63
+ attr_accessor :spec_overrides
64
+ attr_accessor :skip_licenses
65
+ attr_accessor :skip_pods
66
+ attr_accessor :force_prebuild_pods
67
+ attr_accessor :license_filename
68
+ attr_accessor :development_pods_paths
69
+ attr_accessor :build_base_path
70
+ attr_accessor :build_path
71
+ attr_accessor :configuration_filename
72
+ attr_accessor :dev_pods_configuration_filename
73
+ attr_accessor :project_name
74
+ attr_accessor :restore_enabled
75
+ attr_accessor :prebuilt_info_filename
76
+ attr_accessor :lockfile_name
77
+ attr_accessor :lockfile_path
78
+ attr_accessor :use_bundler
79
+ attr_accessor :deterministic_build
80
+ attr_accessor :supported_platforms
81
+ attr_accessor :build_using_repo_paths
82
+ attr_accessor :react_native_project
83
+ attr_accessor :lldbinit_name
84
+ attr_accessor :build_xcframeworks
85
+ end
86
+
87
+ @allow_building_development_pods = false
88
+ @build_settings = DEFAULT_BUILD_SETTINGS
89
+ @build_settings_overrides = DEFAULT_BUILD_SETTINGS_OVERRIDES
90
+ @build_system = DEFAULT_BUILD_SYSTEM
91
+ @library_evolution_support = DEFAULT_LIBRARY_EVOLUTION_SUPPORT
92
+ @base_path = "PodBuilder" # Not nice. This value is used only for initial initization. Once config is loaded it will be an absolute path. FIXME
93
+ @spec_overrides = DEFAULT_SPEC_OVERRIDE
94
+ @skip_licenses = []
95
+ @skip_pods = DEFAULT_SKIP_PODS
96
+ @force_prebuild_pods = DEFAULT_FORCE_PREBUILD_PODS
97
+ @license_filename = "Pods-acknowledgements"
98
+ @development_pods_paths = []
99
+ @build_base_path = "/tmp/pod_builder".freeze
100
+ @build_path = build_base_path
101
+ @configuration_filename = "PodBuilder.json".freeze
102
+ @dev_pods_configuration_filename = "PodBuilderDevPodsPaths.json".freeze
103
+ @project_name = ""
104
+ @restore_enabled = true
105
+ @prebuilt_info_filename = "PodBuilder.json"
106
+ @lockfile_name = "PodBuilder.lock"
107
+ @lockfile_path = "/tmp/#{lockfile_name}"
108
+ @lldbinit_name = "lldbinit".freeze
109
+
110
+ @use_bundler = false
111
+ @deterministic_build = false
112
+
113
+ @supported_platforms = DEFAULT_PLATFORMS
114
+ @build_using_repo_paths = DEFAULT_BUILD_USING_REPO_PATHS
115
+ @react_native_project = false
116
+
117
+ @build_xcframeworks = DEFAULT_BUILD_XCFRAMEWORKS
118
+
119
+ def self.check_inited
120
+ raise "\n\nNot inited, run `pod_builder init`\n".red if podbuilder_path.nil?
121
+ end
122
+
123
+ def self.exists
124
+ return !config_path.nil? && File.exist?(config_path)
125
+ end
126
+
127
+ def self.load
128
+ unless podbuilder_path
129
+ return
130
+ end
131
+
132
+ Configuration.base_path = podbuilder_path
133
+
134
+ if exists
135
+ begin
136
+ json = JSON.parse(File.read(config_path))
137
+ rescue => exception
138
+ raise "\n\n#{File.basename(config_path)} is an invalid JSON\n".red
139
+ end
140
+
141
+ if value = json["spec_overrides"]
142
+ if value.is_a?(Hash) && value.keys.count > 0
143
+ Configuration.spec_overrides = value
144
+ end
145
+ end
146
+ if value = json["skip_licenses"]
147
+ if value.is_a?(Array)
148
+ Configuration.skip_licenses = value
149
+ end
150
+ end
151
+ if value = json["skip_pods"]
152
+ if value.is_a?(Array)
153
+ Configuration.skip_pods = value
154
+ end
155
+ end
156
+ if value = json["force_prebuild_pods"]
157
+ if value.is_a?(Array)
158
+ Configuration.force_prebuild_pods = value
159
+ end
160
+ end
161
+ if value = json["build_settings"]
162
+ if value.is_a?(Hash) && value.keys.count > 0
163
+ Configuration.build_settings = value
164
+ end
165
+ end
166
+ if value = json["build_settings_overrides"]
167
+ if value.is_a?(Hash) && value.keys.count > 0
168
+ Configuration.build_settings_overrides = value
169
+ end
170
+ end
171
+ if value = json["build_system"]
172
+ if value.is_a?(String) && ["Latest", "Legacy"].include?(value)
173
+ Configuration.build_system = value
174
+ end
175
+ end
176
+ if value = json["library_evolution_support"]
177
+ if [TrueClass, FalseClass].include?(value.class)
178
+ Configuration.library_evolution_support = value
179
+ end
180
+ end
181
+ if value = json["license_filename"]
182
+ if value.is_a?(String) && value.length > 0
183
+ Configuration.license_filename = value
184
+ end
185
+ end
186
+ if value = json["project_name"]
187
+ if value.is_a?(String) && value.length > 0
188
+ Configuration.project_name = value
189
+ end
190
+ end
191
+ if value = json["restore_enabled"]
192
+ if [TrueClass, FalseClass].include?(value.class)
193
+ Configuration.restore_enabled = value
194
+ end
195
+ end
196
+ if value = json["allow_building_development_pods"]
197
+ if [TrueClass, FalseClass].include?(value.class)
198
+ Configuration.allow_building_development_pods = value
199
+ end
200
+ end
201
+ if value = json["use_bundler"]
202
+ if [TrueClass, FalseClass].include?(value.class)
203
+ Configuration.use_bundler = value
204
+ end
205
+ end
206
+ if value = json["deterministic_build"]
207
+ if [TrueClass, FalseClass].include?(value.class)
208
+ Configuration.deterministic_build = value
209
+ end
210
+ end
211
+ if value = json["build_using_repo_paths"]
212
+ if [TrueClass, FalseClass].include?(value.class)
213
+ Configuration.build_using_repo_paths = value
214
+ end
215
+ end
216
+ if value = json["react_native_project"]
217
+ if [TrueClass, FalseClass].include?(value.class)
218
+ Configuration.react_native_project = value
219
+ end
220
+ end
221
+ if value = json["build_xcframeworks"]
222
+ if [TrueClass, FalseClass].include?(value.class)
223
+ Configuration.build_xcframeworks = value
224
+ end
225
+ end
226
+
227
+ Configuration.build_settings.freeze
228
+
229
+ sanity_check()
230
+ end
231
+
232
+ dev_pods_configuration_path = File.join(Configuration.base_path, Configuration.dev_pods_configuration_filename)
233
+
234
+ if File.exist?(dev_pods_configuration_path)
235
+ begin
236
+ json = JSON.parse(File.read(dev_pods_configuration_path))
237
+ rescue => exception
238
+ raise "\n\n#{File.basename(dev_pods_configuration_path)} is an invalid JSON\n".red
239
+ end
240
+
241
+ Configuration.development_pods_paths = json || []
242
+ Configuration.development_pods_paths.freeze
243
+ end
244
+
245
+ if !deterministic_build
246
+ build_path = "#{build_base_path}#{(Time.now.to_f * 1000).to_i}"
247
+ lockfile_path = File.join(PodBuilder::home, lockfile_name)
248
+ end
249
+ end
250
+
251
+ def self.write
252
+ config = {}
253
+
254
+ config["project_name"] = Configuration.project_name
255
+ config["spec_overrides"] = Configuration.spec_overrides
256
+ config["skip_licenses"] = Configuration.skip_licenses
257
+ config["skip_pods"] = Configuration.skip_pods
258
+ config["force_prebuild_pods"] = Configuration.force_prebuild_pods
259
+ config["build_settings"] = Configuration.build_settings
260
+ config["build_settings_overrides"] = Configuration.build_settings_overrides
261
+ config["build_system"] = Configuration.build_system
262
+ config["library_evolution_support"] = Configuration.library_evolution_support
263
+ config["license_filename"] = Configuration.license_filename
264
+ config["restore_enabled"] = Configuration.restore_enabled
265
+ config["allow_building_development_pods"] = Configuration.allow_building_development_pods
266
+ config["use_bundler"] = Configuration.use_bundler
267
+ config["deterministic_build"] = Configuration.deterministic_build
268
+ config["build_using_repo_paths"] = Configuration.build_using_repo_paths
269
+ config["react_native_project"] = Configuration.react_native_project
270
+
271
+ File.write(config_path, JSON.pretty_generate(config))
272
+ end
273
+
274
+ private
275
+
276
+ def self.sanity_check
277
+ Configuration.skip_pods.each do |pod|
278
+ if Configuration.force_prebuild_pods.include?(pod)
279
+ puts "PodBuilder.json contains '#{pod}' both in `force_prebuild_pods` and `skip_pods`. Will force prebuilding.".yellow
280
+ end
281
+ end
282
+ end
283
+
284
+ def self.config_path
285
+ unless path = podbuilder_path
286
+ return nil
287
+ end
288
+
289
+ return File.join(path, Configuration.configuration_filename)
290
+ end
291
+
292
+ def self.podbuilder_path
293
+ paths = Dir.glob("#{PodBuilder::home}/**/.pod_builder")
294
+ paths.reject! { |t| t.match(/pod-builder-.*\/Example\/#{File.basename(Configuration.base_path)}\/\.pod_builder$/i) }
295
+ raise "\n\nToo many .pod_builder found `#{paths.join("\n")}`\n".red if paths.count > 1
296
+
297
+ return paths.count > 0 ? File.dirname(paths.first) : nil
298
+ end
299
+ end
300
+ end