cocoapods-generate 1.6.0 → 2.0.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: 444c04f0d19618e1220c68828b385d2a5360b63f359f6d5c97840c92ec4c82f5
4
- data.tar.gz: 953c104741ea87c0629466cd2db8e6b27f2a9d3b395b7a18b76b714fec8d926c
3
+ metadata.gz: ea3b44ab5fbc8842aebc11de2fc54cfc3767a27a5295495ddc4ee615a992ad08
4
+ data.tar.gz: 2e59a2c711cd98ee9c7ce4f6c25d80c88f4bc0a88ade7402fe67ebd0c241df7a
5
5
  SHA512:
6
- metadata.gz: fdf382c8e04699dfb9c206fdc97fb892d39fd7b3d5403fa2118127c2caf92330bd7445b49bc38542ce67aae075002c412633ba09600a3682e20a797ae6d2bae5
7
- data.tar.gz: 237a7ab95303b502f3f0e8b525a3c6f4f640031d55b5ceab88a963806b762f51b15c7197a23c779cae4fd39e54aecb5c47e9daa0a2e0f93b03f84fbaa26c05c7
6
+ metadata.gz: dae3e8cedabed45368ad1642409929363e101e25fb156d2e684ccf158fd01627381aa10558611e7a0f0380e924b83f681a571f742e7397be5f08304040fb2b86
7
+ data.tar.gz: 4acc9aa5dcba8768e7fe33f3c0c3cb564e088505d513f9692f2efd6a944a80d216e417409f91a13f6373fb1b1d0596fd395ea449559051f5418ae4ff1aac43af
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 2.0.0
@@ -86,10 +86,12 @@ module Pod
86
86
  path = dir + '.gen_config.yml'
87
87
  next unless path.file?
88
88
  Pod::Generate::Configuration.from_file(path)
89
- end
89
+ end.compact
90
+
91
+ options.delete(:podspec_paths) if options[:podspec_paths].empty? && config_hashes.any? { |h| h.include?(:podspec_paths) }
90
92
 
91
93
  env = Generate::Configuration.from_env(ENV)
92
- config_hashes.insert(-2, env)
94
+ config_hashes = [env] + config_hashes
93
95
  config_hashes << options
94
96
 
95
97
  configuration = config_hashes.compact.each_with_object({}) { |e, h| h.merge!(e) }
@@ -316,6 +316,19 @@ module Pod
316
316
  !use_libraries?
317
317
  end
318
318
 
319
+ # @return [String] The project name to use for generating this workspace.
320
+ #
321
+ # @param [Specification] spec
322
+ # the specification to generate project name for.
323
+ #
324
+ def project_name_for_spec(spec)
325
+ project_name = spec.name.dup
326
+ # When using multiple Xcode project the project name will collide with the actual .xcodeproj meant for the pod
327
+ # that we are generating the workspace for.
328
+ project_name << 'Sample' if generate_multiple_pod_projects?
329
+ project_name
330
+ end
331
+
319
332
  # @return [Array<Specification>] the podspecs found at the given paths.
320
333
  # This method will download specs from URLs and traverse a directory's children.
321
334
  #
@@ -340,7 +353,7 @@ module Pod
340
353
  elsif path.directory?
341
354
  glob = Pathname.glob(path + '*.podspec{.json,}')
342
355
  next StandardError.new "no specs found in #{UI.path path}" if glob.empty?
343
- glob.map { |f| Pod::Specification.from_file(f) }
356
+ glob.map { |f| Pod::Specification.from_file(f) }.sort_by(&:name)
344
357
  else
345
358
  Pod::Specification.from_file(path)
346
359
  end
@@ -51,7 +51,12 @@ module Pod
51
51
 
52
52
  installer = nil
53
53
  UI.section 'Installing...' do
54
- configuration.pod_config.with_changes(installation_root: install_directory, podfile: podfile, lockfile: configuration.lockfile, sandbox: nil, sandbox_root: install_directory, podfile_path: podfile.defined_in_file, silent: !configuration.pod_config.verbose?, verbose: false, lockfile_path: nil) do
54
+ configuration.pod_config.with_changes(installation_root: install_directory, podfile: podfile,
55
+ lockfile: configuration.lockfile, sandbox: nil,
56
+ sandbox_root: install_directory + 'Pods',
57
+ podfile_path: podfile.defined_in_file,
58
+ silent: !configuration.pod_config.verbose?, verbose: false,
59
+ lockfile_path: nil) do
55
60
  installer = ::Pod::Installer.new(configuration.pod_config.sandbox, podfile, configuration.lockfile)
56
61
  installer.use_default_plugins = configuration.use_default_plugins
57
62
  installer.install!
@@ -59,7 +64,12 @@ module Pod
59
64
  end
60
65
 
61
66
  UI.section 'Performing post-installation steps' do
62
- perform_post_install_steps(open_app_project, installer)
67
+ should_perform_post_install = if installer.respond_to?(:generated_aggregate_targets) # CocoaPods 1.7.0
68
+ !installer.generated_aggregate_targets.empty?
69
+ else
70
+ true
71
+ end
72
+ perform_post_install_steps(open_app_project, installer) if should_perform_post_install
63
73
  end
64
74
 
65
75
  print_post_install_message
@@ -79,7 +89,7 @@ module Pod
79
89
  end
80
90
 
81
91
  def open_app_project(recreate: false)
82
- app_project_path = install_directory.join("#{spec.name}.xcodeproj")
92
+ app_project_path = install_directory.join("#{configuration.project_name_for_spec(spec)}.xcodeproj")
83
93
  if !recreate && app_project_path.exist?
84
94
  Xcodeproj::Project.open(app_project_path)
85
95
  else
@@ -92,25 +102,29 @@ module Pod
92
102
  # @return [Xcodeproj::Project]
93
103
  #
94
104
  def create_app_project
95
- app_project = open_app_project(recreate: true)
105
+ app_project = open_app_project(recreate: !configuration.incremental_installation?)
96
106
 
97
107
  spec_platforms = spec.available_platforms.flatten.reject do |platform|
98
108
  !configuration.platforms.nil? && !configuration.platforms.include?(platform.string_name.downcase)
99
109
  end
100
110
 
101
- Pod::Command::Gen.help! Pod::StandardError.new "No available platforms in #{spec.name}.podspec match requested platforms: #{configuration.platforms}" if spec_platforms.empty?
111
+ if spec_platforms.empty?
112
+ Pod::Command::Gen.help! Pod::StandardError.new "No available platforms in #{spec.name}.podspec match requested platforms: #{configuration.platforms}"
113
+ end
102
114
 
103
115
  spec_platforms
104
116
  .map do |platform|
105
117
  consumer = spec.consumer(platform)
106
118
  target_name = "App-#{Platform.string_name(consumer.platform_name)}"
107
- native_app_target = Pod::Generator::AppTargetHelper.add_app_target(app_project, consumer.platform_name, deployment_target(consumer), target_name)
119
+ next if app_project.targets.map(&:name).include? target_name
120
+ native_app_target = Pod::Generator::AppTargetHelper.add_app_target(app_project, consumer.platform_name,
121
+ deployment_target(consumer), target_name)
108
122
  # Temporarily set Swift version to pass validator checks for pods which do not specify Swift version.
109
123
  # It will then be re-set again within #perform_post_install_steps.
110
124
  Pod::Generator::AppTargetHelper.add_swift_version(native_app_target, Pod::Validator::DEFAULT_SWIFT_VERSION)
111
125
  native_app_target
112
126
  end
113
- .tap do
127
+ .compact.tap do
114
128
  app_project.recreate_user_schemes do |scheme, target|
115
129
  installation_result = installation_result_from_target(target)
116
130
  next unless installation_result
@@ -139,7 +153,10 @@ module Pod
139
153
  remove_script_phase_from_target(native_app_target, 'Check Pods Manifest.lock')
140
154
 
141
155
  pod_target = installer.pod_targets.find { |pt| pt.platform.name == native_app_target.platform_name && pt.pod_name == spec.name }
142
- raise "unable to find a pod target for #{native_app_target} / #{spec}" unless pod_target
156
+ raise "Unable to find a pod target for #{native_app_target} / #{spec}" unless pod_target
157
+
158
+ native_app_target.source_build_phase.clear
159
+ native_app_target.resources_build_phase.clear
143
160
 
144
161
  if (app_host_source_dir = configuration.app_host_source_dir)
145
162
  relative_app_host_source_dir = app_host_source_dir.relative_path_from(installer.sandbox.root)
@@ -173,9 +190,21 @@ module Pod
173
190
  native_app_target.add_file_references([source_file_ref])
174
191
  end
175
192
  elsif Pod::Generator::AppTargetHelper.method(:add_app_project_import).arity == -5 # CocoaPods >= 1.6
176
- Pod::Generator::AppTargetHelper.add_app_project_import(app_project, native_app_target, pod_target, pod_target.platform.name, native_app_target.name)
193
+ # If we are doing incremental installation then the file might already be there.
194
+ platform_name = Platform.string_name(native_app_target.platform_name)
195
+ group = group_for_platform_name(app_project, platform_name)
196
+ main_file_ref = group.files.find { |f| f.display_name == 'main.m' }
197
+ if main_file_ref.nil?
198
+ Pod::Generator::AppTargetHelper.add_app_project_import(app_project, native_app_target, pod_target,
199
+ pod_target.platform.name, native_app_target.name)
200
+ else
201
+ native_app_target.add_file_references([main_file_ref])
202
+ end
177
203
  else
178
- Pod::Generator::AppTargetHelper.add_app_project_import(app_project, native_app_target, pod_target, pod_target.platform.name, pod_target.requires_frameworks?, native_app_target.name)
204
+ Pod::Generator::AppTargetHelper.add_app_project_import(app_project, native_app_target, pod_target,
205
+ pod_target.platform.name,
206
+ pod_target.requires_frameworks?,
207
+ native_app_target.name)
179
208
  end
180
209
 
181
210
  # Set `PRODUCT_BUNDLE_IDENTIFIER`
@@ -185,7 +214,7 @@ module Pod
185
214
 
186
215
  case native_app_target.platform_name
187
216
  when :ios
188
- make_ios_app_launchable(installer, app_project, native_app_target)
217
+ make_ios_app_launchable(app_project, native_app_target)
189
218
  end
190
219
 
191
220
  Pod::Generator::AppTargetHelper.add_swift_version(native_app_target, pod_target.swift_version) unless pod_target.swift_version.blank?
@@ -239,9 +268,10 @@ module Pod
239
268
  .flat_map(&:test_native_targets)
240
269
  .group_by(&:platform_name)
241
270
 
271
+ workspace_path = install_directory + "#{spec.name}.xcworkspace"
242
272
  Xcodeproj::Plist.write_to_path(
243
273
  { 'IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded' => false },
244
- app_project.path.sub_ext('.xcworkspace').join('xcshareddata').tap(&:mkpath).join('WorkspaceSettings.xcsettings')
274
+ workspace_path.join('xcshareddata').tap(&:mkpath).join('WorkspaceSettings.xcsettings')
245
275
  )
246
276
 
247
277
  test_native_targets.each do |platform_name, test_targets|
@@ -266,9 +296,9 @@ module Pod
266
296
  end
267
297
  end
268
298
 
269
- def make_ios_app_launchable(installer, app_project, native_app_target)
299
+ def make_ios_app_launchable(app_project, native_app_target)
270
300
  platform_name = Platform.string_name(native_app_target.platform_name)
271
- generated_source_dir = installer.sandbox.root.join('App', platform_name).tap(&:mkpath)
301
+ generated_source_dir = install_directory.join("App-#{platform_name}").tap(&:mkpath)
272
302
 
273
303
  # Add `LaunchScreen.storyboard`
274
304
  launch_storyboard = generated_source_dir.join('LaunchScreen.storyboard')
@@ -329,12 +359,17 @@ module Pod
329
359
  Xcodeproj::Plist.write_to_path(info_plist_contents, info_plist_path)
330
360
 
331
361
  native_app_target.build_configurations.each do |bc|
332
- bc.build_settings['INFOPLIST_FILE'] = "${SRCROOT}/App/#{platform_name}/Info.plist"
362
+ bc.build_settings['INFOPLIST_FILE'] = "${SRCROOT}/App-#{platform_name}/Info.plist"
333
363
  end
334
364
 
335
- group = app_project.main_group.find_subpath("App-#{platform_name}", true)
336
- group.new_file(info_plist_path)
337
- native_app_target.resources_build_phase.add_file_reference group.new_file(launch_storyboard)
365
+ group = group_for_platform_name(app_project, platform_name)
366
+ group.files.find { |f| f.display_name == 'Info.plist' } || group.new_file(info_plist_path)
367
+ launch_storyboard_file_ref = group.files.find { |f| f.display_name == 'LaunchScreen.storyboard' } || group.new_file(launch_storyboard)
368
+ native_app_target.resources_build_phase.add_file_reference(launch_storyboard_file_ref)
369
+ end
370
+
371
+ def group_for_platform_name(project, platform_name, should_create = true)
372
+ project.main_group.find_subpath("App-#{platform_name}", should_create)
338
373
  end
339
374
 
340
375
  def print_post_install_message
@@ -30,9 +30,10 @@ module Pod
30
30
  def podfile_for_spec(spec)
31
31
  generator = self
32
32
  dir = configuration.gen_dir_for_pod(spec.name)
33
+ project_name = configuration.project_name_for_spec(spec)
33
34
 
34
35
  Pod::Podfile.new do
35
- project "#{spec.name}.xcodeproj"
36
+ project "#{project_name}.xcodeproj"
36
37
  workspace "#{spec.name}.xcworkspace"
37
38
 
38
39
  plugin 'cocoapods-generate'
@@ -43,7 +44,7 @@ module Pod
43
44
  plugin(*[name, options].compact)
44
45
  end
45
46
 
46
- use_frameworks!(generator.configuration.use_frameworks?)
47
+ use_frameworks!(generator.use_frameworks_value)
47
48
 
48
49
  if (supported_swift_versions = generator.supported_swift_versions)
49
50
  supports_swift_versions(supported_swift_versions)
@@ -128,7 +129,7 @@ module Pod
128
129
 
129
130
  # Implement local-sources option to set up dependencies to podspecs in the local filesystem.
130
131
  next if generator.configuration.local_sources.empty?
131
- generator.transitive_local_dependencies(spec, generator.configuration.local_sources).each do |dependency, podspec_file|
132
+ generator.transitive_local_dependencies(spec, generator.configuration.local_sources).sort_by(&:first).each do |dependency, podspec_file|
132
133
  pod_options = generator.dependency_compilation_kwargs(dependency.name)
133
134
  pod_options[:path] = if podspec_file[0] == '/' # absolute path
134
135
  podspec_file
@@ -140,26 +141,30 @@ module Pod
140
141
  end
141
142
  end
142
143
 
143
- def transitive_local_dependencies(spec, paths)
144
- dependencies = spec.dependencies
145
- return_list = []
146
- dependencies.each do |dependency|
144
+ def transitive_local_dependencies(spec, paths, found_podspecs: {}, include_non_library_subspecs: true)
145
+ if include_non_library_subspecs
146
+ non_library_specs = spec.recursive_subspecs.select do |ss|
147
+ ss.test_specification? || (ss.respond_to?(:app_specification?) && ss.app_specification?)
148
+ end
149
+ non_library_specs.each do |subspec|
150
+ transitive_local_dependencies(subspec, paths, found_podspecs: found_podspecs, include_non_library_subspecs: false)
151
+ end
152
+ end
153
+ spec.dependencies.each do |dependency|
154
+ next if found_podspecs.key?(dependency)
147
155
  found_podspec_file = nil
148
156
  name = dependency.name.split('/')[0]
149
157
  paths.each do |path|
150
- podspec_file = path + '/' + name + '.podspec'
158
+ podspec_file = File.join(path, name + '.podspec')
151
159
  next unless File.file?(podspec_file)
152
160
  found_podspec_file = podspec_file
153
161
  break
154
162
  end
155
163
  next unless found_podspec_file
156
- return_list << [dependency, found_podspec_file]
157
- dep_spec = Pod::Specification.from_file(found_podspec_file)
158
- dep_spec.dependencies.each do |d_dep|
159
- dependencies << d_dep unless dependencies.include? d_dep
160
- end
164
+ found_podspecs[dependency] = found_podspec_file.sub(%r{\A\./}, '')
165
+ transitive_local_dependencies(Pod::Specification.from_file(found_podspec_file), paths, found_podspecs: found_podspecs)
161
166
  end
162
- return_list
167
+ found_podspecs
163
168
  end
164
169
 
165
170
  # @return [Boolean]
@@ -189,6 +194,27 @@ module Pod
189
194
  end
190
195
  end
191
196
 
197
+ # @return [Boolean, Hash]
198
+ # the value to use for `use_frameworks!` DSL directive
199
+ #
200
+ def use_frameworks_value
201
+ return configuration.use_frameworks? unless configuration.use_podfile?
202
+ use_framework_values = target_definition_list.map do |target_definition|
203
+ if target_definition.respond_to?(:build_type) # CocoaPods >= 1.9
204
+ build_type = target_definition.build_type
205
+ if build_type.static_library?
206
+ false
207
+ else
208
+ { linkage: build_type == BuildType.dynamic_framework ? :dynamic : :static }
209
+ end
210
+ else
211
+ target_definition.uses_frameworks?
212
+ end
213
+ end.uniq
214
+ raise Informative, 'Multiple use_frameworks! values detected in user Podfile.' unless use_framework_values.count == 1
215
+ use_framework_values.first
216
+ end
217
+
192
218
  # @return [Hash]
193
219
  # a hash with "compilation"-related dependency options for the `pod` DSL method
194
220
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-generate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Giddins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods-disable-podfile-validations
@@ -101,7 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 3.0.4
104
+ rubyforge_project:
105
+ rubygems_version: 2.7.7
105
106
  signing_key:
106
107
  specification_version: 4
107
108
  summary: Generates Xcode workspaces from a podspec.