xcodeproj 0.5.5 → 0.6.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/README.md +1 -0
- data/lib/xcodeproj.rb +2 -1
- data/lib/xcodeproj/config.rb +2 -1
- data/lib/xcodeproj/scheme.rb +272 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68eed1e98656c82c9900d49e52bd8c22b3a82ccf
|
|
4
|
+
data.tar.gz: 06e3be0d616290a94bc7bd6abd1b12a8d719e153
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71f4b96a96f05f285440bd3ee45e75979284d06e4a432e29959ebe9944cd76e87ce7cf373e195155c02ff42b9cd7bf945af411b3c3013d32a128f2a32c6e76fa
|
|
7
|
+
data.tar.gz: 8e79143ff631216843b156982acf94dff0f1d12e46d8822dbe147068ef49abfc4a234003315aad21db1cf8bddb3496f54d8da405fba2bbf1e44471e13a4af512
|
data/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://travis-ci.org/CocoaPods/Xcodeproj)
|
|
4
4
|
[](https://coveralls.io/r/CocoaPods/Xcodeproj)
|
|
5
|
+
[](https://codeclimate.com/github/CocoaPods/Xcodeproj)
|
|
5
6
|
|
|
6
7
|
Xcodeproj lets you create and modify Xcode projects from [Ruby][ruby].
|
|
7
8
|
Script boring management tasks or build Xcode-friendly libraries. Also includes
|
data/lib/xcodeproj.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Xcodeproj
|
|
2
|
-
VERSION = '0.
|
|
2
|
+
VERSION = '0.6.0' unless defined? Xcodeproj::VERSION
|
|
3
3
|
|
|
4
4
|
class PlainInformative < StandardError
|
|
5
5
|
end
|
|
@@ -18,4 +18,5 @@ module Xcodeproj
|
|
|
18
18
|
autoload :Project, 'xcodeproj/project'
|
|
19
19
|
autoload :UI, 'xcodeproj/user_interface'
|
|
20
20
|
autoload :Workspace, 'xcodeproj/workspace'
|
|
21
|
+
autoload :XCScheme, 'xcodeproj/scheme'
|
|
21
22
|
end
|
data/lib/xcodeproj/config.rb
CHANGED
|
@@ -67,7 +67,8 @@ module Xcodeproj
|
|
|
67
67
|
# @return [String] The serialized internal data.
|
|
68
68
|
#
|
|
69
69
|
def to_s
|
|
70
|
-
|
|
70
|
+
[includes.map { |i| "#include \"#{i}\""} +
|
|
71
|
+
to_hash.sort_by(&:first).map { |k, v| "#{k} = #{v}" }].join("\n")
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
# Writes the serialized representation of the internal data to the given
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
require 'rexml/document'
|
|
2
|
+
|
|
3
|
+
module Xcodeproj
|
|
4
|
+
|
|
5
|
+
# This class represents a Scheme document represented by a ".xcscheme" file usually stored
|
|
6
|
+
# in a xcuserdata or xcshareddata (for a shared scheme) folder.
|
|
7
|
+
#
|
|
8
|
+
class XCScheme
|
|
9
|
+
|
|
10
|
+
# @return [REXML::Document] the XML object that will be manipulated to save the scheme file after.
|
|
11
|
+
#
|
|
12
|
+
attr_reader :doc
|
|
13
|
+
|
|
14
|
+
# @return [String] the name of the container (the project name file without the extension) that have the targets
|
|
15
|
+
# used by the scheme.
|
|
16
|
+
#
|
|
17
|
+
attr_reader :container
|
|
18
|
+
|
|
19
|
+
# @return [Xcodeproj::Project::Object::AbstractTarget] the target used by scheme in the build step.
|
|
20
|
+
#
|
|
21
|
+
attr_reader :build_target
|
|
22
|
+
|
|
23
|
+
# @return [Xcodeproj::Project::Object::AbstractTarget] the target used by scheme in the test step.
|
|
24
|
+
#
|
|
25
|
+
attr_reader :test_target
|
|
26
|
+
|
|
27
|
+
# Share a User Scheme. Basically this method move the xcscheme file from the xcuserdata folder to xcshareddata
|
|
28
|
+
# folder.
|
|
29
|
+
#
|
|
30
|
+
# @param project_path [String] Path of the .xcodeproj folder.
|
|
31
|
+
#
|
|
32
|
+
# @param scheme_name [String] The name of scheme that will be shared.
|
|
33
|
+
#
|
|
34
|
+
# @param user [String] The user name that have the scheme
|
|
35
|
+
#
|
|
36
|
+
def self.share_scheme(project_path, scheme_name, user = ENV['USER'])
|
|
37
|
+
from = File.join project_path, 'xcuserdata', "#{user}.xcuserdatad", 'xcschemes', "#{scheme_name}.xcscheme"
|
|
38
|
+
to_folder = File.join project_path, 'xcshareddata', 'xcschemes'
|
|
39
|
+
Pathname(to_folder).mkpath
|
|
40
|
+
to = File.join to_folder, "#{scheme_name}.xcscheme"
|
|
41
|
+
FileUtils.mv from, to
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Create a new XCScheme instance
|
|
45
|
+
#
|
|
46
|
+
# @param [String] container
|
|
47
|
+
# The name of the container (the project name file without the extension) that have the targets used by the
|
|
48
|
+
# scheme.
|
|
49
|
+
#
|
|
50
|
+
# @param [Xcodeproj::Project::Object::AbstractTarget] build_target
|
|
51
|
+
# The target used by scheme in the build step.
|
|
52
|
+
#
|
|
53
|
+
# @param [Xcodeproj::Project::Object::AbstractTarget] test_target
|
|
54
|
+
# The target used by scheme in the test step.
|
|
55
|
+
#
|
|
56
|
+
# @example
|
|
57
|
+
# Xcodeproj::XCScheme.new 'Cocoa Application', project.targets[0], project.targets[1]
|
|
58
|
+
#
|
|
59
|
+
def initialize(container, build_target, test_target = nil)
|
|
60
|
+
@container = container
|
|
61
|
+
@build_target = build_target
|
|
62
|
+
@test_target = test_target
|
|
63
|
+
|
|
64
|
+
@doc = REXML::Document.new
|
|
65
|
+
@doc << REXML::XMLDecl.new(REXML::XMLDecl::DEFAULT_VERSION, 'UTF-8')
|
|
66
|
+
@doc.context[:attribute_quote] = :quote
|
|
67
|
+
|
|
68
|
+
scheme = @doc.add_element 'Scheme'
|
|
69
|
+
scheme.attributes['LastUpgradeVersion'] = build_target.project.root_object.attributes['LastUpgradeCheck']
|
|
70
|
+
scheme.attributes['version'] = '1.3'
|
|
71
|
+
|
|
72
|
+
build_action = scheme.add_element 'BuildAction'
|
|
73
|
+
build_action.attributes['parallelizeBuildables'] = 'YES'
|
|
74
|
+
build_action.attributes['buildImplicitDependencies'] = 'YES'
|
|
75
|
+
|
|
76
|
+
if (build_target.product_type == 'com.apple.product-type.application') then
|
|
77
|
+
build_action_entries = build_action.add_element 'BuildActionEntries'
|
|
78
|
+
|
|
79
|
+
build_action_entry = build_action_entries.add_element 'BuildActionEntry'
|
|
80
|
+
build_action_entry.attributes['buildForTesting'] = 'YES'
|
|
81
|
+
build_action_entry.attributes['buildForRunning'] = 'YES'
|
|
82
|
+
build_action_entry.attributes['buildForProfiling'] = 'YES'
|
|
83
|
+
build_action_entry.attributes['buildForArchiving'] = 'YES'
|
|
84
|
+
build_action_entry.attributes['buildForAnalyzing'] = 'YES'
|
|
85
|
+
|
|
86
|
+
buildable_reference = build_action_entry.add_element 'BuildableReference'
|
|
87
|
+
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
|
88
|
+
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
|
89
|
+
buildable_reference.attributes['BuildableName'] = "#{build_target.name}.app"
|
|
90
|
+
buildable_reference.attributes['BlueprintName'] = build_target.name
|
|
91
|
+
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
test_action = scheme.add_element 'TestAction'
|
|
95
|
+
test_action.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
|
|
96
|
+
test_action.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
|
|
97
|
+
test_action.attributes['shouldUseLaunchSchemeArgsEnv'] = 'YES'
|
|
98
|
+
test_action.attributes['buildConfiguration'] = 'Debug'
|
|
99
|
+
|
|
100
|
+
testables = test_action.add_element 'Testables'
|
|
101
|
+
|
|
102
|
+
if (test_target != nil) then
|
|
103
|
+
testable_reference = testables.add_element 'TestableReference'
|
|
104
|
+
testable_reference.attributes['skipped'] = 'NO'
|
|
105
|
+
|
|
106
|
+
buildable_reference = testable_reference.add_element 'BuildableReference'
|
|
107
|
+
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
|
108
|
+
buildable_reference.attributes['BlueprintIdentifier'] = test_target.uuid
|
|
109
|
+
buildable_reference.attributes['BuildableName'] = "#{test_target.name}.octest"
|
|
110
|
+
buildable_reference.attributes['BlueprintName'] = test_target.name
|
|
111
|
+
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
|
112
|
+
|
|
113
|
+
if (build_target.product_type == 'com.apple.product-type.application') then
|
|
114
|
+
macro_expansion = test_action.add_element 'MacroExpansion'
|
|
115
|
+
|
|
116
|
+
buildable_reference = macro_expansion.add_element 'BuildableReference'
|
|
117
|
+
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
|
118
|
+
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
|
119
|
+
buildable_reference.attributes['BuildableName'] = "#{build_target.name}.app"
|
|
120
|
+
buildable_reference.attributes['BlueprintName'] = build_target.name
|
|
121
|
+
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
launch_action = scheme.add_element 'LaunchAction'
|
|
126
|
+
launch_action.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
|
|
127
|
+
launch_action.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
|
|
128
|
+
launch_action.attributes['launchStyle'] = '0'
|
|
129
|
+
launch_action.attributes['useCustomWorkingDirectory'] = 'NO'
|
|
130
|
+
launch_action.attributes['buildConfiguration'] = 'Debug'
|
|
131
|
+
launch_action.attributes['ignoresPersistentStateOnLaunch'] = 'NO'
|
|
132
|
+
launch_action.attributes['debugDocumentVersioning'] = 'YES'
|
|
133
|
+
launch_action.attributes['allowLocationSimulation'] = 'YES'
|
|
134
|
+
|
|
135
|
+
if (build_target.product_type == 'com.apple.product-type.application') then
|
|
136
|
+
buildable_product_runnable = launch_action.add_element 'BuildableProductRunnable'
|
|
137
|
+
|
|
138
|
+
buildable_reference = buildable_product_runnable.add_element 'BuildableReference'
|
|
139
|
+
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
|
140
|
+
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
|
141
|
+
buildable_reference.attributes['BuildableName'] = "#{build_target.name}.app"
|
|
142
|
+
buildable_reference.attributes['BlueprintName'] = build_target.name
|
|
143
|
+
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
additional_options = launch_action.add_element 'AdditionalOptions'
|
|
147
|
+
|
|
148
|
+
profile_action = scheme.add_element 'ProfileAction'
|
|
149
|
+
profile_action.attributes['shouldUseLaunchSchemeArgsEnv'] = 'YES'
|
|
150
|
+
profile_action.attributes['savedToolIdentifier'] = ''
|
|
151
|
+
profile_action.attributes['useCustomWorkingDirectory'] = 'NO'
|
|
152
|
+
profile_action.attributes['buildConfiguration'] = 'Release'
|
|
153
|
+
profile_action.attributes['debugDocumentVersioning'] = 'YES'
|
|
154
|
+
|
|
155
|
+
if (build_target.product_type == 'com.apple.product-type.application') then
|
|
156
|
+
buildable_product_runnable = profile_action.add_element 'BuildableProductRunnable'
|
|
157
|
+
|
|
158
|
+
buildable_reference = buildable_product_runnable.add_element 'BuildableReference'
|
|
159
|
+
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
|
160
|
+
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
|
161
|
+
buildable_reference.attributes['BuildableName'] = "#{build_target.name}.app"
|
|
162
|
+
buildable_reference.attributes['BlueprintName'] = build_target.name
|
|
163
|
+
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
analyze_action = scheme.add_element 'AnalyzeAction'
|
|
167
|
+
analyze_action.attributes['buildConfiguration'] = 'Debug'
|
|
168
|
+
|
|
169
|
+
archive_action = scheme.add_element 'ArchiveAction'
|
|
170
|
+
archive_action.attributes['buildConfiguration'] = 'Release'
|
|
171
|
+
archive_action.attributes['revealArchiveInOrganizer'] = 'YES'
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Returns the current value if the build target must be runned during the build step.
|
|
175
|
+
#
|
|
176
|
+
# @return [Boolean]
|
|
177
|
+
# true => run during the build step
|
|
178
|
+
# false => not run during the build step
|
|
179
|
+
#
|
|
180
|
+
def build_target_for_running?
|
|
181
|
+
build_target_for_running = ''
|
|
182
|
+
|
|
183
|
+
if build_action = @doc.root.elements['BuildAction']
|
|
184
|
+
if build_action_entries = build_action.elements['BuildActionEntries']
|
|
185
|
+
if build_action_entry = build_action_entries.elements['BuildActionEntry']
|
|
186
|
+
build_target_for_running = build_action_entry.attributes['buildForRunning']
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
build_target_for_running == 'YES'
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Set the build target to run or not run during the build step.
|
|
195
|
+
# Useful for cases where the build target is a unit test bundle.
|
|
196
|
+
#
|
|
197
|
+
# @param [Boolean] build_target_for_running
|
|
198
|
+
# true => run during the build step
|
|
199
|
+
# false => not run during the build step
|
|
200
|
+
#
|
|
201
|
+
def build_target_for_running=(build_target_for_running)
|
|
202
|
+
build_action = @doc.root.elements['BuildAction']
|
|
203
|
+
|
|
204
|
+
if (build_action.elements['BuildActionEntries'] == nil) then
|
|
205
|
+
build_action_entries = build_action.add_element 'BuildActionEntries'
|
|
206
|
+
else
|
|
207
|
+
build_action_entries = build_action.elements['BuildActionEntries']
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
if (build_action_entries.elements['BuildActionEntry'] == nil) then
|
|
211
|
+
build_action_entry = build_action_entries.add_element 'BuildActionEntry'
|
|
212
|
+
build_action_entry.attributes['buildForTesting'] = 'YES'
|
|
213
|
+
build_action_entry.attributes['buildForProfiling'] = 'NO'
|
|
214
|
+
build_action_entry.attributes['buildForArchiving'] = 'NO'
|
|
215
|
+
build_action_entry.attributes['buildForAnalyzing'] = 'NO'
|
|
216
|
+
else
|
|
217
|
+
build_action_entry = build_action_entries.elements['BuildActionEntry']
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
build_action_entry.attributes['buildForRunning'] = build_target_for_running ? 'YES' : 'NO'
|
|
221
|
+
|
|
222
|
+
if (build_action_entry.elements['BuildableReference'] == nil) then
|
|
223
|
+
buildable_reference = build_action_entry.add_element 'BuildableReference'
|
|
224
|
+
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
|
225
|
+
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
|
226
|
+
buildable_reference.attributes['BuildableName'] = "#{build_target.name}.octest"
|
|
227
|
+
buildable_reference.attributes['BlueprintName'] = build_target.name
|
|
228
|
+
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Serializes the current state of the object to a String
|
|
233
|
+
#
|
|
234
|
+
# @return [String] the XML string value of the current state of the object
|
|
235
|
+
#
|
|
236
|
+
def to_s
|
|
237
|
+
formatter = REXML::Formatters::Pretty.new(2)
|
|
238
|
+
formatter.compact = true
|
|
239
|
+
out = ''
|
|
240
|
+
formatter.write(@doc, out)
|
|
241
|
+
out
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# Serializes the current state of the object to a ".xcscheme" file.
|
|
245
|
+
#
|
|
246
|
+
# @param [String, Pathname] project_path
|
|
247
|
+
# The path where the ".xcscheme" file should be stored.
|
|
248
|
+
#
|
|
249
|
+
# @param [Boolean] shared
|
|
250
|
+
# true => if the scheme must be a shared scheme (default value)
|
|
251
|
+
# false => if the scheme must be a user scheme
|
|
252
|
+
#
|
|
253
|
+
# @return [void]
|
|
254
|
+
#
|
|
255
|
+
# @example Saving a scheme
|
|
256
|
+
# scheme.save_as('path/to/Project.xcodeproj') #=> true
|
|
257
|
+
#
|
|
258
|
+
def save_as(project_path, shared = true)
|
|
259
|
+
if shared then
|
|
260
|
+
scheme_folder_path = File.join(project_path, 'xcshareddata', 'xcschemes')
|
|
261
|
+
else
|
|
262
|
+
scheme_folder_path = File.join(project_path, 'xcuserdata', "#{ENV['USER']}.xcuserdatad", 'xcschemes')
|
|
263
|
+
end
|
|
264
|
+
Pathname(scheme_folder_path).mkpath
|
|
265
|
+
scheme_path = File.join(scheme_folder_path, "#{build_target.display_name}.xcscheme")
|
|
266
|
+
File.open(scheme_path, 'w') do |f|
|
|
267
|
+
f.write(self)
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
end
|
|
272
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: xcodeproj
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eloy Duran
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-
|
|
11
|
+
date: 2013-05-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -73,6 +73,7 @@ files:
|
|
|
73
73
|
- lib/xcodeproj/project/object_dictionary.rb
|
|
74
74
|
- lib/xcodeproj/project/object_list.rb
|
|
75
75
|
- lib/xcodeproj/project.rb
|
|
76
|
+
- lib/xcodeproj/scheme.rb
|
|
76
77
|
- lib/xcodeproj/user_interface.rb
|
|
77
78
|
- lib/xcodeproj/workspace.rb
|
|
78
79
|
- lib/xcodeproj.rb
|
|
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
102
103
|
version: '0'
|
|
103
104
|
requirements: []
|
|
104
105
|
rubyforge_project:
|
|
105
|
-
rubygems_version: 2.0.
|
|
106
|
+
rubygems_version: 2.0.3
|
|
106
107
|
signing_key:
|
|
107
108
|
specification_version: 3
|
|
108
109
|
summary: Create and modify Xcode projects from Ruby.
|