pod-builder 3.0.0 ā†’ 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dada31dddd8303f3429e7ebbb13665f6c1e8b4d66ad618795971c652ecb3f7b
4
- data.tar.gz: 290cdba5a29f1672372057f28ec9a867dcba0172b97b1e4c7a6a0cc2a83b6aed
3
+ metadata.gz: 24ce580a9fa3e410dab4cfcb639ba4e17f7b8b4b18a1c530667a5e271f05444f
4
+ data.tar.gz: bcc48ff2244170439b12f30c8853e05fb7225717cab020e6c049357c418f52ba
5
5
  SHA512:
6
- metadata.gz: f0af1cd519bdea4f141c374853c631bfb46813ae0c2caad40d92c7716fbc941e9f5dc4772b6358c368b76840937478fe75f3cb3c4df2508b7593ac527c582ebf
7
- data.tar.gz: 3087670122ad1420438ac6944056e11858b62752aa7b1749b0b4411515d4ceacc80178b045027da3fcfe2404ad33b44be3ab5de64dd1b689fbd5753988783eff
6
+ metadata.gz: bd161a170715f3f4bb1639b5ac33d93c2e36d1bbdffa6389c09ab639e642240b0b829b755925d7ff57178fa6b49cdc2d45aa8c57e0cfbde5f228458b332e57b4
7
+ data.tar.gz: de14f5a02c0d0e712c6a561954a724394febd9abd0b9bf19d29b409bf79f4b1e7d3e616998c10a7dced86f7237c9d9c690280932757f8d9189ee89d39c752857
data/README.md CHANGED
@@ -216,7 +216,7 @@ As an example here we're setting `module_name` in Google's Advertising SDK:
216
216
  }
217
217
  ```
218
218
 
219
- ### `skip_pods`
219
+ #### `skip_pods`
220
220
 
221
221
  You may want to skip some pods to be prebuilt, you can do that as follows:
222
222
 
@@ -229,7 +229,7 @@ You may want to skip some pods to be prebuilt, you can do that as follows:
229
229
  ```
230
230
 
231
231
 
232
- ### `force_prebuild_pods`
232
+ #### `force_prebuild_pods`
233
233
 
234
234
  You may want to force some pods to be prebuilt, this might be the case for prebuilt ones (pods with a single vendored .framework) which are dependencies of othere pods
235
235
 
@@ -244,7 +244,9 @@ You may want to force some pods to be prebuilt, this might be the case for prebu
244
244
 
245
245
  #### `build_settings`
246
246
 
247
- Xcode build settings to use. You can override the default values which are:
247
+ These settings allow you to specify the build settings to use when compiling prebuilt items. These values won't be reflected in your project once the pod has been built.
248
+
249
+ You can override the default values which are:
248
250
 
249
251
  ```json
250
252
  {
@@ -322,10 +324,26 @@ PodBuilder writes a plist and markdown license files of pods specified in the Po
322
324
 
323
325
  If you use bundler to pin the version of CocoaPods in your project set this to true. Default false.
324
326
 
327
+ #### `post_actions`
328
+
329
+ Post actions allow to execute custom scripts after a given command (`switch`, `build`) has been performed.
330
+
331
+ You need to specify a `path` to the executable script which is relative to the _PodBuilder_ folder. Optionally you can also specify whether the command should or should not print the output to stdout/stderr by passing a bool to the `quiet` key (default: false).
332
+
333
+ ```json
334
+ {
335
+ "post_actions": {
336
+ "switch" : { "path": "post_switch_action.rb", "quiet": true },
337
+ "build" : { "path": "post_buil_action.rb", "quiet": false }
338
+ }
339
+ }
340
+ ```
341
+
342
+
325
343
 
326
344
  # Behind the scenes
327
345
 
328
- PodBuilder leverages CocoaPods code and [cocoapods-rome plugin](https://github.com/CocoaPods/Prebuilt) to compile pods into frameworks. Every compiled framework will be boxed (by adding it as a `vendored_framework`) as a subspec of a local podspec. When needed additional settings will be automatically ported from the original podspec, like for example xcconfig settings.
346
+ PodBuilder leverages CocoaPods to compile pods into frameworks. Every compiled framework will be boxed (by adding it as a `vendored_framework`) as a subspec of a local podspec. When needed additional settings will be automatically ported from the original podspec, like for example custom xcconfig settings.
329
347
 
330
348
  # FAQ
331
349
 
@@ -362,7 +380,7 @@ Please open an issue here. You may also add the name of the pod to the [`skip_po
362
380
 
363
381
  # Git LFS
364
382
 
365
- We high encourage to use PodBuilder in combination with Git LFS. Tacking PodBuilder/Prebuilt/**/*.framework/* and PodBuilder/Prebuilt/**/*.a and PodBuilder/dSYM/**/* will ensure that your repo size stays under control with all the benefits of having prebuilt dependencies ready to use.
383
+ We high encourage to use PodBuilder in combination with Git LFS. Tacking `PodBuilder/Prebuilt/**/*.framework/*` and `PodBuilder/Prebuilt/**/*.a` and `PodBuilder/dSYM/**/*` will ensure that your repo size stays under control with all the benefits of having prebuilt dependencies ready to use.
366
384
 
367
385
 
368
386
  # Try it out!
data/exe/pod_builder CHANGED
@@ -76,9 +76,6 @@ Options:
76
76
  opts.on("-w", "--allow-warnings", "Allow warnings") do |o|
77
77
  OPTIONS[:allow_warnings] = o
78
78
  end
79
- opts.on("-r", "--parent-deps", "Include all pods that depend on the specified <PODNAME...>") do |o|
80
- OPTIONS[:resolve_parent_dependencies] = true
81
- end
82
79
  opts.on("-s", "--no-stdin", "Never request interaction with sdtin (e.g. in CI environment)") do |o|
83
80
  OPTIONS[:no_stdin_available] = o
84
81
  end
@@ -17,19 +17,18 @@ module PodBuilder
17
17
  CLAide::Command::PluginManager.loaded_plugins["cocoapods"].push(pluginspec)
18
18
  end
19
19
 
20
- current_dir = Dir.pwd
21
- Dir.chdir(path)
22
-
23
- config = Pod::Config.new()
24
- installer = Pod::Installer.new(config.sandbox, config.podfile, config.lockfile)
25
- installer.repo_update = repo_update
26
- installer.update = false
27
-
28
- installer.prepare
29
-
30
- analyzer = installer.resolve_dependencies
31
-
32
- Dir.chdir(current_dir)
20
+ installer = nil
21
+ analyzer = nil
22
+ Dir.chdir(path) do
23
+ config = Pod::Config.new()
24
+ installer = Pod::Installer.new(config.sandbox, config.podfile, config.lockfile)
25
+ installer.repo_update = repo_update
26
+ installer.update = false
27
+
28
+ installer.prepare
29
+
30
+ analyzer = installer.resolve_dependencies
31
+ end
33
32
 
34
33
  return installer, analyzer
35
34
  end
@@ -32,8 +32,6 @@ module PodBuilder
32
32
  argument_pods = all_buildable_items.map(&:root_name).uniq
33
33
  else
34
34
  argument_pods = Podfile::resolve_pod_names(argument_pods, all_buildable_items)
35
- deps = all_buildable_items.select { |t| argument_pods.include?(t.root_name) }.map(&:dependency_names).flatten.map { |t| t.split("/").first }
36
- argument_pods += deps
37
35
  argument_pods.uniq!
38
36
  end
39
37
 
@@ -43,8 +41,6 @@ module PodBuilder
43
41
  }
44
42
  argument_pods = available_argument_pods.uniq
45
43
 
46
- prebuilt_pods_to_install = prebuilt_items.select { |x| argument_pods.include?(x.root_name) }
47
-
48
44
  Podfile.restore_podfile_clean(all_buildable_items)
49
45
 
50
46
  restore_file_error = Podfile.restore_file_sanity_check
@@ -54,12 +50,25 @@ module PodBuilder
54
50
  pods_to_build = resolve_pods_to_build(argument_pods, buildable_items)
55
51
  buildable_items -= pods_to_build
56
52
 
57
- # We need to split pods to build in 3 groups
53
+ argument_pods += pods_to_build.map(&:root_name)
54
+ argument_pods.uniq!
55
+
56
+ # We need to split pods to build in 4 groups
58
57
  # 1. pods to build in release
59
58
  # 2. pods to build in debug
59
+ # 3. pods to build in release as xcframeworks
60
+ # 4. pods to build in debug as xcframeworks
60
61
 
61
62
  check_not_building_development_pods(pods_to_build)
62
63
 
64
+ # We need to recursively add dependencies to properly split pods in groups.
65
+ # Example:
66
+ # 1. PodA has a dep to PodB
67
+ # 2. PodB is marked to be built as xcframework
68
+ # 3. We rebuild PodA only (pods_to_build contains only PodA)
69
+ # 4. We need to add dependencies recursively so that PodB is is added to pods_to_build_release_xcframework
70
+ pods_to_build = pods_to_build.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
71
+
63
72
  pods_to_build_debug = pods_to_build.select { |x| x.build_configuration == "debug" }
64
73
  pods_to_build_release = pods_to_build - pods_to_build_debug
65
74
 
@@ -82,12 +91,12 @@ module PodBuilder
82
91
  install_using_frameworks = Podfile::install_using_frameworks(analyzer)
83
92
  if Configuration.react_native_project
84
93
  if install_using_frameworks
85
- raise "\n\nOnly static library packaging currently supported for react native projects. Please remove 'use_frameworks!' in #{PodBuilder::basepath("Podfile")}".red
94
+ raise "\n\nOnly static library packaging currently supported for react native projects. Please remove 'use_frameworks!' in #{PodBuilder::basepath("Podfile")}\n".red
86
95
  end
87
96
  prepare_defines_modules_override(all_buildable_items)
88
97
  else
89
98
  unless install_using_frameworks
90
- raise "\n\nOnly framework packaging currently supported. Please add 'use_frameworks!' at root level (not nested in targets) in #{PodBuilder::basepath("Podfile")}".red
99
+ raise "\n\nOnly framework packaging currently supported. Please add 'use_frameworks!' at root level (not nested in targets) in #{PodBuilder::basepath("Podfile")}\n".red
91
100
  end
92
101
  end
93
102
 
@@ -96,12 +105,17 @@ module PodBuilder
96
105
  install_result = InstallResult.new
97
106
  podfiles_items.reject { |x| x.empty? }.each do |podfile_items|
98
107
  build_configuration = podfile_items.map(&:build_configuration).uniq.first
99
-
100
- podfile_items = podfile_items.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
101
108
 
109
+ # We need to recursively find dependencies again because some of the required dependencies might have been moved to a separate group
110
+ # Example:
111
+ # 1. PodA has a dep to PodB
112
+ # 2. PodB is marked to be built as xcframework -> PodB will be added to pods_to_build_release_xcframework and won't be present in
113
+ # pods_to_build_release and therefore build will fail
114
+ podfile_items = podfile_items.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
115
+
102
116
  podfile_content = Podfile.from_podfile_items(podfile_items, analyzer, build_configuration, install_using_frameworks, build_catalyst, podfile_items.first.build_xcframework)
103
117
 
104
- install_result += Install.podfile(podfile_content, podfile_items, podfile_items.first.build_configuration)
118
+ install_result += Install.podfile(podfile_content, podfile_items, argument_pods, podfile_items.first.build_configuration)
105
119
 
106
120
  FileUtils.rm_f(PodBuilder::basepath("Podfile.lock"))
107
121
  end
@@ -119,6 +133,7 @@ module PodBuilder
119
133
  builded_pods_and_deps = podfiles_items.flatten.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
120
134
  builded_pods_and_deps.select! { |x| !x.is_prebuilt }
121
135
 
136
+ prebuilt_pods_to_install = prebuilt_items.select { |x| argument_pods.include?(x.root_name) }
122
137
  Podfile::write_restorable(builded_pods_and_deps + prebuilt_pods_to_install, all_buildable_items, analyzer)
123
138
  if !OPTIONS.has_key?(:skip_prebuild_update)
124
139
  Podfile::write_prebuilt(all_buildable_items, analyzer)
@@ -132,6 +147,8 @@ module PodBuilder
132
147
  puts "\n\nāš ļø Podfile.restore was found invalid and was overwritten. Error:\n #{restore_file_error}".red
133
148
  end
134
149
 
150
+ Configuration.post_actions[:build]&.execute()
151
+
135
152
  puts "\n\nšŸŽ‰ done!\n".green
136
153
  return 0
137
154
  end
@@ -139,10 +156,41 @@ module PodBuilder
139
156
  private
140
157
 
141
158
  def self.should_build_catalyst(installer)
142
- build_settings = installer.analysis_result.targets.map { |t| t.user_project.root_object.targets.map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } } }.flatten
159
+ integrate_targets = installer.podfile.installation_options.integrate_targets
160
+
161
+ # NOTE:
162
+ # When `integrate_targets` is false,
163
+ # `user_project` is nil and Build Settings cannot be collected,
164
+ # so collect Build Settings from xcodeproj and root xcodeproj defined in the Podfile
165
+ # ref:
166
+ # https://github.com/Subito-it/PodBuilder/issues/39
167
+ #
168
+ if integrate_targets
169
+ build_settings = installer.analysis_result.targets.map { |t| t.user_project.root_object.targets.map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } } }.flatten
170
+ else
171
+ # Find all `xcodeproj` in Podfile
172
+ user_projects_build_settings = installer.analysis_result.targets.map { |t|
173
+ user_project_path = PodBuilder.basepath + '/' + t.target_definition.user_project_path
174
+ project = Xcodeproj::Project.open(user_project_path)
175
+ project.root_object.targets.map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } }
176
+ }
177
+ .flatten
178
+ .compact
179
+
180
+ # Find root `xcodeproj`
181
+ project = Xcodeproj::Project.open(PodBuilder.find_xcodeproj)
182
+ root_project_build_setting = project
183
+ .root_object
184
+ .targets
185
+ .map { |u| u.build_configuration_list.build_configurations.map { |v| v.build_settings } }
186
+ .flatten
187
+
188
+ build_settings = user_projects_build_settings | root_project_build_setting
189
+ end
190
+
143
191
  build_catalyst = build_settings.detect { |t| t["SUPPORTS_MACCATALYST"] == "YES" } != nil
144
192
 
145
- puts "\nTo support Catalyst you should enable 'build_xcframeworks' in PodBuilder.json\n".red if build_catalyst && !Configuration.build_xcframeworks
193
+ puts "\nTo support Catalyst you should enable 'build_xcframeworks' in PodBuilder.json\n".red if build_catalyst && !Configuration.build_xcframeworks_all
146
194
 
147
195
  return build_catalyst
148
196
  end
@@ -164,11 +212,11 @@ module PodBuilder
164
212
  end
165
213
 
166
214
  def self.check_pods_exists(pods, buildable_items)
167
- raise "\n\nEmpty Podfile?".red if buildable_items.nil?
215
+ raise "\n\nEmpty Podfile?\n".red if buildable_items.nil?
168
216
 
169
217
  buildable_items = buildable_items.map(&:root_name)
170
218
  pods.each do |pod|
171
- raise "\n\nPod `#{pod}` wasn't found in Podfile.\n\nFound:\n#{buildable_items.join("\n")}\n\n".red if !buildable_items.include?(pod)
219
+ raise "\n\nPod `#{pod}` wasn't found in Podfile.\n\nFound:\n#{buildable_items.join("\n")}\n".red if !buildable_items.include?(pod)
172
220
  end
173
221
  end
174
222
 
@@ -182,7 +230,7 @@ module PodBuilder
182
230
  pods_with_unaligned_build_configuration = pods_with_common_deps.select { |x| x.build_configuration != pod.build_configuration }
183
231
  pods_with_unaligned_build_configuration.map!(&:name)
184
232
 
185
- raise "\n\nDependencies of `#{pod.name}` don't have the same build configuration (#{pod.build_configuration}) of `#{pods_with_unaligned_build_configuration.join(",")}`'s dependencies".red if pods_with_unaligned_build_configuration.count > 0
233
+ raise "\n\nDependencies of `#{pod.name}` don't have the same build configuration (#{pod.build_configuration}) of `#{pods_with_unaligned_build_configuration.join(",")}`'s dependencies\n".red if pods_with_unaligned_build_configuration.count > 0
186
234
  end
187
235
  end
188
236
 
@@ -213,7 +261,7 @@ module PodBuilder
213
261
  if OPTIONS[:allow_warnings]
214
262
  puts "\n\n#{warn_message}".yellow
215
263
  else
216
- raise "\n\n#{warn_message}".red
264
+ raise "\n\n#{warn_message}\n".red
217
265
  end
218
266
  end
219
267
  end
@@ -224,15 +272,17 @@ module PodBuilder
224
272
  pods_to_build = buildable_items.select { |x| argument_pods.include?(x.root_name) }
225
273
  pods_to_build += other_subspecs(pods_to_build, buildable_items)
226
274
 
227
- if OPTIONS[:resolve_parent_dependencies]
228
- dependencies = []
229
- buildable_items.each do |pod|
230
- if !(pod.dependencies(buildable_items) & pods_to_build).empty?
231
- dependencies.push(pod)
232
- end
275
+ # Build all pods that depend on the those that were explictly passed by the user
276
+ dependencies = []
277
+ buildable_items.each do |pod|
278
+ if !(pod.dependencies(buildable_items) & pods_to_build).empty?
279
+ dependencies.push(pod)
233
280
  end
234
- pods_to_build += dependencies
235
281
  end
282
+ log = dependencies.reject { |t| pods_to_build.map(&:root_name).include?(t.root_name) }.map(&:root_name)
283
+ puts "Adding inverse dependencies: #{log.join(", ")}".blue
284
+
285
+ pods_to_build += dependencies
236
286
 
237
287
  return pods_to_build.uniq
238
288
  end
@@ -43,15 +43,16 @@ module PodBuilder
43
43
 
44
44
  PodBuilder::safe_rm_rf(Configuration.base_path)
45
45
 
46
- Dir.chdir(PodBuilder::project_path)
47
- bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
48
- system("#{bundler_prefix}pod install;")
46
+ Dir.chdir(PodBuilder::project_path) do
47
+ bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
48
+ system("#{bundler_prefix}pod install;")
49
49
 
50
- license_base = PodBuilder::project_path(Configuration.license_filename)
51
- FileUtils.rm_f("#{license_base}.plist")
52
- FileUtils.rm_f("#{license_base}.md")
50
+ license_base = PodBuilder::project_path(Configuration.license_filename)
51
+ FileUtils.rm_f("#{license_base}.plist")
52
+ FileUtils.rm_f("#{license_base}.md")
53
53
 
54
- update_gemfile
54
+ update_gemfile
55
+ end
55
56
 
56
57
  puts "\n\nšŸŽ‰ done!\n".green
57
58
  return 0
@@ -89,8 +90,9 @@ module PodBuilder
89
90
  gemfile_lines.select! { |x| !trim_gemfile_line(x).include?(trim_gemfile_line(podbuilder_line)) }
90
91
  File.write(gemfile_path, gemfile_lines.join("\n"))
91
92
 
92
- Dir.chdir(PodBuilder::home)
93
- system("bundle")
93
+ Dir.chdir(PodBuilder::home) do
94
+ system("bundle")
95
+ end
94
96
  end
95
97
 
96
98
  def self.trim_gemfile_line(line)
@@ -19,7 +19,7 @@ module PodBuilder
19
19
  end
20
20
  source_path = File.expand_path(source_path)
21
21
 
22
- raise "\n\nSpecified path does not exists" unless File.directory?(source_path)
22
+ raise "\n\nSpecified path does not exists\n".red unless File.directory?(source_path)
23
23
  end
24
24
 
25
25
  base_path = PodBuilder::basepath
@@ -110,8 +110,9 @@ module PodBuilder
110
110
 
111
111
  File.write(gemfile_path, gemfile_lines.join("\n"))
112
112
 
113
- Dir.chdir(PodBuilder::home)
114
- system("bundle")
113
+ Dir.chdir(PodBuilder::home) do
114
+ system("bundle")
115
+ end
115
116
  end
116
117
 
117
118
  def self.trim_gemfile_line(line)
@@ -122,11 +123,11 @@ module PodBuilder
122
123
  # React-Core.podspec
123
124
  file = "React-Core.podspec"
124
125
  paths = Dir.glob("#{PodBuilder::git_rootpath}/node_modules/**/#{file}")
125
- raise "Unexpected number of #{file} found" if paths.count != 1
126
+ raise "\n\nUnexpected number of #{file} found\n".red if paths.count != 1
126
127
 
127
128
  content = File.read(paths[0])
128
129
  expected_header_search_path_prefix = "s.pod_target_xcconfig = { \"HEADER_SEARCH_PATHS\" => \""
129
- raise "Expected header search path entry not found" unless content.include?(expected_header_search_path_prefix)
130
+ raise "\n\nExpected header search path entry not found\n".red unless content.include?(expected_header_search_path_prefix)
130
131
 
131
132
  content.sub!(expected_header_search_path_prefix, "#{expected_header_search_path_prefix}\\\"$(PODS_ROOT)/Headers/Public/Flipper-Folly\\\" ")
132
133
  File.write(paths[0], content)
@@ -134,11 +135,11 @@ module PodBuilder
134
135
  # React-CoreModules.podspec
135
136
  file = "React-CoreModules.podspec"
136
137
  paths = Dir.glob("#{PodBuilder::git_rootpath}/node_modules/**/#{file}")
137
- raise "Unexpected number of #{file} found" if paths.count != 1
138
+ raise "\n\nUnexpected number of #{file} found\n".red if paths.count != 1
138
139
 
139
140
  content = File.read(paths[0])
140
141
  expected_header_search_path_prefix = "\"HEADER_SEARCH_PATHS\" => \""
141
- raise "Expected header search path entry not found" unless content.include?(expected_header_search_path_prefix)
142
+ raise "\n\nExpected header search path entry not found\n".red unless content.include?(expected_header_search_path_prefix)
142
143
 
143
144
  content.sub!(expected_header_search_path_prefix, "#{expected_header_search_path_prefix}\\\"$(PODS_ROOT)/Headers/Public/Flipper-Folly\\\" ")
144
145
  File.write(paths[0], content)
@@ -45,19 +45,17 @@ module PodBuilder
45
45
  dest_path = PodBuilder::basepath("Sources")
46
46
  FileUtils.mkdir_p(dest_path)
47
47
 
48
- current_dir = Dir.pwd
49
- Dir.chdir(dest_path)
50
-
51
- repo_dir = File.join(dest_path, spec.podspec_name)
52
- if !File.directory?(repo_dir)
53
- raise "\n\nFailed cloning #{spec.name}".red if !system("git clone #{spec.repo} #{spec.podspec_name}")
48
+ Dir.chdir(dest_path) do
49
+ repo_dir = File.join(dest_path, spec.podspec_name)
50
+ if !File.directory?(repo_dir)
51
+ raise "\n\nFailed cloning #{spec.name}".red if !system("git clone #{spec.repo} #{spec.podspec_name}")
52
+ end
54
53
  end
55
54
 
56
- Dir.chdir(repo_dir)
57
- puts "Checking out #{spec.podspec_name}".yellow
58
- raise "\n\nFailed cheking out #{spec.name}".red if !system(git_hard_checkout_cmd(spec))
59
-
60
- Dir.chdir(current_dir)
55
+ Dir.chdir(repo_dir) do
56
+ puts "Checking out #{spec.podspec_name}".yellow
57
+ raise "\n\nFailed cheking out #{spec.name}".red if !system(git_hard_checkout_cmd(spec))
58
+ end
61
59
  end
62
60
 
63
61
  def self.git_hard_checkout_cmd(spec)
@@ -13,19 +13,23 @@ module PodBuilder
13
13
  return -1
14
14
  end
15
15
 
16
+ pods_not_found = []
16
17
  pod_names_to_switch = []
17
18
  argument_pods.each do |pod|
18
19
  pod_name_to_switch = pod
19
20
  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
21
 
24
- pod_names_to_switch.push(pod_name_to_switch)
22
+ if pod_name_to_switch.nil?
23
+ raise "\n\n'#{pod}' not found in PodBuilder's Podfile.\n\nYou might need to explictly add:\n\n pod '#{pod}'\n\nto #{PodBuilder::basepath("Podfile")}\n".red
24
+ else
25
+ check_not_building_subspec(pod_name_to_switch)
26
+
27
+ pod_names_to_switch.push(pod_name_to_switch)
28
+ end
25
29
  end
26
30
 
27
31
  if OPTIONS[:resolve_parent_dependencies] == true
28
- install_update_repo = OPTIONS.fetch(:update_repos, true)
32
+ install_update_repo = OPTIONS.fetch(:update_repos, false)
29
33
  installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo)
30
34
 
31
35
  all_buildable_items = Analyze.podfile_items(installer, analyzer)
@@ -55,7 +59,7 @@ module PodBuilder
55
59
 
56
60
  podspec_content = File.read(podspec_path)
57
61
 
58
- regex = "p\\d\\.dependency '(.*)'"
62
+ regex = "p\\d\\.dependency ['|\"](.*)['|\"]"
59
63
 
60
64
  podspec_content.each_line do |line|
61
65
  matches = line.match(/#{regex}/)
@@ -107,15 +111,15 @@ module PodBuilder
107
111
  next
108
112
  end
109
113
 
110
- matches = line.gsub("\"", "'").match(/pod '(.*?)',(.*)/)
111
- if matches&.size == 3
114
+ matches = line.gsub("\"", "'").match(/pod '(.*?)'/)
115
+ if matches&.size == 2
112
116
  if matches[1].split("/").first == pod_name_to_switch
113
117
  default_entries[current_section] = line
114
118
  end
115
119
  end
116
120
  end
117
121
 
118
- raise "\n\n'#{pod_name_to_switch}' not found in #{podfile_path}".red if default_entries.keys.count == 0
122
+ raise "\n\n'#{pod_name_to_switch}' not found in PodBuilder's Podfile.\n\nYou might need to explictly add:\n\n pod '#{pod_name_to_switch}'\n\nto #{podfile_path}\n".red if default_entries.keys.count == 0
119
123
  end
120
124
 
121
125
  if development_path.nil?
@@ -137,8 +141,8 @@ module PodBuilder
137
141
  current_section = line.split(" ")[1]
138
142
  end
139
143
 
140
- matches = line.gsub("\"", "'").match(/pod '(.*?)',(.*)/)
141
- if matches&.size == 3
144
+ matches = line.gsub("\"", "'").match(/pod '(.*?)'/)
145
+ if matches&.size == 2
142
146
  if matches[1].split("/").first == pod_name_to_switch
143
147
  case OPTIONS[:switch_mode]
144
148
  when "prebuilt"
@@ -166,6 +170,14 @@ module PodBuilder
166
170
  if line.include?("# pb<") && marker = line.split("# pb<").last
167
171
  default_line = default_line.chomp("\n") + " # pb<#{marker}"
168
172
  end
173
+ if (path_match = default_line.match(/:path => '(.*?)'/)) && path_match&.size == 2
174
+ original_path = path_match[1]
175
+ if !is_absolute_path(original_path)
176
+ updated_path = Pathname.new(PodBuilder::basepath(original_path)).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
177
+ default_line.gsub!(":path => '#{original_path}'", ":path => '#{updated_path}'")
178
+ end
179
+ end
180
+
169
181
  lines.append(default_line)
170
182
  next
171
183
  elsif
@@ -183,14 +195,23 @@ module PodBuilder
183
195
  File.write(podfile_path, lines.join)
184
196
  end
185
197
 
186
- Dir.chdir(PodBuilder::project_path)
187
- bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
188
- system("#{bundler_prefix}pod install;")
198
+ Dir.chdir(PodBuilder::project_path) do
199
+ bundler_prefix = Configuration.use_bundler ? "bundle exec " : ""
200
+ system("#{bundler_prefix}pod install;")
201
+ end
202
+
203
+ Configuration.post_actions[:switch]&.execute()
204
+
205
+ puts "\n\nšŸŽ‰ done!\n".green
189
206
 
190
207
  return 0
191
208
  end
192
209
 
193
- private
210
+ private
211
+
212
+ def self.is_absolute_path(path)
213
+ return ["~", "/"].any? { |t| path.start_with?(t) }
214
+ end
194
215
 
195
216
  def self.find_podspec(podname)
196
217
  unless Configuration.development_pods_paths.count > 0
@@ -216,7 +237,7 @@ module PodBuilder
216
237
 
217
238
  def self.check_not_building_subspec(pod_to_switch)
218
239
  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
240
+ 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".red
220
241
  end
221
242
  end
222
243
  end