cocoapods-spm 0.1.3 → 0.1.5

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-spm/command/clean.rb +31 -0
  3. data/lib/cocoapods-spm/command/macro/deprecated.rb +35 -0
  4. data/lib/cocoapods-spm/command/macro/fetch.rb +33 -0
  5. data/lib/cocoapods-spm/command/macro/prebuild.rb +37 -0
  6. data/lib/cocoapods-spm/command/macro.rb +14 -0
  7. data/lib/cocoapods-spm/command/spm.rb +2 -2
  8. data/lib/cocoapods-spm/config/spm.rb +11 -3
  9. data/lib/cocoapods-spm/def/podfile.rb +9 -5
  10. data/lib/cocoapods-spm/def/spm_dependency.rb +3 -1
  11. data/lib/cocoapods-spm/def/spm_package.rb +3 -1
  12. data/lib/cocoapods-spm/helpers/io.rb +13 -0
  13. data/lib/cocoapods-spm/helpers/patch.rb +14 -0
  14. data/lib/cocoapods-spm/hooks/helpers/update_script.rb +61 -0
  15. data/lib/cocoapods-spm/hooks/post_integrate/5.update_settings.rb +24 -35
  16. data/lib/cocoapods-spm/hooks/post_integrate/6.update_embed_frameworks_script.rb +14 -36
  17. data/lib/cocoapods-spm/hooks/post_integrate/7.update_copy_resources_script.rb +33 -0
  18. data/lib/cocoapods-spm/macro/metadata.rb +11 -0
  19. data/lib/cocoapods-spm/macro/prebuilder.rb +7 -6
  20. data/lib/cocoapods-spm/main.rb +2 -1
  21. data/lib/cocoapods-spm/patch/aggregate_target.rb +15 -3
  22. data/lib/cocoapods-spm/patch/installer.rb +6 -7
  23. data/lib/cocoapods-spm/resolver/recursive_target_resolver.rb +37 -0
  24. data/lib/cocoapods-spm/resolver/result.rb +27 -23
  25. data/lib/cocoapods-spm/resolver/umbrella_package.rb +9 -4
  26. data/lib/cocoapods-spm/resolver.rb +6 -8
  27. data/lib/cocoapods-spm/swift/package/base.rb +54 -0
  28. data/lib/cocoapods-spm/swift/package/dependency.rb +27 -0
  29. data/lib/cocoapods-spm/swift/package/description.rb +76 -0
  30. data/lib/cocoapods-spm/swift/package/product.rb +17 -0
  31. data/lib/cocoapods-spm/swift/package/project_packages.rb +58 -0
  32. data/lib/cocoapods-spm/swift/package/resources.rb +17 -0
  33. data/lib/cocoapods-spm/swift/package/target.rb +154 -0
  34. metadata +20 -7
  35. data/lib/cocoapods-spm/command/fetch.rb +0 -31
  36. data/lib/cocoapods-spm/command/prebuild.rb +0 -35
  37. data/lib/cocoapods-spm/metadata.rb +0 -50
  38. data/lib/cocoapods-spm/resolver/product.rb +0 -31
  39. data/lib/cocoapods-spm/resolver/product_dep_resolver.rb +0 -134
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e61ad227d509165fab0c8f3e832aa06d05524fa7c2cbfd4d7cc8f393252fc60f
4
- data.tar.gz: 66f6bf9e254c7a99edc55f304fcf34ea60867fbbb9f138a6473eb200b6fa9f32
3
+ metadata.gz: 815b5b5db4530e4fd685d421cd33fb1cde41b29abfa667aa0ba9d3c1b61f8ef0
4
+ data.tar.gz: 6befd92a1d7528b4da4a5f62a1f8676c8bfb8be0dd5cc65d8c134a7df01d5b01
5
5
  SHA512:
6
- metadata.gz: e48c19f9a2ed81601a69cca75ceda44b9353bf76f996458dc3398dad8e7b0ed2fa6fff8ce03cad91122cdcf6f7603a5cc1070b9944dfab98a0d1ff5081f82740
7
- data.tar.gz: d26d1674591412b761b92e51154142b5e76f7515464b0e462d5b26a06caeadd3162df96308d2ff34b1cb3d27c554eb33715d2248b7e66e2e58e1d56ceb4b1214
6
+ metadata.gz: abf5bf865306d931a1fbe53d230d17d80f62a1813a96b199c902c9f7da9dfc7ecbfff44eac5a3c7043ca73f856d66225c94f38d6ca5cf634f3b475d29f4a5476
7
+ data.tar.gz: 87e9e3935e947420740e3bdbd2d4c8ca0f36c8ad955a9ab15b2d7756c6bf58dc37aa7a3b9378df75b4db60b30c2e1e1a8b666b19d547cbe5216c907a0f89607a
@@ -0,0 +1,31 @@
1
+ module Pod
2
+ class Command
3
+ class Spm < Command
4
+ class Clean < Spm
5
+ self.summary = "Clean caches"
6
+ def self.options
7
+ [
8
+ ["--all", "Clean all"],
9
+ ["--macros", "Clean macros"],
10
+ ["--packages", "Clean packages"],
11
+ ].concat(super)
12
+ end
13
+
14
+ def initialize(argv)
15
+ super
16
+ @clean_all = argv.flag?("all")
17
+ @clean_macros = argv.flag?("macros")
18
+ @clean_pkgs = argv.flag?("packages")
19
+ end
20
+
21
+ def run
22
+ to_clean = []
23
+ to_clean << spm_config.pkg_root_dir if @clean_pkgs
24
+ to_clean << spm_config.macro_root_dir if @clean_macros
25
+ to_clean << spm_config.root_dir if @clean_all
26
+ to_clean.each { |dir| dir.rmtree if dir.exist? }
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,35 @@
1
+ module Pod
2
+ class Command
3
+ class Spm < Command
4
+ def self.bind_command(cls)
5
+ Class.new(Spm) do
6
+ define_method(:cls) { cls }
7
+
8
+ self.summary = "[Deprecated] #{cls.summary}"
9
+
10
+ def self.options
11
+ cls.options
12
+ end
13
+
14
+ def initialize(argv)
15
+ name = self.class.name.demodulize.downcase
16
+ warn "[DEPRECATION] `pod spm #{name}` is deprecated. Please use `pod spm macro #{name}` instead.".yellow
17
+ @_binded = cls.new(argv)
18
+ super
19
+ end
20
+
21
+ def validate!
22
+ @_binded.validate!
23
+ end
24
+
25
+ def run
26
+ @_binded.run
27
+ end
28
+ end
29
+ end
30
+
31
+ Fetch = bind_command(Macro::Fetch)
32
+ Prebuild = bind_command(Macro::Prebuild)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ require "cocoapods-spm/macro/fetcher"
2
+
3
+ module Pod
4
+ class Command
5
+ class Spm < Command
6
+ class Macro < Spm
7
+ class Fetch < Macro
8
+ self.summary = "Fetch macros"
9
+ def self.options
10
+ [
11
+ ["--all", "Prebuild all macros"],
12
+ ["--macros=foo", "Macros to prebuild, separated by comma (,)"],
13
+ ].concat(super)
14
+ end
15
+
16
+ def initialize(argv)
17
+ super
18
+ update_cli_config(
19
+ all: argv.flag?("all"),
20
+ macros: argv.option("macros", "").split(",")
21
+ )
22
+ end
23
+
24
+ def run
25
+ spm_config.macros.each do |name|
26
+ SPM::MacroFetcher.new(name: name, can_cache: true).run
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,37 @@
1
+ require "cocoapods-spm/macro/prebuilder"
2
+
3
+ module Pod
4
+ class Command
5
+ class Spm < Command
6
+ class Macro < Spm
7
+ class Prebuild < Macro
8
+ self.summary = "Prebuild macros"
9
+ def self.options
10
+ [
11
+ ["--all", "Prebuild all macros"],
12
+ ["--macros=foo", "Macros to prebuild, separated by comma (,)"],
13
+ ["--config=foo", "Config (debug/release) to prebuild macros"],
14
+ ].concat(super)
15
+ end
16
+
17
+ def initialize(argv)
18
+ super
19
+ update_cli_config(
20
+ all: argv.flag?("all"),
21
+ macros: argv.option("macros", "").split(","),
22
+ config: argv.option("config"),
23
+ dont_prebuild_macros: false,
24
+ dont_prebuild_macros_if_exist: false
25
+ )
26
+ end
27
+
28
+ def run
29
+ spm_config.macros.each do |name|
30
+ SPM::MacroPrebuilder.new(name: name).run
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,14 @@
1
+ require "cocoapods-spm/command/macro/fetch"
2
+ require "cocoapods-spm/command/macro/prebuild"
3
+ require "cocoapods-spm/command/macro/deprecated"
4
+
5
+ module Pod
6
+ class Command
7
+ class Spm < Command
8
+ class Macro < Spm
9
+ self.summary = "Working with macros"
10
+ self.abstract_command = true
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
- require "cocoapods-spm/command/prebuild"
2
- require "cocoapods-spm/command/fetch"
1
+ require "cocoapods-spm/command/macro"
2
+ require "cocoapods-spm/command/clean"
3
3
 
4
4
  module Pod
5
5
  class Command
@@ -16,7 +16,7 @@ module Pod
16
16
  def initialize
17
17
  @dsl_config = {
18
18
  :dont_prebuild_macros => false,
19
- :dont_prebuild_macros_if_exist => true
19
+ :dont_prebuild_macros_if_exist => true,
20
20
  }
21
21
  @cli_config = {}
22
22
  end
@@ -58,25 +58,33 @@ module Pod
58
58
  end
59
59
 
60
60
  def macro_root_dir
61
- root_dir # To be updated: rootdir / "macros"
61
+ @macro_root_dir ||= prepare_dir(root_dir / "macros")
62
62
  end
63
63
 
64
64
  def macro_downloaded_root_dir
65
65
  macro_root_dir / ".downloaded"
66
66
  end
67
67
 
68
+ def macro_prebuilt_root_dir
69
+ macro_root_dir / ".prebuilt"
70
+ end
71
+
68
72
  def macro_downloaded_sandbox
69
73
  @macro_downloaded_sandbox ||= Sandbox.new(macro_downloaded_root_dir)
70
74
  end
71
75
 
72
76
  def pkg_umbrella_dir
73
- @pkg_umbrella_dir ||= prepare_dir(root_dir / ".umbrella")
77
+ @pkg_umbrella_dir ||= prepare_dir(pkg_root_dir / ".umbrella")
74
78
  end
75
79
 
76
80
  def pkg_checkouts_dir
77
81
  pkg_umbrella_dir / ".build" / "checkouts"
78
82
  end
79
83
 
84
+ def pkg_artifacts_dir
85
+ pkg_umbrella_dir / ".build" / "artifacts"
86
+ end
87
+
80
88
  def pkg_metadata_dir
81
89
  @pkg_metadata_dir ||= prepare_dir(pkg_root_dir / "metadata")
82
90
  end
@@ -1,10 +1,11 @@
1
1
  require "cocoapods-spm/config"
2
+ require "cocoapods-spm/helpers/patch"
2
3
 
3
4
  module Pod
4
5
  class Podfile
6
+ include Mixin::PatchingBehavior
5
7
  attr_accessor :spm_resolver
6
8
 
7
- alias origin_pod pod
8
9
  def config_cocoapods_spm(options)
9
10
  SPM::Config.instance.dsl_config = options
10
11
  end
@@ -13,11 +14,11 @@ module Pod
13
14
  @macro_pods ||= {}
14
15
  end
15
16
 
16
- def pod(name = nil, *requirements)
17
+ patch_method :pod do |name = nil, *requirements|
17
18
  macro = requirements[0].delete(:macro) if requirements.first.is_a?(Hash)
18
19
  macro ||= {}
19
20
  unless macro.empty?
20
- requirements[0][:path] = prepare_macro_pod_dir(name, macro)
21
+ requirements[0][:path] = prepare_macro_pod_dir(name, macro).to_s
21
22
  macro_pods[name] = macro
22
23
  end
23
24
  origin_pod(name, *requirements)
@@ -27,6 +28,10 @@ module Pod
27
28
  current_target_definition.store_spm_pkg(name, options)
28
29
  end
29
30
 
31
+ def spm_pkgs
32
+ spm_pkgs_by_aggregate_target.values.flatten.uniq(&:name)
33
+ end
34
+
30
35
  def spm_pkgs_for(target)
31
36
  spm_pkgs_by_aggregate_target[target.to_s]
32
37
  end
@@ -62,8 +67,7 @@ module Pod
62
67
  end
63
68
  HEREDOC
64
69
 
65
- path = Pathname(".spm.pods/#{name}")
66
- (path / ".prebuilt").mkpath
70
+ path = Pod::SPM::Config.instance.macro_root_dir / name
67
71
  (path / "Sources").mkpath
68
72
  (path / "#{name}.podspec").write(podspec_content)
69
73
  path
@@ -15,8 +15,10 @@ module Pod
15
15
  end
16
16
 
17
17
  def inspect
18
- "#<#{self.class} name=#{name} product=#{product} pkg=#{pkg}>"
18
+ "#<#{self.class} #{name}/#{product} pkg=#{pkg}>"
19
19
  end
20
+
21
+ alias to_s inspect
20
22
  end
21
23
  end
22
24
  end
@@ -42,9 +42,11 @@ module Pod
42
42
  end
43
43
 
44
44
  def inspect
45
- "#<#{self.class} name=#{name}>"
45
+ "#<#{self.class} #{name}>"
46
46
  end
47
47
 
48
+ alias to_s inspect
49
+
48
50
  def local?
49
51
  @relative_path != nil
50
52
  end
@@ -0,0 +1,13 @@
1
+ module Pod
2
+ module IOUtils
3
+ def self.symlink(src, dst)
4
+ # NOTE: File operations are case-insensitive (foo.json and Foo.json are identical)
5
+ return if File.identical?(src, dst)
6
+
7
+ src = Pathname.new(src) unless src.is_a?(Pathname)
8
+ dst = Pathname.new(dst) unless dst.is_a?(Pathname)
9
+ dst.delete if dst.exist?
10
+ File.symlink(src.absolute? ? src : src.realpath, dst)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module Mixin
2
+ module PatchingBehavior
3
+ def patch_method(method_name, &block)
4
+ raw_method_name = "origin_#{method_name}"
5
+ alias_method raw_method_name, method_name
6
+ define_method(method_name, &block)
7
+ private raw_method_name
8
+ end
9
+
10
+ def self.included(base)
11
+ base.extend(self)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,61 @@
1
+ require "cocoapods-spm/hooks/base"
2
+
3
+ module Pod
4
+ module SPM
5
+ module UpdateScript
6
+ module Mixin
7
+ def update_script(options = {})
8
+ script_name = options[:name]
9
+ content_by_target = options[:content_by_target]
10
+
11
+ aggregate_targets.each do |target|
12
+ lines, input_paths, output_paths = content_by_target.call(target)
13
+ next if input_paths.empty?
14
+
15
+ update_script_content(
16
+ path: target.send("#{script_name}_path"),
17
+ before: options[:insert_before],
18
+ insert: lines.join("\n")
19
+ )
20
+
21
+ # Update input/output files
22
+ user_build_configurations.each_key do |config|
23
+ append_contents = lambda do |method_name, contents|
24
+ target.send(method_name, config).open("a") do |f|
25
+ contents.each { |p| f << "\n" << p }
26
+ end
27
+ end
28
+ append_contents.call("#{script_name}_input_files_path", input_paths)
29
+ append_contents.call("#{script_name}_output_files_path", output_paths)
30
+ end
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def update_script_content(options = {})
37
+ match_content = options[:before]
38
+ insert_content = <<~SH
39
+ # --------------------------------------------------------
40
+ # Added by `cocoapods-spm`
41
+ # --------------------------------------------------------
42
+ #{options[:insert]}
43
+ # --------------------------------------------------------
44
+ SH
45
+ options[:path].open("r+") do |f|
46
+ content = f.read
47
+ offset = content.index(match_content) unless match_content.nil?
48
+ if offset.nil?
49
+ f << "\n" << insert_content
50
+ else
51
+ f.seek(offset)
52
+ after_content = f.read
53
+ f.seek(offset)
54
+ f << "\n" << insert_content << after_content
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,5 +1,5 @@
1
1
  require "cocoapods-spm/hooks/base"
2
- require "cocoapods-spm/metadata"
2
+ require "cocoapods-spm/macro/metadata"
3
3
 
4
4
  module Pod
5
5
  module SPM
@@ -7,22 +7,21 @@ module Pod
7
7
  class UpdateSettings < Hook
8
8
  def run
9
9
  update_macro_plugin_flags
10
- update_modulemap_flags
11
- update_swift_include_paths
12
- update_linker_flags
10
+ update_packages_flags
13
11
  end
14
12
 
15
13
  private
16
14
 
17
15
  def macro_plugin_flag_by_config
16
+ path_prefix = "${PODS_ROOT}/../#{spm_config.macro_prebuilt_root_dir}"
18
17
  @macro_plugin_flag_by_config ||= begin
19
18
  hash = user_build_configurations.keys.to_h do |config|
20
19
  flags = macro_pods.keys.map do |name|
21
- metadata = Metadata.for_pod(name)
20
+ metadata = MacroMetadata.for_pod(name)
22
21
  impl_module_name = metadata.macro_impl_name
23
22
  plugin_executable_path =
24
- "${PODS_ROOT}/../.spm.pods/#{name}/.prebuilt/#{config.to_s.downcase}/" \
25
- "#{impl_module_name}##{impl_module_name}"
23
+ "#{path_prefix}/#{name}/" \
24
+ "#{impl_module_name}-#{config.to_s.downcase}##{impl_module_name}"
26
25
  "-load-plugin-executable \"#{plugin_executable_path}\""
27
26
  end.join(" ")
28
27
  [config, flags]
@@ -42,27 +41,20 @@ module Pod
42
41
  )
43
42
  end
44
43
 
45
- def update_modulemap_flags
46
- perform_settings_update(
47
- update_targets: lambda do |target, _, _|
48
- {
49
- "OTHER_SWIFT_FLAGS" => modulemap_args_for_target(target, prefix: "-Xcc"),
50
- "OTHER_CFLAGS" => modulemap_args_for_target(target)
51
- }
52
- end
53
- )
54
- end
55
-
56
- def update_linker_flags
44
+ def update_packages_flags
57
45
  return if @spm_resolver.result.spm_pkgs.empty?
58
46
 
59
- # For packages to work in the main target
60
47
  perform_settings_update(
61
48
  update_targets: lambda do |target, _, _|
62
49
  {
63
- "OTHER_LDFLAGS" => linker_flags_for(target),
50
+ "SOURCE_PACKAGES_CHECKOUTS_DIR" => "${PODS_CONFIGURATION_BUILD_DIR}/../../../SourcePackages/checkouts",
64
51
  "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/PackageFrameworks\"",
65
- "LIBRARY_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}\""
52
+ "LIBRARY_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}\"",
53
+ "SWIFT_INCLUDE_PATHS" => "$(PODS_CONFIGURATION_BUILD_DIR)",
54
+ "OTHER_SWIFT_FLAGS" => modulemap_args_for_target(target, prefix: "-Xcc"),
55
+ "OTHER_CFLAGS" => modulemap_args_for_target(target),
56
+ "HEADER_SEARCH_PATHS" => header_search_paths_for(target),
57
+ "OTHER_LDFLAGS" => linker_flags_for(target),
66
58
  }
67
59
  end
68
60
  )
@@ -74,25 +66,22 @@ module Pod
74
66
  @spm_resolver.result.linker_flags_for(target)
75
67
  end
76
68
 
77
- def update_swift_include_paths
78
- return if @spm_resolver.result.spm_pkgs.empty? && spm_config.all_macros.empty?
79
-
80
- perform_settings_update(
81
- update_targets: lambda do |_, _, _|
82
- { "SWIFT_INCLUDE_PATHS" => "$(PODS_CONFIGURATION_BUILD_DIR)" }
83
- end
84
- )
85
- end
86
-
87
69
  def modulemap_args_for_target(target, prefix: nil)
88
70
  @spm_resolver
89
71
  .result
90
- .spm_products_for(target)
91
- .reject { |p| p.headers_path.nil? }
92
- .map { |p| "-fmodule-map-file=\"${GENERATED_MODULEMAP_DIR}/#{p.name}.modulemap\"" }
72
+ .spm_targets_for(target)
73
+ .filter_map(&:clang_modulemap_arg)
93
74
  .map { |v| prefix.nil? ? v : "#{prefix} #{v}" }
94
75
  .join(" ")
95
76
  end
77
+
78
+ def header_search_paths_for(target)
79
+ @spm_resolver
80
+ .result
81
+ .spm_targets_for(target)
82
+ .filter_map(&:header_search_path_arg)
83
+ .join(" ")
84
+ end
96
85
  end
97
86
  end
98
87
  end
@@ -1,52 +1,30 @@
1
1
  require "cocoapods-spm/hooks/base"
2
+ require "cocoapods-spm/hooks/helpers/update_script"
2
3
 
3
4
  module Pod
4
5
  module SPM
5
6
  class Hook
6
7
  class UpdateEmbedFrameworksScript < Hook
7
- def run
8
- aggregate_targets.each do |target|
9
- next if framework_paths_for(target).empty?
8
+ include UpdateScript::Mixin
10
9
 
11
- update_embed_frameworks_script(target)
12
- user_build_configurations.each_key do |config|
13
- update_embed_frameworks_script_files_path(target, config)
10
+ def run
11
+ update_script(
12
+ name: :embed_frameworks_script,
13
+ content_by_target: lambda do |target|
14
+ input_paths = framework_paths_for(target)
15
+ output_paths = input_paths.map do |p|
16
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(p)}"
17
+ end
18
+ lines = input_paths.map { |p| "install_framework \"#{p}\"" }
19
+ [lines, input_paths, output_paths]
14
20
  end
15
- end
21
+ )
16
22
  end
17
23
 
18
24
  private
19
25
 
20
26
  def framework_paths_for(target)
21
- @spm_resolver.result.spm_products_for(target).select(&:dynamic?).map do |p|
22
- "${BUILT_PRODUCTS_DIR}/PackageFrameworks/#{p.name}.framework"
23
- end
24
- end
25
-
26
- def update_embed_frameworks_script(target)
27
- lines = framework_paths_for(target).map { |p| "install_framework \"#{p}\"" }
28
- target.embed_frameworks_script_path.open("a") do |f|
29
- f << "\n" << <<~SH
30
- # --------------------------------------------------------
31
- # Added by `cocoapods-spm` to embed SPM package frameworks
32
- # --------------------------------------------------------
33
- #{lines.join("\n")}
34
- # --------------------------------------------------------
35
- SH
36
- end
37
- end
38
-
39
- def update_embed_frameworks_script_files_path(target, config)
40
- input_paths = framework_paths_for(target)
41
- output_paths = input_paths.map do |p|
42
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(p)}"
43
- end
44
- target.embed_frameworks_script_input_files_path(config).open("a") do |f|
45
- input_paths.each { |p| f << "\n" << p }
46
- end
47
- target.embed_frameworks_script_output_files_path(config).open("a") do |f|
48
- output_paths.each { |p| f << "\n" << p }
49
- end
27
+ @spm_resolver.result.spm_targets_for(target).select(&:dynamic?).map(&:built_framework_path).uniq
50
28
  end
51
29
  end
52
30
  end
@@ -0,0 +1,33 @@
1
+ require "cocoapods-spm/hooks/base"
2
+ require "cocoapods-spm/hooks/helpers/update_script"
3
+
4
+ module Pod
5
+ module SPM
6
+ class Hook
7
+ class UpdateCopyResourcesScript < Hook
8
+ include UpdateScript::Mixin
9
+
10
+ def run
11
+ update_script(
12
+ name: :copy_resources_script,
13
+ insert_before: Generator::CopyResourcesScript::RSYNC_CALL,
14
+ content_by_target: lambda do |target|
15
+ input_paths = resource_paths_for(target)
16
+ output_paths = input_paths.map do |p|
17
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/#{File.basename(p)}"
18
+ end
19
+ lines = input_paths.map { |p| "install_resource \"#{p}\"" }
20
+ [lines, input_paths, output_paths]
21
+ end
22
+ )
23
+ end
24
+
25
+ private
26
+
27
+ def resource_paths_for(target)
28
+ @spm_resolver.result.spm_targets_for(target).flat_map(&:resources).map(&:built_resource_path).uniq
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ require "cocoapods-spm/swift/package/description"
2
+
3
+ module Pod
4
+ module SPM
5
+ class MacroMetadata < Swift::PackageDescription
6
+ def self.for_pod(name)
7
+ from_file(Config.instance.macro_root_dir / name / "metadata.json")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- require "cocoapods-spm/metadata"
1
+ require "cocoapods-spm/macro/metadata"
2
2
 
3
3
  module Pod
4
4
  module SPM
@@ -26,7 +26,7 @@ module Pod
26
26
  end
27
27
 
28
28
  def macro_prebuilt_dir
29
- macro_dir / ".prebuilt"
29
+ spm_config.macro_prebuilt_root_dir / name
30
30
  end
31
31
 
32
32
  def metadata_path
@@ -39,7 +39,7 @@ module Pod
39
39
 
40
40
  raw = Dir.chdir(macro_downloaded_dir) { `swift package dump-package` }
41
41
  metadata_path.write(raw)
42
- @metadata = Metadata.from_s(raw)
42
+ @metadata = MacroMetadata.from_s(raw)
43
43
  end
44
44
 
45
45
  def prebuild_macro_impl
@@ -47,7 +47,8 @@ module Pod
47
47
 
48
48
  config = spm_config.macro_config
49
49
  impl_module_name = @metadata.macro_impl_name
50
- return if spm_config.dont_prebuild_macros_if_exist? && (macro_prebuilt_dir / config / impl_module_name).exist?
50
+ prebuilt_binary = macro_prebuilt_dir / "#{impl_module_name}-#{config}"
51
+ return if spm_config.dont_prebuild_macros_if_exist? && prebuilt_binary.exist?
51
52
 
52
53
  UI.section "Building macro implementation: #{impl_module_name} (#{config})...".green do
53
54
  Dir.chdir(macro_downloaded_dir) do
@@ -55,10 +56,10 @@ module Pod
55
56
  end
56
57
  end
57
58
 
58
- (macro_prebuilt_dir / config).mkpath
59
+ prebuilt_binary.parent.mkpath
59
60
  FileUtils.copy_entry(
60
61
  macro_downloaded_dir / ".build" / config / impl_module_name,
61
- macro_prebuilt_dir / config / impl_module_name
62
+ prebuilt_binary
62
63
  )
63
64
  end
64
65
  end
@@ -1,5 +1,6 @@
1
+ require "cocoapods-spm/helpers/io"
2
+ require "cocoapods-spm/helpers/patch"
1
3
  require "cocoapods-spm/config"
2
- require "cocoapods-spm/metadata"
3
4
  require "cocoapods-spm/executables"
4
5
  require "cocoapods-spm/def/target_definition"
5
6
  require "cocoapods-spm/def/podfile"