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.
- checksums.yaml +7 -0
- data/lib/cocoapods-spm/command/clean.rb +31 -0
- data/lib/cocoapods-spm/command/macro/deprecated.rb +35 -0
- data/lib/cocoapods-spm/command/macro/fetch.rb +33 -0
- data/lib/cocoapods-spm/command/macro/prebuild.rb +37 -0
- data/lib/cocoapods-spm/command/macro.rb +14 -0
- data/lib/cocoapods-spm/command/spm.rb +17 -0
- data/lib/cocoapods-spm/compatibility/all.rb +1 -0
- data/lib/cocoapods-spm/compatibility/rb26.rb +14 -0
- data/lib/cocoapods-spm/config/pod.rb +11 -0
- data/lib/cocoapods-spm/config/project.rb +32 -0
- data/lib/cocoapods-spm/config/spm.rb +111 -0
- data/lib/cocoapods-spm/config.rb +15 -0
- data/lib/cocoapods-spm/def/installer.rb +7 -0
- data/lib/cocoapods-spm/def/podfile.rb +80 -0
- data/lib/cocoapods-spm/def/spec.rb +26 -0
- data/lib/cocoapods-spm/def/spm_dependency.rb +24 -0
- data/lib/cocoapods-spm/def/spm_package.rb +106 -0
- data/lib/cocoapods-spm/def/target_definition.rb +15 -0
- data/lib/cocoapods-spm/def/xcodeproj.rb +38 -0
- data/lib/cocoapods-spm/executables.rb +9 -0
- data/lib/cocoapods-spm/helpers/io.rb +14 -0
- data/lib/cocoapods-spm/helpers/patch.rb +14 -0
- data/lib/cocoapods-spm/hooks/base.rb +99 -0
- data/lib/cocoapods-spm/hooks/helpers/update_script.rb +61 -0
- data/lib/cocoapods-spm/hooks/post_integrate/1.add_spm_pkgs.rb +31 -0
- data/lib/cocoapods-spm/hooks/post_integrate/5.update_settings.rb +88 -0
- data/lib/cocoapods-spm/hooks/post_integrate/6.update_embed_frameworks_script.rb +32 -0
- data/lib/cocoapods-spm/hooks/post_integrate/7.update_copy_resources_script.rb +33 -0
- data/lib/cocoapods-spm/macro/config.rb +27 -0
- data/lib/cocoapods-spm/macro/fetcher.rb +86 -0
- data/lib/cocoapods-spm/macro/metadata.rb +17 -0
- data/lib/cocoapods-spm/macro/pod_installer.rb +35 -0
- data/lib/cocoapods-spm/macro/prebuilder.rb +50 -0
- data/lib/cocoapods-spm/main.rb +13 -0
- data/lib/cocoapods-spm/patch/aggregate_target.rb +25 -0
- data/lib/cocoapods-spm/patch/installer.rb +75 -0
- data/lib/cocoapods-spm/resolver/recursive_target_resolver.rb +39 -0
- data/lib/cocoapods-spm/resolver/result.rb +73 -0
- data/lib/cocoapods-spm/resolver/target_dep_resolver.rb +64 -0
- data/lib/cocoapods-spm/resolver/umbrella_package.rb +72 -0
- data/lib/cocoapods-spm/resolver/validator.rb +32 -0
- data/lib/cocoapods-spm/resolver.rb +43 -0
- data/lib/cocoapods-spm/swift/package/base.rb +54 -0
- data/lib/cocoapods-spm/swift/package/dependency.rb +27 -0
- data/lib/cocoapods-spm/swift/package/description.rb +76 -0
- data/lib/cocoapods-spm/swift/package/product.rb +17 -0
- data/lib/cocoapods-spm/swift/package/project_packages.rb +59 -0
- data/lib/cocoapods-spm/swift/package/resources.rb +17 -0
- data/lib/cocoapods-spm/swift/package/target.rb +171 -0
- data/lib/cocoapods-spm.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 61c295a3bd5dc13beff3de299254b1e38e65f5618f11b03eb85009d3e59f91df
|
4
|
+
data.tar.gz: ae2353e7d463cbe3205e480efd0450cb202c0e0ef86819cb464b8d1b62d050ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37db7d97562b0f2024066449d190782849235134109bb04c0de6035389e12abe74469a6bbce154d14915d5928710e7cad536c7039a6c86214101cae29a1e7e2a
|
7
|
+
data.tar.gz: 4d247fb37f0b5b53feec72307bb5bfc3ab85bf50cf70b213933b2756c5c45403c7d7d6b41a53aefb987fc864e0ebeddb2b5f96ae3fea2c65f6abcab283f7879b
|
@@ -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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "cocoapods-spm/command/macro"
|
2
|
+
require "cocoapods-spm/command/clean"
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Spm < Command
|
7
|
+
include SPM::Config::Mixin
|
8
|
+
|
9
|
+
self.summary = "Working with SPM"
|
10
|
+
self.abstract_command = true
|
11
|
+
|
12
|
+
def update_cli_config(options)
|
13
|
+
spm_config.cli_config.merge!(options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "rb26"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Pod
|
2
|
+
module SPM
|
3
|
+
class Config
|
4
|
+
module ProjectConfigMixin
|
5
|
+
def project_config
|
6
|
+
ProjectConfig.instance
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class ProjectConfig
|
11
|
+
def self.instance
|
12
|
+
@instance ||= ProjectConfig.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def workspace
|
16
|
+
@workspace ||= Pod::Config.instance.podfile.defined_in_file.parent.glob("*.xcworkspace").first
|
17
|
+
end
|
18
|
+
|
19
|
+
def scheme
|
20
|
+
workspace.parent.glob("*.xcodeproj/**/*.xcscheme").first.basename(".xcscheme")
|
21
|
+
end
|
22
|
+
|
23
|
+
def default_derived_data_path
|
24
|
+
@default_derived_data_path ||= begin
|
25
|
+
raw = `xcodebuild -showBuildSettings -workspace #{workspace.shellescape} -scheme #{scheme.shellescape}`
|
26
|
+
Pathname(raw[/BUILD_DIR = (.*)/, 1]).parent.parent
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Pod
|
2
|
+
module SPM
|
3
|
+
class Config
|
4
|
+
module SPMConfigMixin
|
5
|
+
def spm_config
|
6
|
+
Config.instance
|
7
|
+
end
|
8
|
+
|
9
|
+
def macro_pods
|
10
|
+
pod_config.podfile.macro_pods
|
11
|
+
end
|
12
|
+
|
13
|
+
def local_macro_pod?(name)
|
14
|
+
!local_macro_pod_dir(name).nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def local_macro_pod_dir(name)
|
18
|
+
opts = macro_pods.fetch(name, {})
|
19
|
+
return Path(opts[:podspec]).dirname if opts.key?(:podspec)
|
20
|
+
|
21
|
+
Pathname(opts[:path]) if opts.key?(:path)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_accessor :dsl_config, :cli_config
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@dsl_config = {
|
29
|
+
:dont_prebuild_macros => false,
|
30
|
+
:dont_prebuild_macros_if_exist => true,
|
31
|
+
}
|
32
|
+
@cli_config = {}
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.instance
|
36
|
+
@instance ||= Config.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def merged_config
|
40
|
+
@dsl_config.merge(@cli_config)
|
41
|
+
end
|
42
|
+
|
43
|
+
def dont_prebuild_macros?
|
44
|
+
merged_config[:dont_prebuild_macros]
|
45
|
+
end
|
46
|
+
|
47
|
+
def dont_prebuild_macros_if_exist?
|
48
|
+
merged_config[:dont_prebuild_macros_if_exist]
|
49
|
+
end
|
50
|
+
|
51
|
+
def macro_config
|
52
|
+
merged_config[:config] || merged_config[:default_macro_config] || "debug"
|
53
|
+
end
|
54
|
+
|
55
|
+
def all_macros
|
56
|
+
@all_macros ||= Pod::Config.instance.podfile.macro_pods.keys
|
57
|
+
end
|
58
|
+
|
59
|
+
def macros
|
60
|
+
merged_config[:all] ? all_macros : (merged_config[:macros] || [])
|
61
|
+
end
|
62
|
+
|
63
|
+
def root_dir
|
64
|
+
@root_dir ||= Pathname(".spm.pods")
|
65
|
+
end
|
66
|
+
|
67
|
+
def pkg_root_dir
|
68
|
+
@pkg_root_dir ||= prepare_dir(root_dir / "packages")
|
69
|
+
end
|
70
|
+
|
71
|
+
def macro_root_dir
|
72
|
+
@macro_root_dir ||= prepare_dir(root_dir / "macros")
|
73
|
+
end
|
74
|
+
|
75
|
+
def macro_downloaded_root_dir
|
76
|
+
macro_root_dir / ".downloaded"
|
77
|
+
end
|
78
|
+
|
79
|
+
def macro_prebuilt_root_dir
|
80
|
+
macro_root_dir / ".prebuilt"
|
81
|
+
end
|
82
|
+
|
83
|
+
def macro_downloaded_sandbox
|
84
|
+
@macro_downloaded_sandbox ||= Sandbox.new(macro_downloaded_root_dir)
|
85
|
+
end
|
86
|
+
|
87
|
+
def pkg_umbrella_dir
|
88
|
+
@pkg_umbrella_dir ||= prepare_dir(pkg_root_dir / ".umbrella")
|
89
|
+
end
|
90
|
+
|
91
|
+
def pkg_checkouts_dir
|
92
|
+
pkg_umbrella_dir / ".build" / "checkouts"
|
93
|
+
end
|
94
|
+
|
95
|
+
def pkg_artifacts_dir
|
96
|
+
pkg_umbrella_dir / ".build" / "artifacts"
|
97
|
+
end
|
98
|
+
|
99
|
+
def pkg_metadata_dir
|
100
|
+
@pkg_metadata_dir ||= prepare_dir(pkg_root_dir / "metadata")
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def prepare_dir(dir)
|
106
|
+
dir.mkpath
|
107
|
+
dir
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "cocoapods-spm/config/spm"
|
2
|
+
require "cocoapods-spm/config/pod"
|
3
|
+
require "cocoapods-spm/config/project"
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
module SPM
|
7
|
+
class Config
|
8
|
+
module Mixin
|
9
|
+
include ProjectConfigMixin
|
10
|
+
include PodConfigMixin
|
11
|
+
include SPMConfigMixin
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require "cocoapods-spm/config"
|
2
|
+
require "cocoapods-spm/helpers/patch"
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Podfile
|
6
|
+
include Mixin::PatchingBehavior
|
7
|
+
attr_accessor :spm_resolver
|
8
|
+
|
9
|
+
def config_cocoapods_spm(options)
|
10
|
+
SPM::Config.instance.dsl_config.merge!(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def macro_pods
|
14
|
+
@macro_pods ||= {}
|
15
|
+
end
|
16
|
+
|
17
|
+
patch_method :pod do |name = nil, *requirements|
|
18
|
+
macro = requirements[0].delete(:macro) if requirements.first.is_a?(Hash)
|
19
|
+
macro ||= {}
|
20
|
+
unless macro.empty?
|
21
|
+
requirements[0][:path] = prepare_macro_pod_dir(name, macro).to_s
|
22
|
+
macro_pods[name] = macro
|
23
|
+
end
|
24
|
+
origin_pod(name, *requirements)
|
25
|
+
end
|
26
|
+
|
27
|
+
def spm_pkg(name, options)
|
28
|
+
current_target_definition.store_spm_pkg(name, options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def spm_pkgs
|
32
|
+
spm_pkgs_by_aggregate_target.values.flatten.uniq(&:name)
|
33
|
+
end
|
34
|
+
|
35
|
+
def spm_pkgs_for(target)
|
36
|
+
spm_pkgs_by_aggregate_target[target.to_s]
|
37
|
+
end
|
38
|
+
|
39
|
+
def spm_pkgs_by_aggregate_target
|
40
|
+
@spm_pkgs_by_aggregate_target ||= begin
|
41
|
+
dict = {}
|
42
|
+
to_visit = root_target_definitions.map { |t| [t, []] }
|
43
|
+
until to_visit.empty?
|
44
|
+
target, acc = to_visit.pop
|
45
|
+
dict[target.to_s] = (target.spm_pkgs + acc).uniq
|
46
|
+
to_visit += target.children.map { |t| [t, dict[target.to_s]] }
|
47
|
+
end
|
48
|
+
dict
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def platforms
|
53
|
+
@platforms ||= target_definition_list.filter_map { |d| d.platform&.name }.uniq || [:ios]
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def prepare_macro_pod_dir(name, requirement)
|
59
|
+
link = requirement[:git] || "N/A"
|
60
|
+
podspec_content = <<~HEREDOC
|
61
|
+
Pod::Spec.new do |s|
|
62
|
+
s.name = "#{name}"
|
63
|
+
s.version = "0.0.1"
|
64
|
+
s.summary = "#{name}"
|
65
|
+
s.description = "#{name}"
|
66
|
+
s.homepage = "#{link}"
|
67
|
+
s.license = "MIT"
|
68
|
+
s.authors = "dummy@gmail.com"
|
69
|
+
s.source = #{requirement}
|
70
|
+
s.source_files = "Sources/**/*"
|
71
|
+
end
|
72
|
+
HEREDOC
|
73
|
+
|
74
|
+
path = Pod::SPM::Config.instance.macro_root_dir / name
|
75
|
+
(path / "Sources").mkpath
|
76
|
+
(path / "#{name}.podspec").write(podspec_content)
|
77
|
+
path
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "cocoapods-spm/config"
|
2
|
+
require "cocoapods-spm/def/spm_dependency"
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Specification
|
6
|
+
def spm_dependencies
|
7
|
+
@spm_dependencies ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def spm_dependency(name, options = {})
|
11
|
+
spm_dependencies << SPM::Dependency.new(name, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def with
|
15
|
+
spec = Pod::Spec.new(
|
16
|
+
parent,
|
17
|
+
name,
|
18
|
+
test_specification,
|
19
|
+
app_specification: app_specification
|
20
|
+
)
|
21
|
+
spec.attributes_hash = attributes_hash.dup
|
22
|
+
yield spec if block_given?
|
23
|
+
spec
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pod
|
2
|
+
module SPM
|
3
|
+
class Dependency
|
4
|
+
attr_reader :name, :product
|
5
|
+
attr_accessor :pkg
|
6
|
+
|
7
|
+
def initialize(name, options = {}, product: nil, pkg: nil)
|
8
|
+
cmps = name.split("/")
|
9
|
+
raise "Invalid dependency `#{name}`" if cmps.count > 2
|
10
|
+
|
11
|
+
@name = cmps.first
|
12
|
+
@product = product || cmps.last
|
13
|
+
@options = options
|
14
|
+
@pkg = pkg
|
15
|
+
end
|
16
|
+
|
17
|
+
def inspect
|
18
|
+
"#<#{self.class} #{name}/#{product} pkg=#{pkg}>"
|
19
|
+
end
|
20
|
+
|
21
|
+
alias to_s inspect
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require "cocoapods-spm/def/xcodeproj"
|
2
|
+
require "cocoapods-spm/def/spm_dependency"
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
module SPM
|
6
|
+
class Package
|
7
|
+
attr_reader :name, :requirement, :url, :relative_path, :linking_opts
|
8
|
+
|
9
|
+
def initialize(name, options = {})
|
10
|
+
@name = name
|
11
|
+
@_options = options
|
12
|
+
@relative_path = nil
|
13
|
+
@linkage = nil
|
14
|
+
@url = nil
|
15
|
+
@requirement = nil
|
16
|
+
@linking_opts = {}
|
17
|
+
parse_options(options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse_options(options)
|
21
|
+
@url = options[:url] || options[:git]
|
22
|
+
@relative_path = relative_path_from(options)
|
23
|
+
@requirement = requirement_from(options)
|
24
|
+
@linking_opts = options[:linking] || {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def slug
|
28
|
+
@slug ||= File.basename(@url || @relative_path, ".*")
|
29
|
+
end
|
30
|
+
|
31
|
+
def absolute_path
|
32
|
+
(Pathname("Pods") / relative_path).realpath.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def relative_path_from(options)
|
36
|
+
if (relative_path = options[:relative_path])
|
37
|
+
relative_path
|
38
|
+
elsif (path = options[:path])
|
39
|
+
path = Pathname(path).expand_path
|
40
|
+
path.relative_path_from(File.absolute_path("Pods")).to_s
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def inspect
|
45
|
+
"#<#{self.class} #{name}>"
|
46
|
+
end
|
47
|
+
|
48
|
+
alias to_s inspect
|
49
|
+
|
50
|
+
def local?
|
51
|
+
@relative_path != nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def use_default_xcode_linking?
|
55
|
+
@linking_opts.fetch(:use_default_xcode_linking, false)
|
56
|
+
end
|
57
|
+
|
58
|
+
def should_exclude_from_target?(target_name)
|
59
|
+
@linking_opts.fetch(:exclude_from_targets, []).include?(target_name.delete_prefix('Pods-'))
|
60
|
+
end
|
61
|
+
|
62
|
+
def linker_flags
|
63
|
+
@linking_opts[:linker_flags] || []
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_dependencies
|
67
|
+
if (products = @_options[:products])
|
68
|
+
products.map { |product| Dependency.new(@name, product: product, pkg: self) }
|
69
|
+
else
|
70
|
+
[Dependency.new(@name, pkg: self)]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def create_pkg_ref(project)
|
75
|
+
cls = local? ? Object::XCLocalSwiftPackageReference : Object::XCRemoteSwiftPackageReference
|
76
|
+
ref = project.new(cls)
|
77
|
+
ref.name = name
|
78
|
+
if local?
|
79
|
+
ref.relative_path = relative_path
|
80
|
+
else
|
81
|
+
ref.repositoryURL = url
|
82
|
+
ref.requirement = requirement
|
83
|
+
end
|
84
|
+
ref
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def requirement_from(options)
|
90
|
+
return if @relative_path
|
91
|
+
|
92
|
+
if (requirement = options[:requirement])
|
93
|
+
requirement
|
94
|
+
elsif (version = options.delete(:version) || options.delete(:tag))
|
95
|
+
{ :kind => "exactVersion", :version => version }
|
96
|
+
elsif (branch = options.delete(:branch))
|
97
|
+
{ :kind => "branch", :branch => branch }
|
98
|
+
elsif (revision = options.delete(:commit))
|
99
|
+
{ :kind => "revision", :revision => revision }
|
100
|
+
else
|
101
|
+
raise "Missing requirement for SPM package: #{name}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "xcodeproj"
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
module SPM
|
5
|
+
module Object
|
6
|
+
module PackageReferenceMixin
|
7
|
+
attr_accessor :name
|
8
|
+
|
9
|
+
def create_pkg_product_dependency_ref(product)
|
10
|
+
ref = project.new(BaseObject::XCSwiftPackageProductDependency)
|
11
|
+
ref.package = self
|
12
|
+
ref.product_name = product
|
13
|
+
ref
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_target_dependency_ref(product)
|
17
|
+
ref = project.new(BaseObject::PBXTargetDependency)
|
18
|
+
ref.name = product
|
19
|
+
ref.product_ref = create_pkg_product_dependency_ref(product)
|
20
|
+
ref
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
BaseObject = Xcodeproj::Project::Object
|
25
|
+
|
26
|
+
class XCRemoteSwiftPackageReference < BaseObject::XCRemoteSwiftPackageReference
|
27
|
+
include PackageReferenceMixin
|
28
|
+
end
|
29
|
+
|
30
|
+
class XCLocalSwiftPackageReference < BaseObject::XCLocalSwiftPackageReference
|
31
|
+
include PackageReferenceMixin
|
32
|
+
end
|
33
|
+
|
34
|
+
class XCSwiftPackageProductDependency < BaseObject::XCSwiftPackageProductDependency
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|