xcodeproject_swift 0.3.13

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 (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +30 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +37 -0
  5. data/.travis.yml +13 -0
  6. data/.yardopts +7 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE +22 -0
  9. data/README.md +192 -0
  10. data/Rakefile +11 -0
  11. data/lib/xcodeproject.rb +2 -0
  12. data/lib/xcodeproject/build_phase_node.rb +111 -0
  13. data/lib/xcodeproject/data.rb +89 -0
  14. data/lib/xcodeproject/exceptions.rb +29 -0
  15. data/lib/xcodeproject/extend/array.rb +32 -0
  16. data/lib/xcodeproject/extend/hash.rb +35 -0
  17. data/lib/xcodeproject/extend/string.rb +31 -0
  18. data/lib/xcodeproject/file_node.rb +86 -0
  19. data/lib/xcodeproject/formatter.rb +47 -0
  20. data/lib/xcodeproject/node.rb +42 -0
  21. data/lib/xcodeproject/pbx_build_file.rb +63 -0
  22. data/lib/xcodeproject/pbx_file_reference.rb +82 -0
  23. data/lib/xcodeproject/pbx_group.rb +204 -0
  24. data/lib/xcodeproject/pbx_native_target.rb +94 -0
  25. data/lib/xcodeproject/pbx_project.rb +57 -0
  26. data/lib/xcodeproject/project.rb +72 -0
  27. data/lib/xcodeproject/root_node.rb +127 -0
  28. data/lib/xcodeproject/tasks/build_task.rb +59 -0
  29. data/lib/xcodeproject/uuid_generator.rb +37 -0
  30. data/lib/xcodeproject/version.rb +27 -0
  31. data/lib/xcodeproject/xc_build_configuration.rb +98 -0
  32. data/lib/xcodeproject/xc_configuration_list.rb +47 -0
  33. data/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-a.h +1 -0
  34. data/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-a.m +1 -0
  35. data/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-r.h +1 -0
  36. data/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-r.m +1 -0
  37. data/resources/example/dir1b/dir2b/file3b.m +0 -0
  38. data/resources/example/dir1b/file2b.m +0 -0
  39. data/resources/example/dir1c/file2c.h +0 -0
  40. data/resources/example/dir1c/file2c.m +0 -0
  41. data/resources/example/example.xcodeproj/project.pbxproj +324 -0
  42. data/resources/example/example/AppDelegate.h +7 -0
  43. data/resources/example/example/AppDelegate.m +49 -0
  44. data/resources/example/example/en.lproj/InfoPlist.strings +2 -0
  45. data/resources/example/example/example-Info.plist +45 -0
  46. data/resources/example/example/example-Prefix.pch +14 -0
  47. data/resources/example/example/main.m +10 -0
  48. data/spec/build_phase_node_spec.rb +103 -0
  49. data/spec/file_node_spec.rb +58 -0
  50. data/spec/pbx_build_file_spec.rb +26 -0
  51. data/spec/pbx_file_reference_spec.rb +42 -0
  52. data/spec/pbx_group_spec.rb +360 -0
  53. data/spec/pbx_native_target_spec.rb +62 -0
  54. data/spec/pbx_project_spec.rb +39 -0
  55. data/spec/project_spec.rb +86 -0
  56. data/spec/spec_helper.rb +67 -0
  57. data/spec/support/shared_examples/file_node_shared_examples.rb +27 -0
  58. data/spec/xc_build_configuration_spec.rb +114 -0
  59. data/spec/xc_configuration_list_spec.rb +23 -0
  60. data/xcodeproject.gemspec +29 -0
  61. metadata +233 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f03beca96de3362617d2b51f3fac84bf60a2ebdd
4
+ data.tar.gz: 65df8e76bf32b322b10aa27c8cf13d92a5d605a0
5
+ SHA512:
6
+ metadata.gz: 74dc353bf6b1ba4fcc485e6ae05fc7727d27acbc573b6199e227e73b9670826c42d698dbcdc998106b235b9c2fce777b0e2046eb66744410f90f7c19751c1853
7
+ data.tar.gz: a225739a421cf15b0b314a42d8d468fa1e8e44c578af6f3be90102653e7880d738dfc26c5512919b42de5db33a8f8d66adcea1b0625f31b2b7b8e09db3a158ca
data/.gitignore ADDED
@@ -0,0 +1,30 @@
1
+ # OSX
2
+ .DS_Store
3
+ ._*
4
+ .Spotlight-V100
5
+ .Trashes
6
+
7
+ # vim
8
+ .*.sw[a-z]
9
+ *.un~
10
+ Session.vim
11
+
12
+ # ruby
13
+ *.gem
14
+ *.rbc
15
+ .bundle
16
+ .config
17
+ .idea
18
+ .yardoc
19
+ Gemfile.lock
20
+ InstalledFiles
21
+ _yardoc
22
+ coverage
23
+ doc/
24
+ lib/bundler/man
25
+ pkg
26
+ rdoc
27
+ spec/reports
28
+ test/tmp
29
+ test/version_tmp
30
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.rubocop.yml ADDED
@@ -0,0 +1,37 @@
1
+ Documentation:
2
+ Enabled: false
3
+ Style/BlockDelimiters:
4
+ EnforcedStyle: semantic
5
+ Style/BracesAroundHashParameters:
6
+ EnforcedStyle: context_dependent
7
+ Style/IndentHash:
8
+ Enabled: false
9
+ Style/Lambda:
10
+ Enabled: false
11
+ Style/MultilineTernaryOperator:
12
+ Enabled: false
13
+ Style/MutableConstant:
14
+ Enabled: false
15
+ Style/NumericLiterals:
16
+ Enabled: false
17
+ Style/PercentLiteralDelimiters:
18
+ PreferredDelimiters:
19
+ '%i': '[]'
20
+ '%w': '[]'
21
+ '%W': '[]'
22
+ Style/MultilineMethodCallIndentation:
23
+ EnforcedStyle: indented
24
+ Lint/EndAlignment:
25
+ AlignWith: variable
26
+ Metrics/BlockNesting:
27
+ Enabled: false
28
+ Metrics/LineLength:
29
+ Max: 140
30
+ Metrics/MethodLength:
31
+ Max: 25
32
+ Metrics/ClassLength:
33
+ Max: 150
34
+ Metrics/CyclomaticComplexity:
35
+ Max: 10
36
+ Metrics/AbcSize:
37
+ Max: 40
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0-p481
4
+ - 2.1.0
5
+ - 2.1.1
6
+ - 2.1.2
7
+ - 2.1.3
8
+ - 2.1.4
9
+ - 2.1.5
10
+ - 2.3.1
11
+ before_install: gem update --remote bundler
12
+ install:
13
+ - bundle install --retry=3
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --markup markdown
2
+ --markup-provider redcarpet
3
+ --charset utf-8
4
+ --readme README.md
5
+ -
6
+ README.md
7
+ LICENSE
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in xcodeproject.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Andrei Nesterov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,192 @@
1
+ XcodeProject
2
+ ===
3
+ The Ruby API for working with Xcode project files.
4
+
5
+ [![Pledgie Badge][pledgie_img]][pledgie]
6
+
7
+ [![Build Status][travis_img]][travis]
8
+
9
+ Installation
10
+ ---
11
+ `gem install xcodeproject`
12
+
13
+ Getting started
14
+ ---
15
+ A simple example that displays all targets of the project will look like this:
16
+
17
+ ```ruby
18
+ require 'rubygems'
19
+ require 'xcodeproject'
20
+
21
+ proj = XcodeProject::Project.new('path/to/example.xcodeproj')
22
+ proj.read.targets.each do |target|
23
+ puts target.name
24
+ end
25
+ ```
26
+
27
+ First, you must create an XcodeProject::Project object like this:
28
+
29
+ ```ruby
30
+ proj = XcodeProject::Project.new('path/to/example.xcodeproj')
31
+ ```
32
+
33
+ Or you can find all projects are located in the specified directory:
34
+
35
+ ```ruby
36
+ projs = XcodeProject::Project.find('path/to/dir')
37
+ ```
38
+
39
+ Or by specified directory pattern:
40
+
41
+ ```ruby
42
+ projs = XcodeProject::Project.find('*/**')
43
+ ```
44
+
45
+ After creating the project object, you can read the data from it:
46
+
47
+ ```ruby
48
+ data = proj.read
49
+ p data.target('example').config('Release').build_settings
50
+ ```
51
+
52
+ Or rewrite data:
53
+
54
+ ```ruby
55
+ proj.change do |data|
56
+ data.target('example').config('Release').build_settings['GCC_VERSION'] = 'com.apple.compilers.llvmgcc42'
57
+ end
58
+ ```
59
+
60
+ Files, groups and directories
61
+ ---
62
+ Displaying all of top-level groups:
63
+
64
+ ```ruby
65
+ data.main_group.children.each do |child|
66
+ p child.name
67
+ end
68
+ ```
69
+
70
+ Displaying files of specified group:
71
+
72
+ ```ruby
73
+ group = data.group('path/from/main_group')
74
+ group.files.each do |file|
75
+ p file.name
76
+ end
77
+ ```
78
+
79
+ You can get group's (or file's) group path (the path from the main group):
80
+
81
+ ```ruby
82
+ group.group_path
83
+ ```
84
+
85
+ Directories are groups that are explicitly represented in the file system. For them, you can also get a file path:
86
+
87
+ ```ruby
88
+ group.total_path
89
+ ```
90
+
91
+ You can add a group to project by specifying the path from the main group:
92
+
93
+ ```ruby
94
+ data.add_group('path/from/main_group')
95
+ ```
96
+
97
+ Or from the current group:
98
+
99
+ ```ruby
100
+ group.add_group('path/from/current_group')
101
+ ```
102
+
103
+ To add a directory to the project, you must specify the file path:
104
+
105
+ ```ruby
106
+ data.add_dir('group_path/to/parent', '/file_path/to/dir')
107
+ group.add_dir('/file_path/to/dir')
108
+ ```
109
+
110
+ Adding files are same:
111
+
112
+ ```ruby
113
+ data.add_file('group_path/to/parent', '/file_path/to/file')
114
+ group.add_file('/file_path/to/file')
115
+ ```
116
+
117
+ You can also remove files, groups and directories from the project:
118
+
119
+ ```ruby
120
+ data.remove_file('path/from/main_group')
121
+ data.remove_group('path/from/main_group')
122
+
123
+ group.remove_file('path/from/current_group')
124
+ group.remove_group('path/from/current_group')
125
+ ```
126
+
127
+ Targets
128
+ ---
129
+ Getting the target object is simple:
130
+
131
+ ```ruby
132
+ target = data.target('example')
133
+ ```
134
+
135
+ After adding a file to the project, you can add it to target's build phase:
136
+
137
+ ```ruby
138
+ file = main_group.add_file('/file_path/to/file')
139
+ target.add_source(file)
140
+ ```
141
+
142
+ Or remove from target's build phase:
143
+
144
+ ```ruby
145
+ target.remove_source(file)
146
+ ```
147
+
148
+ Building the project
149
+ ---
150
+ XcodeProject uses Rake and XcodeBuilder for building projects.
151
+
152
+ You need to create a `rakefile`, a simple look like this:
153
+
154
+ ```ruby
155
+ require 'rubygems'
156
+ require 'xcodeproject'
157
+
158
+ proj = XcodeProject::Project.new('path/to/example.xcodeproj')
159
+ XcodeProject::Tasks::BuildTask.new(proj)
160
+ ```
161
+
162
+ You will now have access to a variety of tasks such as clean and build. A full list of tasks can be viewed by running `rake -T`:
163
+
164
+ ```sh
165
+ $ rake -T
166
+ rake example:archive # Creates an archive build of the specified target(s).
167
+ rake example:build # Builds the specified target(s).
168
+ rake example:clean # Cleans the build using the same build settings.
169
+ rake example:cleanbuild # Builds the specified target(s) from a clean slate.
170
+ ```
171
+
172
+ Configuring your tasks:
173
+
174
+ ```ruby
175
+ XcodeProject::Tasks::BuildTask.new(proj) do |t|
176
+ t.target = "libexample"
177
+ t.configuration = "Release"
178
+ end
179
+ ```
180
+
181
+ You can find out more about XcodeBuilder [here][xcodebuilder].
182
+
183
+ License
184
+ ---
185
+ XcodeProject is provided under the terms of the [the MIT license][license]
186
+
187
+ [xcodebuilder]:https://github.com/lukeredpath/xcodebuild-rb
188
+ [license]:http://www.opensource.org/licenses/MIT
189
+ [pledgie]:http://pledgie.com/campaigns/17599
190
+ [pledgie_img]:http://www.pledgie.com/campaigns/17599.png?skin_name=chrome
191
+ [travis]:http://travis-ci.org/manifest/xcodeproject
192
+ [travis_img]:https://secure.travis-ci.org/manifest/xcodeproject.png
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'rubygems'
4
+ require 'bundler/gem_tasks'
5
+ require 'rspec/core/rake_task'
6
+ require 'yard'
7
+
8
+ RSpec::Core::RakeTask.new
9
+ YARD::Rake::YardocTask.new
10
+
11
+ task default: :build
@@ -0,0 +1,2 @@
1
+ require 'xcodeproject/project'
2
+ require 'xcodeproject/version'
@@ -0,0 +1,111 @@
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 'xcodeproject/pbx_build_file'
27
+
28
+ module XcodeProject
29
+ class BuildPhaseNode < Node
30
+ def initialize(root, uuid, data)
31
+ super(root, uuid, data)
32
+ @files = data['files']
33
+ end
34
+
35
+ def files
36
+ build_files.map(&:file_ref)
37
+ end
38
+
39
+ def add_file(file_obj)
40
+ case file_obj
41
+ when PBXFileReference
42
+ add_build_file(file_obj.uuid)
43
+ when PBXBuildFile
44
+ add_build_file_uuid(file_obj.uuid)
45
+ else
46
+ raise ArgumentError, 'Wrong argument type, expected the PBXFileReference or PBXBuildFile.'
47
+ end
48
+ end
49
+
50
+ def remove_file(file_obj)
51
+ case file_obj
52
+ when PBXFileReference
53
+ remove_build_file(file_obj.uuid)
54
+ when PBXBuildFile
55
+ remove_build_file_uuid(file_obj.uuid)
56
+ else
57
+ raise ArgumentError, 'Wrong argument type, expected the PBXFileReference or PBXBuildFile.'
58
+ end
59
+ end
60
+
61
+ def doctor
62
+ @files.each do |uuid|
63
+ obj = root.object(uuid)
64
+ if obj.nil?
65
+ remove_build_file_uuid(uuid)
66
+ puts "removed #{uuid}"
67
+ end
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def build_files
74
+ @files.map { |uuid| root.object!(uuid) }
75
+ end
76
+
77
+ def build_file(file_ref_uuid)
78
+ build_files.select { |obj| obj.file_ref.uuid == file_ref_uuid }.first
79
+ end
80
+
81
+ def add_build_file(file_ref_uuid)
82
+ obj = build_file(file_ref_uuid)
83
+ if obj.nil?
84
+ obj = PBXBuildFile.add(root, file_ref_uuid)
85
+ add_build_file_uuid(obj.uuid)
86
+ end
87
+ obj
88
+ end
89
+
90
+ def remove_build_file(file_ref_uuid)
91
+ obj = build_file(file_ref_uuid)
92
+ remove_build_file_uuid(obj.uuid) unless obj.nil?
93
+ end
94
+
95
+ def add_build_file_uuid(build_file_uuid)
96
+ @files << build_file_uuid unless @files.include?(build_file_uuid)
97
+ end
98
+
99
+ def remove_build_file_uuid(build_file_uuid)
100
+ @files.delete(build_file_uuid)
101
+ end
102
+ end
103
+
104
+ class PBXSourcesBuildPhase < BuildPhaseNode; end
105
+ class PBXHeadersBuildPhase < BuildPhaseNode; end
106
+ class PBXResourcesBuildPhase < BuildPhaseNode; end
107
+ class PBXFrameworksBuildPhase < BuildPhaseNode; end
108
+ class PBXAppleScriptBuildPhase < BuildPhaseNode; end
109
+ class PBXShellScriptBuildPhase < BuildPhaseNode; end
110
+ class PBXCopyFilesBuildPhase < BuildPhaseNode; end
111
+ end