xcodeproject_swift 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +30 -0
- data/.rspec +2 -0
- data/.rubocop.yml +37 -0
- data/.travis.yml +13 -0
- data/.yardopts +7 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +192 -0
- data/Rakefile +11 -0
- data/lib/xcodeproject.rb +2 -0
- data/lib/xcodeproject/build_phase_node.rb +111 -0
- data/lib/xcodeproject/data.rb +89 -0
- data/lib/xcodeproject/exceptions.rb +29 -0
- data/lib/xcodeproject/extend/array.rb +32 -0
- data/lib/xcodeproject/extend/hash.rb +35 -0
- data/lib/xcodeproject/extend/string.rb +31 -0
- data/lib/xcodeproject/file_node.rb +86 -0
- data/lib/xcodeproject/formatter.rb +47 -0
- data/lib/xcodeproject/node.rb +42 -0
- data/lib/xcodeproject/pbx_build_file.rb +63 -0
- data/lib/xcodeproject/pbx_file_reference.rb +82 -0
- data/lib/xcodeproject/pbx_group.rb +204 -0
- data/lib/xcodeproject/pbx_native_target.rb +94 -0
- data/lib/xcodeproject/pbx_project.rb +57 -0
- data/lib/xcodeproject/project.rb +72 -0
- data/lib/xcodeproject/root_node.rb +127 -0
- data/lib/xcodeproject/tasks/build_task.rb +59 -0
- data/lib/xcodeproject/uuid_generator.rb +37 -0
- data/lib/xcodeproject/version.rb +27 -0
- data/lib/xcodeproject/xc_build_configuration.rb +98 -0
- data/lib/xcodeproject/xc_configuration_list.rb +47 -0
- data/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-a.h +1 -0
- data/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-a.m +1 -0
- data/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-r.h +1 -0
- data/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-r.m +1 -0
- data/resources/example/dir1b/dir2b/file3b.m +0 -0
- data/resources/example/dir1b/file2b.m +0 -0
- data/resources/example/dir1c/file2c.h +0 -0
- data/resources/example/dir1c/file2c.m +0 -0
- data/resources/example/example.xcodeproj/project.pbxproj +324 -0
- data/resources/example/example/AppDelegate.h +7 -0
- data/resources/example/example/AppDelegate.m +49 -0
- data/resources/example/example/en.lproj/InfoPlist.strings +2 -0
- data/resources/example/example/example-Info.plist +45 -0
- data/resources/example/example/example-Prefix.pch +14 -0
- data/resources/example/example/main.m +10 -0
- data/spec/build_phase_node_spec.rb +103 -0
- data/spec/file_node_spec.rb +58 -0
- data/spec/pbx_build_file_spec.rb +26 -0
- data/spec/pbx_file_reference_spec.rb +42 -0
- data/spec/pbx_group_spec.rb +360 -0
- data/spec/pbx_native_target_spec.rb +62 -0
- data/spec/pbx_project_spec.rb +39 -0
- data/spec/project_spec.rb +86 -0
- data/spec/spec_helper.rb +67 -0
- data/spec/support/shared_examples/file_node_shared_examples.rb +27 -0
- data/spec/xc_build_configuration_spec.rb +114 -0
- data/spec/xc_configuration_list_spec.rb +23 -0
- data/xcodeproject.gemspec +29 -0
- metadata +233 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
#--
|
2
|
+
# The MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012-2014 Andrei Nesterov <ae.nesterov@gmail.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
require 'xcodeproject/root_node'
|
26
|
+
|
27
|
+
module XcodeProject
|
28
|
+
class Data
|
29
|
+
def initialize(data, wd)
|
30
|
+
@root = RootNode.new(data, wd)
|
31
|
+
end
|
32
|
+
|
33
|
+
def project
|
34
|
+
@root.project
|
35
|
+
end
|
36
|
+
|
37
|
+
def targets
|
38
|
+
project.targets
|
39
|
+
end
|
40
|
+
|
41
|
+
def target(name)
|
42
|
+
project.target(name)
|
43
|
+
end
|
44
|
+
|
45
|
+
def main_group
|
46
|
+
project.main_group
|
47
|
+
end
|
48
|
+
|
49
|
+
def group(gpath)
|
50
|
+
main_group.group(gpath)
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_group(gpath)
|
54
|
+
main_group.add_group(gpath)
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_dir(parent_gpath, path)
|
58
|
+
main_group.add_group(parent_gpath).add_dir(path)
|
59
|
+
end
|
60
|
+
|
61
|
+
def remove_group(gpath)
|
62
|
+
main_group.remove_group(gpath)
|
63
|
+
end
|
64
|
+
|
65
|
+
def file(gpath)
|
66
|
+
main_group.file(gpath)
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_file(parent_gpath, path)
|
70
|
+
main_group.add_group(parent_gpath).add_file(path)
|
71
|
+
end
|
72
|
+
|
73
|
+
def remove_file(gpath)
|
74
|
+
main_group.remove_file(gpath)
|
75
|
+
end
|
76
|
+
|
77
|
+
def doctor
|
78
|
+
targets.each(&:doctor)
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_plist(_fmtr = Formatter.new)
|
82
|
+
@root.to_plist
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
attr_accessor :root
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#--
|
2
|
+
# The MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012-2014 Andrei Nesterov <ae.nesterov@gmail.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
module XcodeProject
|
26
|
+
class ParseError < StandardError; end
|
27
|
+
class FilePathError < StandardError; end
|
28
|
+
class GroupPathError < StandardError; end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#--
|
2
|
+
# The MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012-2014 Andrei Nesterov <ae.nesterov@gmail.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
require 'xcodeproject/formatter'
|
26
|
+
|
27
|
+
class Array
|
28
|
+
def to_plist(fmtr = XcodeProject::Formatter.new)
|
29
|
+
items = map { |item| item.to_plist(fmtr).to_s }
|
30
|
+
%{(#{fmtr.t2}#{items.join(",#{fmtr.t2}")}#{fmtr.t1})}
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#--
|
2
|
+
# The MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012-2014 Andrei Nesterov <ae.nesterov@gmail.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
require 'xcodeproject/formatter'
|
26
|
+
|
27
|
+
class Hash
|
28
|
+
def to_plist(fmtr = XcodeProject::Formatter.new)
|
29
|
+
fmtr.inc
|
30
|
+
items = map { |key, value| "#{key.to_plist(fmtr)} = #{value.to_plist(fmtr)};" }
|
31
|
+
fmtr.dec
|
32
|
+
|
33
|
+
%({#{fmtr.t2}#{items.join(fmtr.t2.to_s)}#{fmtr.t1}})
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#--
|
2
|
+
# The MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012-2014 Andrei Nesterov <ae.nesterov@gmail.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
require 'json'
|
26
|
+
|
27
|
+
class String
|
28
|
+
def to_plist(_fmtr = nil)
|
29
|
+
to_json
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#--
|
2
|
+
# The MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012-2014 Andrei Nesterov <ae.nesterov@gmail.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
require 'xcodeproject/node'
|
26
|
+
require 'pathname'
|
27
|
+
|
28
|
+
module XcodeProject
|
29
|
+
class FileNode < Node
|
30
|
+
attr_reader :name
|
31
|
+
attr_reader :path
|
32
|
+
attr_reader :source_tree
|
33
|
+
|
34
|
+
def initialize(root, uuid, data)
|
35
|
+
super(root, uuid, data)
|
36
|
+
|
37
|
+
@source_tree = data['sourceTree']
|
38
|
+
@name ||= data['name']
|
39
|
+
@path ||= data['path']
|
40
|
+
|
41
|
+
@name ||= File.basename(@path) unless @path.nil?
|
42
|
+
end
|
43
|
+
|
44
|
+
def source_tree
|
45
|
+
SourceTreeMap[@source_tree]
|
46
|
+
end
|
47
|
+
|
48
|
+
def parent
|
49
|
+
root.select_objects { |_uuid, data|
|
50
|
+
(data['children'].include?(uuid) if data['isa'] == 'PBXGroup') ? true : false
|
51
|
+
}.first
|
52
|
+
end
|
53
|
+
|
54
|
+
def group_path
|
55
|
+
obj = self
|
56
|
+
res = ''
|
57
|
+
loop do
|
58
|
+
pn = obj.name ? obj.name : ''
|
59
|
+
res = Pathname.new(pn).join(res)
|
60
|
+
break unless (obj = obj.parent)
|
61
|
+
end
|
62
|
+
res.cleanpath
|
63
|
+
end
|
64
|
+
|
65
|
+
def total_path
|
66
|
+
res = ''
|
67
|
+
case source_tree
|
68
|
+
when :source_root
|
69
|
+
res = path
|
70
|
+
when :group
|
71
|
+
pn = path.nil? ? '' : path
|
72
|
+
res = parent.total_path.join(pn) unless parent.nil?
|
73
|
+
else
|
74
|
+
raise ParseError, "No such '#{source_tree}' source tree type."
|
75
|
+
end
|
76
|
+
root.absolute_path(res)
|
77
|
+
end
|
78
|
+
|
79
|
+
private_class_method
|
80
|
+
|
81
|
+
SourceTreeMap = {
|
82
|
+
'SOURCE_ROOT' => :source_root,
|
83
|
+
'<group>' => :group
|
84
|
+
}.freeze
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#--
|
2
|
+
# The MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012-2014 Andrei Nesterov <ae.nesterov@gmail.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
module XcodeProject
|
26
|
+
class Formatter
|
27
|
+
def initialize
|
28
|
+
@counter = 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def inc
|
32
|
+
@counter += 1
|
33
|
+
end
|
34
|
+
|
35
|
+
def dec
|
36
|
+
@counter -= 1
|
37
|
+
end
|
38
|
+
|
39
|
+
def t1
|
40
|
+
"\n" + "\t" * @counter
|
41
|
+
end
|
42
|
+
|
43
|
+
def t2
|
44
|
+
"\n" + "\t" * (@counter + 1)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#--
|
2
|
+
# The MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012-2014 Andrei Nesterov <ae.nesterov@gmail.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
module XcodeProject
|
26
|
+
class Node
|
27
|
+
attr_reader :uuid
|
28
|
+
attr_reader :isa
|
29
|
+
|
30
|
+
def initialize(root, uuid, data)
|
31
|
+
@root = root
|
32
|
+
@uuid = uuid
|
33
|
+
@data = data
|
34
|
+
@isa = data['isa']
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
attr_accessor :root
|
40
|
+
attr_accessor :data
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#--
|
2
|
+
# The MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012-2014 Andrei Nesterov <ae.nesterov@gmail.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
require 'xcodeproject/node'
|
26
|
+
|
27
|
+
module XcodeProject
|
28
|
+
class PBXBuildFile < Node
|
29
|
+
attr_reader :file_ref
|
30
|
+
|
31
|
+
def initialize(root, uuid, data)
|
32
|
+
super(root, uuid, data)
|
33
|
+
|
34
|
+
@file_ref = data['fileRef']
|
35
|
+
end
|
36
|
+
|
37
|
+
def file_ref
|
38
|
+
root.object!(@file_ref)
|
39
|
+
end
|
40
|
+
|
41
|
+
def remove!
|
42
|
+
root.project.targets.each do |target|
|
43
|
+
target.remove_source(self)
|
44
|
+
end
|
45
|
+
root.remove_object(uuid)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.add(root, file_ref_uuid)
|
49
|
+
uuid, data = root.add_object(create_object_hash(file_ref_uuid))
|
50
|
+
new(root, uuid, data)
|
51
|
+
end
|
52
|
+
|
53
|
+
private_class_method
|
54
|
+
|
55
|
+
def self.create_object_hash(file_ref_uuid)
|
56
|
+
data = []
|
57
|
+
data << %w[isa PBXBuildFile]
|
58
|
+
data << ['fileRef', file_ref_uuid]
|
59
|
+
|
60
|
+
Hash[data]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|