cocoapods-spm2 0.1.10

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 (53) hide show
  1. checksums.yaml +7 -0
  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 +17 -0
  8. data/lib/cocoapods-spm/compatibility/all.rb +1 -0
  9. data/lib/cocoapods-spm/compatibility/rb26.rb +14 -0
  10. data/lib/cocoapods-spm/config/pod.rb +11 -0
  11. data/lib/cocoapods-spm/config/project.rb +32 -0
  12. data/lib/cocoapods-spm/config/spm.rb +111 -0
  13. data/lib/cocoapods-spm/config.rb +15 -0
  14. data/lib/cocoapods-spm/def/installer.rb +7 -0
  15. data/lib/cocoapods-spm/def/podfile.rb +80 -0
  16. data/lib/cocoapods-spm/def/spec.rb +26 -0
  17. data/lib/cocoapods-spm/def/spm_dependency.rb +24 -0
  18. data/lib/cocoapods-spm/def/spm_package.rb +106 -0
  19. data/lib/cocoapods-spm/def/target_definition.rb +15 -0
  20. data/lib/cocoapods-spm/def/xcodeproj.rb +38 -0
  21. data/lib/cocoapods-spm/executables.rb +9 -0
  22. data/lib/cocoapods-spm/helpers/io.rb +14 -0
  23. data/lib/cocoapods-spm/helpers/patch.rb +14 -0
  24. data/lib/cocoapods-spm/hooks/base.rb +99 -0
  25. data/lib/cocoapods-spm/hooks/helpers/update_script.rb +61 -0
  26. data/lib/cocoapods-spm/hooks/post_integrate/1.add_spm_pkgs.rb +31 -0
  27. data/lib/cocoapods-spm/hooks/post_integrate/5.update_settings.rb +88 -0
  28. data/lib/cocoapods-spm/hooks/post_integrate/6.update_embed_frameworks_script.rb +32 -0
  29. data/lib/cocoapods-spm/hooks/post_integrate/7.update_copy_resources_script.rb +33 -0
  30. data/lib/cocoapods-spm/macro/config.rb +27 -0
  31. data/lib/cocoapods-spm/macro/fetcher.rb +86 -0
  32. data/lib/cocoapods-spm/macro/metadata.rb +17 -0
  33. data/lib/cocoapods-spm/macro/pod_installer.rb +35 -0
  34. data/lib/cocoapods-spm/macro/prebuilder.rb +50 -0
  35. data/lib/cocoapods-spm/main.rb +13 -0
  36. data/lib/cocoapods-spm/patch/aggregate_target.rb +25 -0
  37. data/lib/cocoapods-spm/patch/installer.rb +75 -0
  38. data/lib/cocoapods-spm/resolver/recursive_target_resolver.rb +39 -0
  39. data/lib/cocoapods-spm/resolver/result.rb +73 -0
  40. data/lib/cocoapods-spm/resolver/target_dep_resolver.rb +64 -0
  41. data/lib/cocoapods-spm/resolver/umbrella_package.rb +72 -0
  42. data/lib/cocoapods-spm/resolver/validator.rb +32 -0
  43. data/lib/cocoapods-spm/resolver.rb +43 -0
  44. data/lib/cocoapods-spm/swift/package/base.rb +54 -0
  45. data/lib/cocoapods-spm/swift/package/dependency.rb +27 -0
  46. data/lib/cocoapods-spm/swift/package/description.rb +76 -0
  47. data/lib/cocoapods-spm/swift/package/product.rb +17 -0
  48. data/lib/cocoapods-spm/swift/package/project_packages.rb +59 -0
  49. data/lib/cocoapods-spm/swift/package/resources.rb +17 -0
  50. data/lib/cocoapods-spm/swift/package/target.rb +171 -0
  51. data/lib/cocoapods-spm.rb +1 -0
  52. data/lib/cocoapods_plugin.rb +1 -0
  53. metadata +108 -0
@@ -0,0 +1,171 @@
1
+ require "cocoapods-spm/swift/package/base"
2
+
3
+ module Pod
4
+ module Swift
5
+ class PackageDescription
6
+ autoload :Resources, "cocoapods-spm/swift/package/resources"
7
+
8
+ class Target < PackageDescriptionBaseObject
9
+ def type
10
+ raw["type"]
11
+ end
12
+
13
+ def macro?
14
+ type == "macro"
15
+ end
16
+
17
+ def binary?
18
+ return @binary unless @binary.nil?
19
+
20
+ @binary = type == "binary"
21
+ end
22
+
23
+ def dynamic?
24
+ @dynamic
25
+ end
26
+
27
+ def framework_name
28
+ @product_name || name
29
+ end
30
+
31
+ def sources_path
32
+ @sources_path ||= begin
33
+ path = raw["path"] || "Sources/#{name}"
34
+ root.src_dir / path
35
+ end
36
+ end
37
+
38
+ def public_headers_path_expr
39
+ @public_headers_path_expr ||= public_headers_path.to_s.sub(
40
+ root.checkouts_dir.to_s,
41
+ "${SOURCE_PACKAGES_CHECKOUTS_DIR}"
42
+ )
43
+ end
44
+
45
+ def header_search_path_arg
46
+ "\"#{public_headers_path_expr}\"" unless public_headers_path.nil?
47
+ end
48
+
49
+ def public_headers_path
50
+ res = sources_path / raw["publicHeadersPath"] if raw.key?("publicHeadersPath")
51
+ res = implicit_public_headers if res.nil?
52
+ res
53
+ end
54
+
55
+ def implicit_public_headers
56
+ path = sources_path / "include"
57
+ path unless path.glob("**/*.h*").empty?
58
+ end
59
+
60
+ def modulemap_path
61
+ @modulemap_path ||= public_headers_path&.glob("*.modulemap")&.first
62
+ end
63
+
64
+ def clang_modulemap_path_expr
65
+ return "#{public_headers_path_expr}/#{modulemap_path.basename}" unless modulemap_path.nil?
66
+
67
+ "${GENERATED_MODULEMAP_DIR}/#{name}.modulemap" unless binary?
68
+ end
69
+
70
+ def clang_modulemap_arg
71
+ "-fmodule-map-file=\"#{clang_modulemap_path_expr}\"" unless clang_modulemap_path_expr.nil?
72
+ end
73
+
74
+ def resources
75
+ res = raw.fetch("resources", []).flat_map { |h| Resources.new(h, parent: self) }
76
+ res = implicit_resources if res.empty?
77
+ res
78
+ end
79
+
80
+ def implicit_resources
81
+ target_sources_path = raw["path"] || "Sources/#{name}"
82
+ target_sources_path = root.src_dir / target_sources_path
83
+
84
+ # Refer to the following link for the implicit resources
85
+ # https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package#Add-resource-files
86
+ patterns = [
87
+ "*.xcassets",
88
+ "*.xib",
89
+ "*.storyboard",
90
+ "*.xcdatamodeld",
91
+ "*.lproj",
92
+ ]
93
+ return [] if patterns.all? { |p| target_sources_path.glob(p).empty? }
94
+
95
+ [Resources.new({}, parent: self)]
96
+ end
97
+
98
+ def linker_flags
99
+ return ["-framework \"#{framework_name}\""] if dynamic?
100
+ return ["-l\"#{name}.o\""] unless binary?
101
+
102
+ case binary_basename
103
+ when /(\S+)\.framework/ then ["-framework \"#{$1}\""]
104
+ when /lib(\S+)\.(a|dylib)/ then ["-l\"#{$1}\""]
105
+ when /(\S+\.(a|dylib))/ then ["\"${PODS_CONFIGURATION_BUILD_DIR}/#{$1}\""]
106
+ else []
107
+ end
108
+ end
109
+
110
+ def resolve_dependencies(pkg_desc_cache, platform: nil)
111
+ raw.fetch("dependencies", []).flat_map do |hash|
112
+ type = ["byName", "target", "product"].find { |k| hash.key?(k) }
113
+ if type.nil?
114
+ raise Informative, "Unexpected dependency type. Must be either `byName`, `target`, or `product`."
115
+ end
116
+ next [] unless match_platform?(hash[type][-1], platform)
117
+
118
+ name = hash[type][0]
119
+ pkg_name = hash.key?("product") ? hash["product"][1] : self.pkg_name
120
+ pkg_desc = pkg_desc_cache[pkg_name]
121
+ find_by_target = -> { pkg_desc.targets.select { |t| t.name == name } }
122
+ find_by_product = -> { pkg_desc.targets_of_product(name) }
123
+ next find_by_target.call if hash.key?("target")
124
+ next find_by_product.call if hash.key?("product")
125
+
126
+ # byName, could be either a target or a product
127
+ next find_by_target.call || find_by_product.call
128
+ end
129
+ end
130
+
131
+ def built_framework_path
132
+ "${BUILT_PRODUCTS_DIR}/PackageFrameworks/#{framework_name}.framework"
133
+ end
134
+
135
+ def xcframework
136
+ @xcframework ||= begin
137
+ path = (root.artifacts_dir / name).glob("*.xcframework")[0]
138
+ Xcode::XCFramework.new(name, path.realpath) unless path.nil?
139
+ end
140
+ end
141
+
142
+ def binary_basename
143
+ return nil unless binary?
144
+
145
+ @binary_basename ||= begin
146
+ xcframework_dir ||= (root.artifacts_dir / name).glob("*.xcframework")[0]
147
+ xcframework_dir ||= root.src_dir / raw["path"] if raw.key?("path")
148
+ paths = xcframework_dir.glob("*/*.{a,framework}")
149
+ UI.warn "Cannot detect binary_basename for #{name}" if paths.empty?
150
+ paths[0].basename.to_s unless paths.empty?
151
+ end
152
+ end
153
+
154
+ def use_default_xcode_linking?
155
+ root.use_default_xcode_linking?
156
+ end
157
+
158
+ private
159
+
160
+ def match_platform?(condition, platform)
161
+ # Consider matching if there's no condition
162
+ return true if condition.nil? || !condition.key?("platformNames")
163
+
164
+ # macos is called osx in Cocoapods.
165
+ platform_name = platform.to_s == 'osx' ? 'macos' : platform.to_s
166
+ condition["platformNames"].include?(platform_name)
167
+ end
168
+ end
169
+ end
170
+ end
171
+ end
@@ -0,0 +1 @@
1
+ require "cocoapods-spm/gem_version"
@@ -0,0 +1 @@
1
+ require "cocoapods-spm/main"
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-spm2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.10
5
+ platform: ruby
6
+ authors:
7
+ - Michael Ledger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-12-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xcodeproj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.23.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.23.0
27
+ description: CocoaPods plugin to add SPM dependencies to CocoaPods targets
28
+ email:
29
+ - MichaelLedger@163.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/cocoapods-spm.rb
35
+ - lib/cocoapods-spm/command/clean.rb
36
+ - lib/cocoapods-spm/command/macro.rb
37
+ - lib/cocoapods-spm/command/macro/deprecated.rb
38
+ - lib/cocoapods-spm/command/macro/fetch.rb
39
+ - lib/cocoapods-spm/command/macro/prebuild.rb
40
+ - lib/cocoapods-spm/command/spm.rb
41
+ - lib/cocoapods-spm/compatibility/all.rb
42
+ - lib/cocoapods-spm/compatibility/rb26.rb
43
+ - lib/cocoapods-spm/config.rb
44
+ - lib/cocoapods-spm/config/pod.rb
45
+ - lib/cocoapods-spm/config/project.rb
46
+ - lib/cocoapods-spm/config/spm.rb
47
+ - lib/cocoapods-spm/def/installer.rb
48
+ - lib/cocoapods-spm/def/podfile.rb
49
+ - lib/cocoapods-spm/def/spec.rb
50
+ - lib/cocoapods-spm/def/spm_dependency.rb
51
+ - lib/cocoapods-spm/def/spm_package.rb
52
+ - lib/cocoapods-spm/def/target_definition.rb
53
+ - lib/cocoapods-spm/def/xcodeproj.rb
54
+ - lib/cocoapods-spm/executables.rb
55
+ - lib/cocoapods-spm/helpers/io.rb
56
+ - lib/cocoapods-spm/helpers/patch.rb
57
+ - lib/cocoapods-spm/hooks/base.rb
58
+ - 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
63
+ - lib/cocoapods-spm/macro/config.rb
64
+ - lib/cocoapods-spm/macro/fetcher.rb
65
+ - lib/cocoapods-spm/macro/metadata.rb
66
+ - lib/cocoapods-spm/macro/pod_installer.rb
67
+ - lib/cocoapods-spm/macro/prebuilder.rb
68
+ - lib/cocoapods-spm/main.rb
69
+ - lib/cocoapods-spm/patch/aggregate_target.rb
70
+ - lib/cocoapods-spm/patch/installer.rb
71
+ - lib/cocoapods-spm/resolver.rb
72
+ - lib/cocoapods-spm/resolver/recursive_target_resolver.rb
73
+ - lib/cocoapods-spm/resolver/result.rb
74
+ - lib/cocoapods-spm/resolver/target_dep_resolver.rb
75
+ - lib/cocoapods-spm/resolver/umbrella_package.rb
76
+ - lib/cocoapods-spm/resolver/validator.rb
77
+ - lib/cocoapods-spm/swift/package/base.rb
78
+ - lib/cocoapods-spm/swift/package/dependency.rb
79
+ - lib/cocoapods-spm/swift/package/description.rb
80
+ - lib/cocoapods-spm/swift/package/product.rb
81
+ - lib/cocoapods-spm/swift/package/project_packages.rb
82
+ - lib/cocoapods-spm/swift/package/resources.rb
83
+ - lib/cocoapods-spm/swift/package/target.rb
84
+ - lib/cocoapods_plugin.rb
85
+ homepage: https://github.com/MichaelLedger/cocoapods-spm
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubygems_version: 3.5.21
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: CocoaPods plugin to add SPM dependencies to CocoaPods targets
108
+ test_files: []