pod-builder 1.9.2 → 2.0.0.beta.21
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/.gitignore +9 -0
- data/Example/PodBuilder/.gitignore +6 -0
- data/Example/PodBuilder/.pod_builder/pod_builder +0 -0
- data/Example/{Frameworks → PodBuilder}/PodBuilder.json +10 -4
- data/Example/PodBuilder/Podfile +23 -0
- data/Example/PodBuilder/Podfile.restore +40 -0
- data/Example/PodBuilderExample.xcodeproj/project.pbxproj +3 -8
- data/Example/{PodBuilderExample.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist → PodBuilderExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist} +2 -8
- data/Example/PodBuilderExample/AppDelegate.swift +4 -0
- data/Example/Podfile +42 -1
- data/Example/Podfile.lock +426 -7
- data/Example/Pods-acknowledgements.md +210 -0
- data/Example/Pods-acknowledgements.plist +206 -0
- data/README.md +50 -13
- data/exe/pod_builder +39 -28
- data/lib/pod_builder/analyze.rb +32 -7
- data/lib/pod_builder/analyzer.rb +16 -0
- data/lib/pod_builder/command/build.rb +44 -161
- data/lib/pod_builder/command/build_all.rb +2 -2
- data/lib/pod_builder/command/clean.rb +34 -55
- data/lib/pod_builder/command/clear_lldbinit.rb +7 -3
- data/lib/pod_builder/command/deintegrate.rb +29 -7
- data/lib/pod_builder/command/generate_lfs.rb +3 -3
- data/lib/pod_builder/command/generate_podspec.rb +3 -2
- data/lib/pod_builder/command/info.rb +1 -1
- data/lib/pod_builder/command/init.rb +37 -14
- data/lib/pod_builder/command/install_sources.rb +21 -14
- data/lib/pod_builder/command/none.rb +2 -2
- data/lib/pod_builder/command/restore_all.rb +4 -4
- data/lib/pod_builder/command/switch.rb +137 -95
- data/lib/pod_builder/command/sync_podfile.rb +5 -3
- data/lib/pod_builder/command/update.rb +5 -6
- data/lib/pod_builder/command/update_lldbinit.rb +11 -9
- data/lib/pod_builder/configuration.rb +88 -13
- data/lib/pod_builder/core.rb +93 -12
- data/lib/pod_builder/info.rb +32 -98
- data/lib/pod_builder/install.rb +255 -195
- data/lib/pod_builder/licenses.rb +4 -4
- data/lib/pod_builder/podfile.rb +287 -73
- data/lib/pod_builder/podfile/post_actions.rb +9 -15
- data/lib/pod_builder/podfile_cp.rb +93 -0
- data/lib/pod_builder/podfile_item.rb +181 -82
- data/lib/pod_builder/podspec.rb +144 -135
- data/lib/pod_builder/rome/post_install.rb +240 -0
- data/lib/pod_builder/rome/pre_install.rb +6 -0
- data/lib/pod_builder/templates/build_podfile.template +3 -3
- data/lib/pod_builder/version.rb +1 -1
- data/pod-builder.gemspec +4 -4
- metadata +34 -65
- data/Example/Pods/Alamofire/LICENSE +0 -19
- data/Example/Pods/Alamofire/README.md +0 -242
- data/Example/Pods/Alamofire/Source/AFError.swift +0 -460
- data/Example/Pods/Alamofire/Source/Alamofire.swift +0 -465
- data/Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift +0 -37
- data/Example/Pods/Alamofire/Source/MultipartFormData.swift +0 -580
- data/Example/Pods/Alamofire/Source/NetworkReachabilityManager.swift +0 -233
- data/Example/Pods/Alamofire/Source/Notifications.swift +0 -55
- data/Example/Pods/Alamofire/Source/ParameterEncoding.swift +0 -483
- data/Example/Pods/Alamofire/Source/Request.swift +0 -654
- data/Example/Pods/Alamofire/Source/Response.swift +0 -567
- data/Example/Pods/Alamofire/Source/ResponseSerialization.swift +0 -715
- data/Example/Pods/Alamofire/Source/Result.swift +0 -300
- data/Example/Pods/Alamofire/Source/ServerTrustPolicy.swift +0 -307
- data/Example/Pods/Alamofire/Source/SessionDelegate.swift +0 -725
- data/Example/Pods/Alamofire/Source/SessionManager.swift +0 -896
- data/Example/Pods/Alamofire/Source/TaskDelegate.swift +0 -466
- data/Example/Pods/Alamofire/Source/Timeline.swift +0 -136
- data/Example/Pods/Alamofire/Source/Validation.swift +0 -315
- data/Example/Pods/Manifest.lock +0 -16
- data/Example/Pods/Pods.xcodeproj/project.pbxproj +0 -673
- data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Alamofire.xcscheme +0 -60
- data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Pods-PodBuilderExample.xcscheme +0 -60
- data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist +0 -21
- data/Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m +0 -5
- data/Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch +0 -12
- data/Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h +0 -16
- data/Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap +0 -6
- data/Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig +0 -9
- data/Example/Pods/Target Support Files/Alamofire/Info.plist +0 -26
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Info.plist +0 -26
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.markdown +0 -26
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.plist +0 -58
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-dummy.m +0 -5
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-frameworks.sh +0 -153
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-resources.sh +0 -118
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-umbrella.h +0 -16
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.debug.xcconfig +0 -11
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.modulemap +0 -6
- data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.release.xcconfig +0 -11
- data/lib/pod_builder/cocoapods/specification.rb +0 -27
data/lib/pod_builder/licenses.rb
CHANGED
@@ -12,19 +12,19 @@
|
|
12
12
|
|
13
13
|
if current_licenses.count > 0
|
14
14
|
licenses_header = current_licenses.shift
|
15
|
-
raise "
|
15
|
+
raise "\n\nUnexpected license found in header".red if licenses_header.has_key?("License")
|
16
16
|
end
|
17
17
|
if current_licenses.count > 0
|
18
18
|
license_footer = current_licenses.pop
|
19
|
-
raise "
|
19
|
+
raise "\n\nUnexpected license found in footer".red if license_footer.has_key?("License")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
if licenses.count > 0
|
24
24
|
licenses_header = licenses.shift
|
25
|
-
raise "
|
25
|
+
raise "\n\nUnexpected license found in header".red if licenses_header.has_key?("License")
|
26
26
|
license_footer = licenses.pop
|
27
|
-
raise "
|
27
|
+
raise "\n\nUnexpected license found in footer".red if license_footer.has_key?("License")
|
28
28
|
|
29
29
|
lincenses_titles = licenses.map { |x| x["Title"] }
|
30
30
|
current_licenses.select! { |x| !lincenses_titles.include?(x["Title"]) }
|
data/lib/pod_builder/podfile.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
require 'json'
|
1
2
|
module PodBuilder
|
2
3
|
class Podfile
|
3
4
|
PODBUILDER_LOCK_ACTION = ["raise \"\\n🚨 Do not launch 'pod install' manually, use `pod_builder` instead!\\n\" if !File.exist?('pod_builder.lock')"].freeze
|
4
|
-
POST_INSTALL_ACTIONS = ["require 'pod_builder/podfile/post_actions'", "PodBuilder::Podfile::
|
5
|
+
POST_INSTALL_ACTIONS = ["require 'pod_builder/podfile/post_actions'", "PodBuilder::Podfile::pod_builder_post_process"].freeze
|
5
6
|
|
6
7
|
PRE_INSTALL_ACTIONS = ["Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_duplicate_framework_and_library_names) {}"].freeze
|
7
8
|
private_constant :PRE_INSTALL_ACTIONS
|
8
9
|
|
9
|
-
def self.from_podfile_items(items, analyzer)
|
10
|
-
raise "
|
10
|
+
def self.from_podfile_items(items, analyzer, build_configuration)
|
11
|
+
raise "\n\nno items".red unless items.count > 0
|
11
12
|
|
12
13
|
sources = analyzer.sources
|
13
14
|
|
@@ -15,14 +16,16 @@ module PodBuilder
|
|
15
16
|
podfile = File.read("#{cwd}/templates/build_podfile.template")
|
16
17
|
|
17
18
|
platform = analyzer.instance_variable_get("@result").targets.first.platform
|
19
|
+
|
20
|
+
install_using_frameworks = analyzer.podfile.root_target_definitions.map(&:uses_frameworks?).uniq.first
|
21
|
+
podfile.sub!("%%%use_frameworks%%%", install_using_frameworks ? "use_frameworks!" : "")
|
22
|
+
|
18
23
|
podfile.sub!("%%%platform_name%%%", platform.name.to_s)
|
19
24
|
podfile.sub!("%%%deployment_version%%%", platform.deployment_target.version)
|
20
25
|
|
21
26
|
podfile.sub!("%%%sources%%%", sources.map { |x| "source '#{x.url}'" }.join("\n"))
|
22
27
|
|
23
|
-
|
24
|
-
raise "Found different build configurations in #{items}" if build_configurations.count != 1
|
25
|
-
podfile.sub!("%%%build_configuration%%%", build_configurations.first.capitalize)
|
28
|
+
podfile.sub!("%%%build_configuration%%%", build_configuration.capitalize)
|
26
29
|
|
27
30
|
podfile_build_settings = ""
|
28
31
|
|
@@ -35,10 +38,27 @@ module PodBuilder
|
|
35
38
|
|
36
39
|
# These settings need to be set as is to properly build frameworks
|
37
40
|
build_settings['SWIFT_COMPILATION_MODE'] = 'wholemodule'
|
38
|
-
build_settings['CLANG_ENABLE_MODULE_DEBUGGING'] = 'NO'
|
39
41
|
build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
|
40
42
|
build_settings['DEBUG_INFORMATION_FORMAT'] = "dwarf-with-dsym"
|
41
43
|
|
44
|
+
build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = platform.deployment_target.version # Fix compilation warnings on Xcode 12
|
45
|
+
|
46
|
+
# Don't store .pcm info in binary, see https://forums.swift.org/t/swift-behavior-of-gmodules-and-dsyms/23211/3
|
47
|
+
build_settings['CLANG_ENABLE_MODULE_DEBUGGING'] = 'NO'
|
48
|
+
build_settings['OTHER_SWIFT_FLAGS'] = "-Xfrontend -no-clang-module-breadcrumbs"
|
49
|
+
|
50
|
+
# Improve compile speed
|
51
|
+
build_settings['COMPILER_INDEX_STORE_ENABLE'] = 'NO'
|
52
|
+
build_settings['SWIFT_INDEX_STORE_ENABLE'] = 'NO'
|
53
|
+
build_settings['MTL_ENABLE_INDEX_STORE'] = 'NO'
|
54
|
+
|
55
|
+
if Configuration.build_system == "Legacy"
|
56
|
+
build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = "NO"
|
57
|
+
raise "\n\nCan't enable library evolution support with legacy build system!".red if Configuration.library_evolution_support
|
58
|
+
elsif Configuration.library_evolution_support
|
59
|
+
build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = "YES"
|
60
|
+
end
|
61
|
+
|
42
62
|
build_settings['SWIFT_VERSION'] = item_build_settings["SWIFT_VERSION"] || item.swift_version || project_swift_version(analyzer)
|
43
63
|
|
44
64
|
item_build_settings.each do |k, v|
|
@@ -51,7 +71,7 @@ module PodBuilder
|
|
51
71
|
if x.split("/").first == item.root_name
|
52
72
|
next nil # remove dependency to parent spec
|
53
73
|
end
|
54
|
-
if overridded_module_name = Configuration.spec_overrides.fetch(x, {})["module_name"]
|
74
|
+
if overridded_module_name = Configuration.spec_overrides.fetch(x, {})["module_name"] # this might no longer be needed after
|
55
75
|
next overridded_module_name
|
56
76
|
end
|
57
77
|
}.compact
|
@@ -100,9 +120,6 @@ module PodBuilder
|
|
100
120
|
}
|
101
121
|
end
|
102
122
|
|
103
|
-
multiple_buildable_items = podfile_items.uniq { |t| t.root_name }
|
104
|
-
buildable_items = podfile_items.reject { |t| multiple_buildable_items.map(&:root_name).include?(t.root_name) && t.is_external == false }
|
105
|
-
|
106
123
|
result_targets = analyzer.instance_variable_get("@result").targets.map(&:name)
|
107
124
|
podfile_content = ["# Autogenerated by PodBuilder (https://github.com/Subito-it/PodBuilder)", "# Please don't modify this file", "\n"]
|
108
125
|
podfile_content += analyzer.podfile.sources.map { |x| "source '#{x}'" }
|
@@ -128,7 +145,7 @@ module PodBuilder
|
|
128
145
|
|
129
146
|
specifications.each do |spec|
|
130
147
|
item = podfile_items.detect { |x| x.name == spec.name }
|
131
|
-
if
|
148
|
+
if podfile_items.map(&:name).include?(spec.name)
|
132
149
|
podfile_content.push("\t#{item.entry}")
|
133
150
|
end
|
134
151
|
end
|
@@ -139,9 +156,16 @@ module PodBuilder
|
|
139
156
|
File.write(podfile_restore_path, podfile_content.join("\n"))
|
140
157
|
end
|
141
158
|
|
142
|
-
def self.write_prebuilt(all_buildable_items, analyzer)
|
159
|
+
def self.write_prebuilt(all_buildable_items, analyzer)
|
160
|
+
if Configuration.react_native_project
|
161
|
+
return write_prebuilt_react_native(all_buildable_items, analyzer)
|
162
|
+
end
|
163
|
+
|
143
164
|
puts "Updating Application Podfile".yellow
|
144
165
|
|
166
|
+
explicit_deps = analyzer.explicit_pods()
|
167
|
+
explicit_deps.map! { |t| all_buildable_items.detect { |x| x.name == t.name } }
|
168
|
+
explicit_deps.uniq!
|
145
169
|
podbuilder_podfile_path = PodBuilder::basepath("Podfile")
|
146
170
|
rel_path = Pathname.new(podbuilder_podfile_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
|
147
171
|
|
@@ -156,22 +180,33 @@ module PodBuilder
|
|
156
180
|
next
|
157
181
|
end
|
158
182
|
|
159
|
-
if pod_name = pod_definition_in(line, true)
|
183
|
+
if pod_name = pod_definition_in(line, true)
|
160
184
|
if podfile_item = all_buildable_items.detect { |x| x.name == pod_name }
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
end
|
171
|
-
else
|
172
|
-
prebuilt_lines.push("#{line.detect_indentation}#{podfile_item.prebuilt_entry}\n")
|
185
|
+
marker = podfile_item.prebuilt_marker()
|
186
|
+
|
187
|
+
non_explicit_dependencies = podfile_item.recursive_dependencies(all_buildable_items) - explicit_deps
|
188
|
+
non_explicit_dependencies_root_names = non_explicit_dependencies.map(&:root_name).uniq.filter { |t| t != podfile_item.root_name }
|
189
|
+
non_explicit_dependencies = non_explicit_dependencies_root_names.map { |x|
|
190
|
+
if item = all_buildable_items.detect { |t| x == t.name }
|
191
|
+
item
|
192
|
+
else
|
193
|
+
item = all_buildable_items.detect { |t| x == t.root_name }
|
173
194
|
end
|
195
|
+
}.compact
|
196
|
+
|
197
|
+
non_explicit_dependencies.each do |dep|
|
198
|
+
dep_item = all_buildable_items.detect { |x| x.name == dep.name }
|
199
|
+
|
200
|
+
if File.exist?(dep_item.prebuilt_podspec_path) && !dep_item.is_prebuilt
|
201
|
+
pod_name = dep_item.prebuilt_entry(false)
|
202
|
+
prebuilt_lines.push("#{line.detect_indentation}#{pod_name}#{marker}\n")
|
203
|
+
end
|
204
|
+
|
205
|
+
explicit_deps.push(dep)
|
206
|
+
end
|
174
207
|
|
208
|
+
if File.exist?(podfile_item.prebuilt_podspec_path) && !podfile_item.is_prebuilt
|
209
|
+
prebuilt_lines.push("#{line.detect_indentation}#{podfile_item.prebuilt_entry}\n")
|
175
210
|
next
|
176
211
|
end
|
177
212
|
end
|
@@ -180,20 +215,45 @@ module PodBuilder
|
|
180
215
|
prebuilt_lines.push(line)
|
181
216
|
end
|
182
217
|
|
218
|
+
podfile_content = prebuilt_lines.join
|
219
|
+
|
220
|
+
podfile_content = Podfile.update_path_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
221
|
+
podfile_content = Podfile.update_project_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
222
|
+
podfile_content = Podfile.update_require_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
223
|
+
|
224
|
+
podfile_content = add_pre_install_actions(podfile_content)
|
225
|
+
podfile_content = add_post_install_checks(podfile_content)
|
226
|
+
|
183
227
|
project_podfile_path = PodBuilder::project_path("Podfile")
|
184
|
-
File.write(project_podfile_path,
|
185
|
-
|
186
|
-
|
228
|
+
File.write(project_podfile_path, podfile_content)
|
229
|
+
end
|
230
|
+
|
231
|
+
def self.write_prebuilt_react_native(all_buildable_items, analyzer)
|
232
|
+
puts "Updating Application Podfile".yellow
|
233
|
+
|
234
|
+
podbuilder_podfile_path = PodBuilder::basepath("Podfile")
|
235
|
+
rel_path = Pathname.new(podbuilder_podfile_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
|
236
|
+
|
237
|
+
podfile_content = ["# Autogenerated by PodBuilder (https://github.com/Subito-it/PodBuilder)\n", "# Any change to this file should be done on #{rel_path}\n", "\n"].join
|
238
|
+
podfile_content += analyzer.podfile.pb_to_s(all_buildable_items)
|
187
239
|
|
188
|
-
|
189
|
-
|
240
|
+
podfile_content = Podfile.update_path_entries(podfile_content, PodfileCP.method(:podfile_path_transform))
|
241
|
+
podfile_content = Podfile.update_project_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
242
|
+
podfile_content = Podfile.update_require_entries(podfile_content, Podfile.method(:podfile_path_transform))
|
243
|
+
|
244
|
+
podfile_content = add_pre_install_actions(podfile_content)
|
245
|
+
podfile_content = add_post_install_checks(podfile_content)
|
246
|
+
|
247
|
+
project_podfile_path = PodBuilder::project_path("Podfile")
|
248
|
+
File.write(project_podfile_path, podfile_content)
|
190
249
|
end
|
191
250
|
|
192
251
|
def self.install
|
193
252
|
puts "Running pod install".yellow
|
194
253
|
|
195
254
|
Dir.chdir(PodBuilder::project_path) do
|
196
|
-
|
255
|
+
bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
|
256
|
+
system("#{bundler_prefix}pod install;")
|
197
257
|
end
|
198
258
|
end
|
199
259
|
|
@@ -202,10 +262,6 @@ module PodBuilder
|
|
202
262
|
return stripped_line.gsub("\"", "'").gsub(" ", "").gsub("\t", "").gsub("\n", "")
|
203
263
|
end
|
204
264
|
|
205
|
-
def self.add_install_block(podfile_path)
|
206
|
-
add(PODBUILDER_LOCK_ACTION, "pre_install", podfile_path)
|
207
|
-
end
|
208
|
-
|
209
265
|
def self.pod_definition_in(line, include_commented)
|
210
266
|
stripped_line = strip_line(line)
|
211
267
|
matches = stripped_line.match(/(^pod')(.*?)(')/)
|
@@ -249,6 +305,8 @@ module PodBuilder
|
|
249
305
|
return nil
|
250
306
|
end
|
251
307
|
|
308
|
+
puts "Checking Podfile.restore".yellow
|
309
|
+
|
252
310
|
podfile_restore_path = PodBuilder::basepath("Podfile.restore")
|
253
311
|
unless File.exist?(podfile_restore_path)
|
254
312
|
return
|
@@ -289,16 +347,62 @@ module PodBuilder
|
|
289
347
|
|
290
348
|
if stripped_line.match(/(pod')(.*?)(')/) != nil
|
291
349
|
starting_def_found = stripped_line.start_with?("def") && (line.match("\s*def\s") != nil)
|
292
|
-
raise "
|
350
|
+
raise "\n\nUnsupported single line def/pod. `def` and `pod` shouldn't be on the same line, please modify the following line:\n#{line}".red if starting_def_found
|
293
351
|
end
|
294
352
|
end
|
295
353
|
end
|
296
354
|
|
355
|
+
def self.resolve_pod_names(names, all_buildable_items)
|
356
|
+
resolved_names = []
|
357
|
+
|
358
|
+
names.each do |name|
|
359
|
+
if item = all_buildable_items.detect { |t| t.root_name.downcase == name.downcase }
|
360
|
+
resolved_names.push(item.root_name)
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
return resolved_names.uniq
|
365
|
+
end
|
366
|
+
|
367
|
+
def self.resolve_pod_names_from_podfile(names)
|
368
|
+
resolved_names = []
|
369
|
+
|
370
|
+
# resolve potentially wrong pod name case
|
371
|
+
podfile_path = PodBuilder::basepath("Podfile")
|
372
|
+
content = File.read(podfile_path)
|
373
|
+
|
374
|
+
current_section = ""
|
375
|
+
content.each_line do |line|
|
376
|
+
matches = line.gsub("\"", "'").match(/pod '(.*?)'/)
|
377
|
+
if matches&.size == 2
|
378
|
+
if resolved_name = names.detect { |t| matches[1].split("/").first.downcase == t.downcase }
|
379
|
+
resolved_names.push(matches[1].split("/").first)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
resolved_names.uniq
|
385
|
+
end
|
386
|
+
|
297
387
|
private
|
298
388
|
|
299
|
-
def self.
|
300
|
-
|
389
|
+
def self.podfile_path_transform(path)
|
390
|
+
use_absolute_paths = false
|
391
|
+
podfile_path = PodBuilder::project_path("Podfile")
|
392
|
+
original_basepath = PodBuilder::basepath
|
301
393
|
|
394
|
+
podfile_base_path = Pathname.new(File.dirname(podfile_path))
|
395
|
+
|
396
|
+
original_path = Pathname.new(File.join(original_basepath, path))
|
397
|
+
replace_path = original_path.relative_path_from(podfile_base_path)
|
398
|
+
if use_absolute_paths
|
399
|
+
replace_path = replace_path.expand_path(podfile_base_path)
|
400
|
+
end
|
401
|
+
|
402
|
+
return replace_path
|
403
|
+
end
|
404
|
+
|
405
|
+
def self.indentation_from_string(content)
|
302
406
|
lines = content.split("\n").select { |x| !x.empty? }
|
303
407
|
|
304
408
|
if lines.count > 2
|
@@ -319,13 +423,13 @@ module PodBuilder
|
|
319
423
|
def self.project_swift_version(analyzer)
|
320
424
|
swift_versions = analyzer.instance_variable_get("@result").targets.map { |x| x.target_definition.swift_version }.compact.uniq
|
321
425
|
|
322
|
-
raise "
|
426
|
+
raise "\n\nFound different Swift versions in targets. Expecting one, got `#{swift_versions}`".red if swift_versions.count > 1
|
323
427
|
|
324
428
|
return swift_versions.first || PodBuilder::system_swift_version
|
325
429
|
end
|
326
430
|
|
327
431
|
def self.podfile_items_at(podfile_path, include_prebuilt = false)
|
328
|
-
raise "
|
432
|
+
raise "\n\nExpecting basepath folder!".red if !File.exist?(PodBuilder::basepath("Podfile"))
|
329
433
|
|
330
434
|
if File.basename(podfile_path) != "Podfile"
|
331
435
|
File.rename(PodBuilder::basepath("Podfile"), PodBuilder::basepath("Podfile.tmp"))
|
@@ -354,18 +458,20 @@ module PodBuilder
|
|
354
458
|
return buildable_items
|
355
459
|
end
|
356
460
|
|
357
|
-
def self.
|
358
|
-
add(
|
461
|
+
def self.add_install_block(podfile_content)
|
462
|
+
return add(PODBUILDER_LOCK_ACTION, "pre_install", podfile_content)
|
359
463
|
end
|
360
464
|
|
361
|
-
def self.
|
362
|
-
add(
|
465
|
+
def self.add_pre_install_actions(podfile_content)
|
466
|
+
return add(PRE_INSTALL_ACTIONS + [" "], "pre_install", podfile_content)
|
363
467
|
end
|
364
468
|
|
365
|
-
def self.
|
366
|
-
|
469
|
+
def self.add_post_install_checks(podfile_content)
|
470
|
+
return add(POST_INSTALL_ACTIONS + [" "], "post_install", podfile_content)
|
471
|
+
end
|
367
472
|
|
368
|
-
|
473
|
+
def self.add(entries, marker, podfile_content)
|
474
|
+
file_indentation = indentation_from_string(podfile_content)
|
369
475
|
|
370
476
|
entries = entries.map { |x| "#{file_indentation}#{x}\n"}
|
371
477
|
|
@@ -382,55 +488,48 @@ module PodBuilder
|
|
382
488
|
end
|
383
489
|
|
384
490
|
if !marker_found
|
491
|
+
if podfile_lines.last.strip.length > 0
|
492
|
+
podfile_lines.push("\n")
|
493
|
+
end
|
385
494
|
podfile_lines.push("\n#{marker} do |installer|\n")
|
386
495
|
podfile_lines.push(entries)
|
387
496
|
podfile_lines.push("end\n")
|
388
497
|
end
|
389
498
|
|
390
|
-
|
499
|
+
return podfile_lines.join
|
391
500
|
end
|
392
501
|
|
393
|
-
def self.
|
394
|
-
|
395
|
-
|
396
|
-
base_path = Pathname.new(File.dirname(podfile_path))
|
397
|
-
regex = "(\s*pod\s*['|\"])(.*?)(['|\"])(.*?)(:path\s*=>\s*['|\"])(.*?)(['|\"])"
|
502
|
+
def self.update_path_entries(podfile_content, path_transform)
|
503
|
+
regex = "(\s*pod\s*['|\"])(.*?)(['|\"])(.*?):(path|podspec)(\s*=>\s*['|\"])(.*?)(['|\"])"
|
398
504
|
|
399
505
|
podfile_lines = []
|
400
506
|
podfile_content.each_line do |line|
|
401
507
|
stripped_line = strip_line(line)
|
402
508
|
matches = line.match(/#{regex}/)
|
403
509
|
|
404
|
-
if matches&.size ==
|
510
|
+
if matches&.size == 9 && !stripped_line.start_with?("#")
|
405
511
|
pod_name = matches[2]
|
406
|
-
path = matches[
|
512
|
+
path = matches[7]
|
407
513
|
|
408
514
|
is_absolute = ["~", "/"].include?(path[0])
|
409
|
-
unless !
|
515
|
+
unless !PodBuilder::prebuiltpath.end_with?(path) && !is_absolute
|
410
516
|
podfile_lines.push(line)
|
411
517
|
next
|
412
518
|
end
|
413
519
|
|
414
|
-
|
415
|
-
replace_path = original_path.relative_path_from(base_path)
|
416
|
-
if use_absolute_paths
|
417
|
-
replace_path = replace_path.expand_path(base_path)
|
418
|
-
end
|
520
|
+
replace_path = path_transform.call(path)
|
419
521
|
|
420
|
-
updated_path_line = line.gsub(/#{regex}/, '\1\2\3\4\
|
522
|
+
updated_path_line = line.gsub(/#{regex}/, '\1\2\3\4:\5\6' + replace_path.to_s + '\8\9')
|
421
523
|
podfile_lines.push(updated_path_line)
|
422
524
|
else
|
423
525
|
podfile_lines.push(line)
|
424
526
|
end
|
425
527
|
end
|
426
528
|
|
427
|
-
|
529
|
+
return podfile_lines.join
|
428
530
|
end
|
429
531
|
|
430
|
-
def self.update_project_entries(
|
431
|
-
podfile_content = File.read(podfile_path)
|
432
|
-
|
433
|
-
base_path = Pathname.new(File.dirname(podfile_path))
|
532
|
+
def self.update_project_entries(podfile_content, path_transform)
|
434
533
|
regex = "(\s*project\s*['|\"])(.*?)(['|\"])"
|
435
534
|
|
436
535
|
podfile_lines = []
|
@@ -447,11 +546,36 @@ module PodBuilder
|
|
447
546
|
next
|
448
547
|
end
|
449
548
|
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
549
|
+
replace_path = path_transform.call(path)
|
550
|
+
|
551
|
+
updated_path_line = line.gsub(/#{regex}/, '\1' + replace_path.to_s + '\3\4')
|
552
|
+
podfile_lines.push(updated_path_line)
|
553
|
+
else
|
554
|
+
podfile_lines.push(line)
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
return podfile_lines.join
|
559
|
+
end
|
560
|
+
|
561
|
+
def self.update_require_entries(podfile_content, path_transform)
|
562
|
+
regex = "(\s*require_relative\s*['|\"])(.*?)(['|\"])"
|
563
|
+
|
564
|
+
podfile_lines = []
|
565
|
+
podfile_content.each_line do |line|
|
566
|
+
stripped_line = strip_line(line)
|
567
|
+
matches = line.match(/#{regex}/)
|
568
|
+
|
569
|
+
if matches&.size == 4 && !stripped_line.start_with?("#")
|
570
|
+
path = matches[2]
|
571
|
+
|
572
|
+
is_absolute = ["~", "/"].include?(path[0])
|
573
|
+
unless !is_absolute
|
574
|
+
podfile_lines.push(line)
|
575
|
+
next
|
454
576
|
end
|
577
|
+
|
578
|
+
replace_path = path_transform.call(path)
|
455
579
|
|
456
580
|
updated_path_line = line.gsub(/#{regex}/, '\1' + replace_path.to_s + '\3\4')
|
457
581
|
podfile_lines.push(updated_path_line)
|
@@ -460,7 +584,97 @@ module PodBuilder
|
|
460
584
|
end
|
461
585
|
end
|
462
586
|
|
463
|
-
|
587
|
+
return podfile_lines.join
|
588
|
+
end
|
589
|
+
|
590
|
+
def self.prepare_for_react_native_write_pb_configuration(podfile_content)
|
591
|
+
base = File.expand_path(File.join(PodBuilder::project_path, ".."))
|
592
|
+
bin_js = Dir.glob("#{base}/node_modules/@react-native-community/cli/build/bin.js")
|
593
|
+
|
594
|
+
raise "\n\nReact native cli bin_js not found!".red unless bin_js.count == 1
|
595
|
+
bin_js = bin_js.first
|
596
|
+
|
597
|
+
config_dest_path = PodBuilder::basepath("rn_config.json")
|
598
|
+
|
599
|
+
raise "\n\nFailed generating react native configuration file".red unless system("node '#{bin_js}' config > #{config_dest_path}")
|
600
|
+
|
601
|
+
content = File.read(config_dest_path)
|
602
|
+
|
603
|
+
content.gsub!(PodBuilder::project_path, "..")
|
604
|
+
content.gsub!(File.expand_path(PodBuilder::project_path("..")), "../..")
|
605
|
+
|
606
|
+
json = JSON.parse(content)
|
607
|
+
begin
|
608
|
+
json["project"]["ios"]["sourceDir"] = "./"
|
609
|
+
json["project"]["ios"]["podfile"] = "./"
|
610
|
+
rescue => exception
|
611
|
+
raise "\n\nFailed updating react native configuration json".red
|
612
|
+
end
|
613
|
+
|
614
|
+
File.write(config_dest_path, JSON.pretty_generate(json))
|
615
|
+
|
616
|
+
return "rn_config = JSON.load(File.read(\"rn_config.json\")) # pb added\n\n" + podfile_content
|
617
|
+
end
|
618
|
+
|
619
|
+
def self.prepare_for_react_native_rn_pods_file(podfile_content)
|
620
|
+
lines = []
|
621
|
+
podfile_content.each_line do |line|
|
622
|
+
if line.include?("use_react_native!")
|
623
|
+
matches = line.match(/(\s*)/)
|
624
|
+
unless matches&.size == 2
|
625
|
+
return podfile_content
|
626
|
+
end
|
627
|
+
|
628
|
+
indentation = matches[1]
|
629
|
+
lines.push("#{indentation}use_react_native!(:path => rn_config[\"reactNativePath\"]) # pb added\n")
|
630
|
+
lines.push("#{indentation}# #{line.strip} # pb removed\n")
|
631
|
+
else
|
632
|
+
lines.push(line)
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
636
|
+
return lines.join
|
637
|
+
end
|
638
|
+
|
639
|
+
def self.prepare_for_react_native_native_modules_file(podfile_content)
|
640
|
+
lines = []
|
641
|
+
podfile_content.each_line do |line|
|
642
|
+
if line.include?("use_native_modules!")
|
643
|
+
matches = line.match(/(\s*)/)
|
644
|
+
unless matches&.size == 2
|
645
|
+
return podfile_content
|
646
|
+
end
|
647
|
+
|
648
|
+
indentation = matches[1]
|
649
|
+
lines.push("#{indentation}use_native_modules!(rn_config) # pb added\n")
|
650
|
+
lines.push("#{indentation}# #{line.strip} # pb removed\n")
|
651
|
+
else
|
652
|
+
lines.push(line)
|
653
|
+
end
|
654
|
+
end
|
655
|
+
|
656
|
+
return lines.join
|
657
|
+
end
|
658
|
+
|
659
|
+
def self.prepare_for_react_native(podfile_content)
|
660
|
+
original_podfile_content = podfile_content.dup
|
661
|
+
|
662
|
+
podfile_content = prepare_for_react_native_write_pb_configuration(podfile_content)
|
663
|
+
content = prepare_for_react_native_rn_pods_file(podfile_content)
|
664
|
+
if content == podfile_content
|
665
|
+
return original_podfile_content
|
666
|
+
end
|
667
|
+
podfile_content = content
|
668
|
+
content = prepare_for_react_native_native_modules_file(podfile_content)
|
669
|
+
if content == podfile_content
|
670
|
+
return original_podfile_content
|
671
|
+
end
|
672
|
+
podfile_content = content
|
673
|
+
|
674
|
+
Configuration.build_using_repo_paths = true
|
675
|
+
Configuration.react_native_project = true
|
676
|
+
|
677
|
+
return podfile_content
|
464
678
|
end
|
465
679
|
end
|
466
680
|
end
|