xcmv 1.2.0 → 1.3.0
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 +4 -4
- data/lib/xcmv/file.rb +10 -2
- data/lib/xcmv/group_membership.rb +21 -5
- data/lib/xcmv/version.rb +1 -1
- data/lib/xcmv.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b1211a94c5f7daff4383d3aa05a5c20a65c66da
|
4
|
+
data.tar.gz: add87d0f05d8d163d14543b75fc131b0f49f9995
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 786a56f236c0f476ca80987dba5da88ca67a420e22fa614fe03a6599d8edc95f9a1b6b71eb77e1d2a62c82d49ccadd4b8f1e9014b317101fd2dc70dec4972292
|
7
|
+
data.tar.gz: 5042a1ac63777486ee675d0f8e1439636c8a0fc255c847e85579638d9c4a4180cf020b32d49302d1121f84a2f22e6150d1373a370c5fb74558b7f56fd468e143
|
data/lib/xcmv/file.rb
CHANGED
@@ -57,11 +57,19 @@ module XcodeMove
|
|
57
57
|
def add_to_targets(target_names, header_visibility)
|
58
58
|
unless target_names
|
59
59
|
group = GroupMembership.new(pbx_file.parent)
|
60
|
-
targets = group.
|
60
|
+
targets = group.inferred_targets
|
61
|
+
|
62
|
+
if targets.empty?
|
63
|
+
# fallback: if we can't infer any target membership,
|
64
|
+
# we just assign the first target of the project and emit a warning
|
65
|
+
fallback_target = project.targets.select{ |t| t.respond_to?(:source_build_phase) }[0]
|
66
|
+
targets = [fallback_target]
|
67
|
+
warn "⚠️ Warning: Unable to infer target membership of #{path} -- assigning to #{fallback_target.name}."
|
68
|
+
end
|
61
69
|
else
|
62
70
|
name_set = target_names.to_set
|
63
71
|
targets = project.targets.select{ |t| name_set.include?(t.name) }
|
64
|
-
abort "No targets found in #{target_names}" if targets.empty?
|
72
|
+
abort "🛑 Error: No targets found in #{target_names}." if targets.empty?
|
65
73
|
end
|
66
74
|
|
67
75
|
targets.each do |target|
|
@@ -1,18 +1,34 @@
|
|
1
|
+
class Xcodeproj::Project::Object::PBXGroup
|
2
|
+
# Returns an array of targets that have build files in `group`.
|
3
|
+
def sibling_targets
|
4
|
+
siblings = children.to_set
|
5
|
+
compiled_targets = project.targets.select{ |t| t.respond_to?(:source_build_phase) }
|
6
|
+
compiled_targets.select{ |t| t.source_build_phase.files_references.any?{ |f| siblings.include?(f) } }
|
7
|
+
end
|
8
|
+
end
|
1
9
|
|
2
10
|
module XcodeMove
|
3
11
|
class GroupMembership
|
12
|
+
attr_reader :group, :project
|
4
13
|
def initialize(group)
|
5
14
|
@group = group
|
6
15
|
@project = group.project
|
7
16
|
@siblings = @group.children.to_set
|
8
17
|
end
|
9
18
|
|
10
|
-
# Returns an array of targets that
|
11
|
-
|
12
|
-
|
13
|
-
|
19
|
+
# Returns an array of targets that the `group` should reasonably
|
20
|
+
# belong to -- either based on `sibling_targets` or the `sibling_targets`
|
21
|
+
# of some ancestor group.
|
22
|
+
def inferred_targets
|
23
|
+
target_group = self.group
|
24
|
+
targets = []
|
25
|
+
while targets.empty? and target_group.respond_to?(:sibling_targets) do
|
26
|
+
targets += target_group.sibling_targets
|
27
|
+
target_group = target_group.parent
|
28
|
+
end
|
29
|
+
targets
|
14
30
|
end
|
15
|
-
|
31
|
+
|
16
32
|
def max_header_visibility(target)
|
17
33
|
sibling_headers = target.headers_build_phase.files.filter{ |f| @siblings.include?(file_ref) }
|
18
34
|
sibling_headers.map{ |f| HeaderVisibility.from_file_settings(f.settings) }.max
|
data/lib/xcmv/version.rb
CHANGED
data/lib/xcmv.rb
CHANGED
@@ -10,7 +10,7 @@ module XcodeMove
|
|
10
10
|
# Moves from one `Pathname` to another
|
11
11
|
def self.mv(src, dst, options)
|
12
12
|
src_file = src.directory? ? Group.new(src) : File.new(src)
|
13
|
-
dst_file = src_file.with_dirname(dst)
|
13
|
+
dst_file = src_file.with_dirname(dst.dirname)
|
14
14
|
|
15
15
|
puts("#{src_file.path} => #{dst_file.path}")
|
16
16
|
|
@@ -45,7 +45,7 @@ module XcodeMove
|
|
45
45
|
if src_file.pbx_file
|
46
46
|
src_file.remove_from_project
|
47
47
|
else
|
48
|
-
warn("
|
48
|
+
warn("⚠️ Warning: #{src.path.basename} not found in #{src.project.path.basename}, moving anyway...")
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|