cocoapods-spm 0.1.9 → 0.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24612d253fbaf74d473abe53ca7b3293e06b5dda91b1ef52fd2795f96d5a3a97
4
- data.tar.gz: 1394cfc0a85d5378fab7929926f1f65acd7635a9236f427e2f746b4bc973a145
3
+ metadata.gz: 6c3b50f5ee1f6aac5f97a26a629a3db6e979d9d3f64d23d8b0ad09efb64b65a8
4
+ data.tar.gz: f9a36254b07ad0a945a4f74a408f86e5c64061401b1313d1176a6cf6d9a3b961
5
5
  SHA512:
6
- metadata.gz: b9a897b591b5265b2ab5fc760261fd4d2bc319d26e23a4dcf603e51f8dd40103b0d67c3ee6fbc53749727373d748ae8b0252ad2b2e74d4d972ed6f0716cc7267
7
- data.tar.gz: 062b87214c04d88dc26fbc871951006eb69c65055410a7537c03c5f7177e039adf2cf93f6ece2d718e51dd8eec66d392acd8462157dbd5634ef6f4347d587221
6
+ metadata.gz: 9129545f35676f21d34e904e5517b3a05d0fc18eaff8ca0e9fa3045d97d965ab61f7f0c07428df4e663a482d585de920e499f04d2cd76f5732f323295f1ae86b
7
+ data.tar.gz: 16461e45669ff05d949264c52dfd7b820e562ed5fd8096d86593e07c2a9f4fdb974e22923bc8f79c22d79d95b68c6573317c51a8fe0353862bf1aa1b8e85608a
@@ -22,6 +22,7 @@ module Pod
22
22
  end
23
23
 
24
24
  def run
25
+ verify_podfile_exists!
25
26
  spm_config.macros.each do |name|
26
27
  SPM::MacroFetcher.new(name: name, can_cache: true).run
27
28
  end
@@ -26,6 +26,7 @@ module Pod
26
26
  end
27
27
 
28
28
  def run
29
+ verify_podfile_exists!
29
30
  spm_config.macros.each do |name|
30
31
  SPM::MacroPrebuilder.new(name: name).run
31
32
  end
@@ -5,6 +5,7 @@ module Pod
5
5
  class Command
6
6
  class Spm < Command
7
7
  include SPM::Config::Mixin
8
+ include ProjectDirectory
8
9
 
9
10
  self.summary = "Working with SPM"
10
11
  self.abstract_command = true
@@ -1,7 +1,11 @@
1
+ require "cocoapods-spm/helpers/path"
2
+
1
3
  module Pod
2
4
  module SPM
3
5
  class Config
4
6
  module PodConfigMixin
7
+ include PathMixn
8
+
5
9
  def pod_config
6
10
  Pod::Config.instance
7
11
  end
@@ -1,3 +1,5 @@
1
+ require "cocoapods-spm/helpers/path"
2
+
1
3
  module Pod
2
4
  module SPM
3
5
  class Config
@@ -1,6 +1,10 @@
1
+ require "cocoapods-spm/helpers/path"
2
+
1
3
  module Pod
2
4
  module SPM
3
5
  class Config
6
+ include PathMixn
7
+
4
8
  module SPMConfigMixin
5
9
  def spm_config
6
10
  Config.instance
@@ -61,7 +65,7 @@ module Pod
61
65
  end
62
66
 
63
67
  def root_dir
64
- @root_dir ||= Pathname(".spm.pods")
68
+ @root_dir ||= prepare_dir(Pod::Config.instance.installation_root / ".spm.pods")
65
69
  end
66
70
 
67
71
  def pkg_root_dir
@@ -99,13 +103,6 @@ module Pod
99
103
  def pkg_metadata_dir
100
104
  @pkg_metadata_dir ||= prepare_dir(pkg_root_dir / "metadata")
101
105
  end
102
-
103
- private
104
-
105
- def prepare_dir(dir)
106
- dir.mkpath
107
- dir
108
- end
109
106
  end
110
107
  end
111
108
  end
@@ -1,7 +1,15 @@
1
1
  module Pod
2
2
  class Installer
3
- def native_targets
4
- pods_project.targets + pod_target_subprojects.flat_map(&:targets)
3
+ module InstallerMixin
4
+ def native_targets
5
+ projects_to_integrate.flat_map(&:targets)
6
+ end
7
+
8
+ def projects_to_integrate
9
+ [pods_project] + pod_target_subprojects
10
+ end
5
11
  end
12
+
13
+ include InstallerMixin
6
14
  end
7
15
  end
@@ -18,7 +18,8 @@ module Pod
18
18
  macro = requirements[0].delete(:macro) if requirements.first.is_a?(Hash)
19
19
  macro ||= {}
20
20
  unless macro.empty?
21
- requirements[0][:path] = prepare_macro_pod_dir(name, macro).to_s
21
+ macro_dir = prepare_macro_pod_dir(name, macro)
22
+ requirements[0][:path] = macro_dir.relative_path_from(Pod::Config.instance.installation_root).to_s
22
23
  macro_pods[name] = macro
23
24
  end
24
25
  origin_pod(name, *requirements)
@@ -22,6 +22,7 @@ module Pod
22
22
  @relative_path = relative_path_from(options)
23
23
  @requirement = requirement_from(options)
24
24
  @linking_opts = options[:linking] || {}
25
+ validate!
25
26
  end
26
27
 
27
28
  def slug
@@ -86,6 +87,16 @@ module Pod
86
87
 
87
88
  private
88
89
 
90
+ def validate!
91
+ if use_default_xcode_linking? # rubocop:disable Style/GuardClause
92
+ UI.warn <<~HEREDOC
93
+ The option :use_default_xcode_linking in the following declaration is deprecated:
94
+ #{@_options}
95
+ You are recommended to omit this option in `spm_pkg`.
96
+ HEREDOC
97
+ end
98
+ end
99
+
89
100
  def requirement_from(options)
90
101
  return if @relative_path
91
102
 
@@ -0,0 +1,10 @@
1
+ module Pod
2
+ module SPM
3
+ module PathMixn
4
+ def prepare_dir(dir)
5
+ dir.mkpath
6
+ dir
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,11 +1,13 @@
1
1
  require "cocoapods-spm/config"
2
2
  require "cocoapods-spm/def/podfile"
3
3
  require "cocoapods-spm/def/spec"
4
+ require "cocoapods-spm/macro/metadata"
4
5
 
5
6
  module Pod
6
7
  module SPM
7
8
  class Hook
8
9
  include Config::Mixin
10
+ include Installer::InstallerMixin
9
11
 
10
12
  def initialize(context, options = {})
11
13
  @context = context
@@ -34,10 +36,6 @@ module Pod
34
36
  @context.pod_target_subprojects
35
37
  end
36
38
 
37
- def projects_to_integrate
38
- [pods_project] + pod_target_subprojects
39
- end
40
-
41
39
  def user_build_configurations
42
40
  @user_build_configurations ||= (pod_targets + aggregate_targets)[0].user_build_configurations
43
41
  end
@@ -94,6 +92,19 @@ module Pod
94
92
  end
95
93
  end
96
94
  end
95
+
96
+ def macro_metadata_for_pod(name)
97
+ return nil unless spm_config.all_macros.include?(name)
98
+
99
+ @macro_metadata_cache ||= {}
100
+ @macro_metadata_cache[name] = MacroMetadata.for_pod(name) unless @macro_metadata_cache.key?(name)
101
+ @macro_metadata_cache[name]
102
+ end
103
+
104
+ def pod_name_of_target(name)
105
+ target = @analysis_result.pod_targets.find { |x| x.name == name }
106
+ target.nil? ? name : target.pod_name
107
+ end
97
108
  end
98
109
  end
99
110
  end
@@ -13,11 +13,12 @@ module Pod
13
13
  private
14
14
 
15
15
  def macro_plugin_flag_by_config
16
- path_prefix = "${PODS_ROOT}/../#{spm_config.macro_prebuilt_root_dir}"
16
+ prebuild_root_dir = spm_config.macro_prebuilt_root_dir.relative_path_from(pod_config.installation_root)
17
+ path_prefix = "${PODS_ROOT}/../#{prebuild_root_dir}"
17
18
  @macro_plugin_flag_by_config ||= begin
18
19
  hash = user_build_configurations.keys.to_h do |config|
19
20
  flags = macro_pods.keys.map do |name|
20
- metadata = MacroMetadata.for_pod(name)
21
+ metadata = macro_metadata_for_pod(name)
21
22
  impl_module_name = metadata.macro_impl_name
22
23
  plugin_executable_path =
23
24
  "#{path_prefix}/#{name}/" \
@@ -0,0 +1,26 @@
1
+ require "cocoapods-spm/hooks/base"
2
+ require "cocoapods-spm/macro/metadata"
3
+
4
+ module Pod
5
+ module SPM
6
+ class Hook
7
+ class UpdateMacroPlatforms < Hook
8
+ def run
9
+ to_save = Set.new
10
+ native_targets.each do |target|
11
+ name = pod_name_of_target(target.name)
12
+ metadata = macro_metadata_for_pod(name)
13
+ next if metadata.nil?
14
+
15
+ settings = metadata.platform_build_settings
16
+ target.build_configurations.each do |config|
17
+ settings.each { |k, v| config.build_settings[k] = v }
18
+ end
19
+ to_save << target.project
20
+ end
21
+ to_save.each(&:save)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -2,6 +2,7 @@ module Pod
2
2
  module SPM
3
3
  module MacroConfigMixin
4
4
  include Config::Mixin
5
+ include PathMixn
5
6
 
6
7
  def macro_downloaded_dir
7
8
  spm_config.macro_downloaded_root_dir / name
@@ -11,6 +12,10 @@ module Pod
11
12
  @macro_dir ||= spm_config.macro_root_dir / name
12
13
  end
13
14
 
15
+ def macro_scratch_dir
16
+ @macro_scratch_dir ||= prepare_dir(spm_config.macro_root_dir / ".build")
17
+ end
18
+
14
19
  def macro_prebuilt_dir
15
20
  spm_config.macro_prebuilt_root_dir / name
16
21
  end
@@ -12,6 +12,22 @@ module Pod
12
12
  end
13
13
  from_file(path)
14
14
  end
15
+
16
+ def platforms
17
+ raw["platforms"].to_h { |ds| [ds["platformName"], ds["version"]] }
18
+ end
19
+
20
+ def platform_build_settings
21
+ ds = {
22
+ "ios" => "IPHONEOS_DEPLOYMENT_TARGET",
23
+ "macos" => "MACOSX_DEPLOYMENT_TARGET",
24
+ "tvos" => "TVOS_DEPLOYMENT_TARGET",
25
+ "watchos" => "WATCHOS_DEPLOYMENT_TARGET",
26
+ "visionos" => "XROS_DEPLOYMENT_TARGET",
27
+ "driverkit" => "DRIVERKIT_DEPLOYMENT_TARGET",
28
+ }
29
+ platforms.transform_keys { |k| ds[k] }.reject { |k, _| k.nil? }
30
+ end
15
31
  end
16
32
  end
17
33
  end
@@ -28,14 +28,23 @@ module Pod
28
28
  end
29
29
 
30
30
  UI.section "Building macro implementation: #{impl_module_name} (#{config})...".green do
31
- Dir.chdir(macro_downloaded_dir) do
32
- swift! ["--version"]
33
- swift! ["build", "-c", config, "--product", impl_module_name]
34
- end
31
+ swift! ["--version"]
32
+ swift! [
33
+ "build",
34
+ "-c", config,
35
+ "--product", impl_module_name,
36
+ "--package-path", macro_downloaded_dir,
37
+ "--scratch-path", macro_scratch_dir,
38
+ ]
39
+ # Workaround: When building a macro, the debug.yaml under the scratch dir contains some corrupted info,
40
+ # causing the following failure when building the next macro:
41
+ # No target named 'OrcamImpl-debug.exe' in build description
42
+ # Idk what this file is for, but deleting it helps
43
+ macro_scratch_dir.glob("*.yaml").each { |p| p.delete if p.exist? }
35
44
  end
36
45
 
37
46
  prebuilt_binary.parent.mkpath
38
- macro_downloaded_build_config_dir = macro_downloaded_dir / ".build" / config
47
+ macro_downloaded_build_config_dir = macro_scratch_dir / config
39
48
  macro_build_binary_file_path = macro_downloaded_build_config_dir / impl_module_name
40
49
  unless macro_build_binary_file_path.exist?
41
50
  macro_build_binary_file_path = macro_downloaded_build_config_dir / "#{impl_module_name}-tool"
@@ -63,7 +63,7 @@ module Pod
63
63
  return target.name if target.is_a?(Pod::AggregateTarget)
64
64
 
65
65
  cmps = target.name.split("-")
66
- return cmps[...-1].join("-") if ["iOS", "macOS", "watchOS", "tvOS"].include?(cmps[-1])
66
+ return cmps[...-1].join("-") if ["iOS", "macOS", "watchOS", "tvOS", "visionOS"].include?(cmps[-1])
67
67
 
68
68
  target.name
69
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-spm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thuyen Trinh
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-08 00:00:00.000000000 Z
11
+ date: 2025-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -54,12 +54,14 @@ files:
54
54
  - lib/cocoapods-spm/executables.rb
55
55
  - lib/cocoapods-spm/helpers/io.rb
56
56
  - lib/cocoapods-spm/helpers/patch.rb
57
+ - lib/cocoapods-spm/helpers/path.rb
57
58
  - lib/cocoapods-spm/hooks/base.rb
58
59
  - lib/cocoapods-spm/hooks/helpers/update_script.rb
59
- - lib/cocoapods-spm/hooks/post_integrate/1.add_spm_pkgs.rb
60
- - lib/cocoapods-spm/hooks/post_integrate/5.update_settings.rb
61
- - lib/cocoapods-spm/hooks/post_integrate/6.update_embed_frameworks_script.rb
62
- - lib/cocoapods-spm/hooks/post_integrate/7.update_copy_resources_script.rb
60
+ - lib/cocoapods-spm/hooks/post_integrate/01.add_spm_pkgs.rb
61
+ - lib/cocoapods-spm/hooks/post_integrate/05.update_settings.rb
62
+ - lib/cocoapods-spm/hooks/post_integrate/06.update_macro_platforms.rb
63
+ - lib/cocoapods-spm/hooks/post_integrate/20.update_embed_frameworks_script.rb
64
+ - lib/cocoapods-spm/hooks/post_integrate/21.update_copy_resources_script.rb
63
65
  - lib/cocoapods-spm/macro/config.rb
64
66
  - lib/cocoapods-spm/macro/fetcher.rb
65
67
  - lib/cocoapods-spm/macro/metadata.rb
@@ -86,7 +88,7 @@ homepage: https://github.com/trinhngocthuyen/cocoapods-spm
86
88
  licenses:
87
89
  - MIT
88
90
  metadata: {}
89
- post_install_message:
91
+ post_install_message:
90
92
  rdoc_options: []
91
93
  require_paths:
92
94
  - lib
@@ -102,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
104
  version: '0'
103
105
  requirements: []
104
106
  rubygems_version: 3.2.33
105
- signing_key:
107
+ signing_key:
106
108
  specification_version: 4
107
109
  summary: CocoaPods plugin to add SPM dependencies to CocoaPods targets
108
110
  test_files: []