xcodeproj 0.8.1 → 0.9.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 +7 -0
- data/lib/xcodeproj/constants.rb +10 -4
- data/lib/xcodeproj/project/object/group.rb +118 -12
- data/lib/xcodeproj/project/object/native_target.rb +39 -0
- data/lib/xcodeproj/project/object/root_object.rb +1 -1
- data/lib/xcodeproj/project/object/target_dependency.rb +1 -1
- data/lib/xcodeproj/project/project_helper.rb +254 -0
- data/lib/xcodeproj/project.rb +19 -107
- data/lib/xcodeproj/scheme.rb +109 -66
- data/lib/xcodeproj/xcodebuild_helper.rb +96 -0
- data/lib/xcodeproj.rb +11 -10
- metadata +49 -66
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 529ed72e9f63e78ad2b0ca1a550ff4316ef1606f
|
4
|
+
data.tar.gz: 43bfe6819ebde4b4e6d1a1f4ce8bd49891663254
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 16a8b646d24a0cf360732816343f08daa455271e8909ae6c2ccc7b1fe9f05f4f4750544ea9af40798969e8aa4f7de30efc7ec53adc42f928fdc71897b3e75e25
|
7
|
+
data.tar.gz: ba101e58ee80931f8991c64f23b0a001bfb59ec27f6decd7c22e22b625f15b65da3aa1c0ec032ef336db39b92e7ef23a483d2853492418c049663f5d1ed61698
|
data/lib/xcodeproj/constants.rb
CHANGED
@@ -20,6 +20,10 @@ module Xcodeproj
|
|
20
20
|
#
|
21
21
|
LAST_KNOWN_OBJECT_VERSION = 46
|
22
22
|
|
23
|
+
# @return [String] The last known object version to Xcodeproj.
|
24
|
+
#
|
25
|
+
LAST_UPGRADE_CHECK = '0450'
|
26
|
+
|
23
27
|
# @return [Hash] The all the known ISAs grouped by superclass.
|
24
28
|
#
|
25
29
|
KNOWN_ISAS = {
|
@@ -69,6 +73,7 @@ module Xcodeproj
|
|
69
73
|
'application' => 'wrapper.application',
|
70
74
|
'dylib' => 'compiled.mach-o.dylib',
|
71
75
|
'framework' => 'wrapper.framework',
|
76
|
+
'bundle' => 'wrapper.plug-in',
|
72
77
|
'h' => 'sourcecode.c.h',
|
73
78
|
'm' => 'sourcecode.c.objc',
|
74
79
|
'pch' => 'sourcecode.c.h',
|
@@ -83,10 +88,11 @@ module Xcodeproj
|
|
83
88
|
# @return [Hash] The uniform type identifier of various product types.
|
84
89
|
#
|
85
90
|
PRODUCT_TYPE_UTI = {
|
86
|
-
:application
|
87
|
-
:framework
|
88
|
-
:dynamic_library
|
89
|
-
:static_library
|
91
|
+
:application => 'com.apple.product-type.application',
|
92
|
+
:framework => 'com.apple.product-type.framework',
|
93
|
+
:dynamic_library => 'com.apple.product-type.library.dynamic',
|
94
|
+
:static_library => 'com.apple.product-type.library.static',
|
95
|
+
:bundle => 'com.apple.product-type.bundle',
|
90
96
|
}.freeze
|
91
97
|
|
92
98
|
# @return [Hash] The common build settings grouped by platform, and build
|
@@ -99,6 +99,18 @@ module Xcodeproj
|
|
99
99
|
children.select { |obj| obj.class == PBXGroup }
|
100
100
|
end
|
101
101
|
|
102
|
+
# @return [Array<PBXGroup,PBXFileReference,PBXReferenceProxy>] the
|
103
|
+
# recursive children of the group.
|
104
|
+
#
|
105
|
+
def recursive_children_groups
|
106
|
+
result = []
|
107
|
+
groups.each do |child|
|
108
|
+
result << child
|
109
|
+
result.concat(child.recursive_children_groups)
|
110
|
+
end
|
111
|
+
result
|
112
|
+
end
|
113
|
+
|
102
114
|
# @return [Array<XCVersionGroup>] the version groups in the group
|
103
115
|
# children.
|
104
116
|
#
|
@@ -125,20 +137,99 @@ module Xcodeproj
|
|
125
137
|
#
|
126
138
|
# @return [PBXFileReference] the new file reference.
|
127
139
|
#
|
128
|
-
def new_file(path, sub_group_path = nil
|
129
|
-
|
130
|
-
|
131
|
-
|
140
|
+
def new_file(path, sub_group_path = nil)
|
141
|
+
extname = File.extname(path)
|
142
|
+
case
|
143
|
+
when extname == '.framework' then new_framework(path, sub_group_path)
|
144
|
+
when extname == '.xcdatamodeld' then new_xcdatamodeld(path, sub_group_path)
|
145
|
+
else new_file_reference(path, sub_group_path)
|
146
|
+
end
|
147
|
+
end
|
132
148
|
|
133
|
-
|
134
|
-
|
149
|
+
# Creates a new file reference with the given path and adds it to the
|
150
|
+
# group or to an optional subpath.
|
151
|
+
#
|
152
|
+
# @note @see #new_file
|
153
|
+
#
|
154
|
+
# @param @see #new_file
|
155
|
+
#
|
156
|
+
# @return [PBXFileReference] the new file reference.
|
157
|
+
#
|
158
|
+
def new_file_reference(path, sub_group_path = nil)
|
159
|
+
ref = project.new(PBXFileReference)
|
160
|
+
ref.path = path.to_s
|
161
|
+
ref.update_last_known_file_type
|
135
162
|
|
136
|
-
|
137
|
-
|
163
|
+
parent_group = find_subpath(sub_group_path, true)
|
164
|
+
parent_group.children << ref
|
165
|
+
set_file_refenrece_name_if_needed(ref, parent_group)
|
166
|
+
ref
|
167
|
+
end
|
168
|
+
|
169
|
+
# Sets the name of a reference if needed, to match Xcode behaviour.
|
170
|
+
#
|
171
|
+
# @param [PBXFileReference, XCVersionGroup] ref
|
172
|
+
# the reference which needs the name optionally set.
|
173
|
+
#
|
174
|
+
# @return [void]
|
175
|
+
#
|
176
|
+
def set_file_refenrece_name_if_needed(ref, parent_group)
|
177
|
+
same_path_of_group = (parent_group.path == Pathname(ref.path).dirname.to_s)
|
178
|
+
same_path_project = (Pathname(ref.path).dirname.to_s == '.' && parent_group.path.nil?)
|
138
179
|
unless same_path_of_group || same_path_project
|
139
|
-
|
180
|
+
ref.name = Pathname(ref.path).basename.to_s
|
140
181
|
end
|
141
|
-
|
182
|
+
end
|
183
|
+
|
184
|
+
# Creates a new file reference to a framework bundle.
|
185
|
+
#
|
186
|
+
# @note @see #new_file
|
187
|
+
#
|
188
|
+
# @param @see #new_file
|
189
|
+
#
|
190
|
+
# @return [PBXFileReference] the new file reference.
|
191
|
+
#
|
192
|
+
def new_framework(path, sub_group_path = nil)
|
193
|
+
ref = new_file_reference(path, sub_group_path = nil)
|
194
|
+
ref.include_in_index = nil
|
195
|
+
ref
|
196
|
+
end
|
197
|
+
|
198
|
+
# Creates a new version group reference to an xcdatamodeled adding the
|
199
|
+
# xcdatamodel files included in the wrapper as chidren file references.
|
200
|
+
#
|
201
|
+
# @note To match Xcode behaviour the last xcdatamodel according to its
|
202
|
+
# path is set as the current version.
|
203
|
+
#
|
204
|
+
# @note @see #new_file
|
205
|
+
#
|
206
|
+
# @param @see #new_file
|
207
|
+
#
|
208
|
+
# @return [XCVersionGroup] the new reference.
|
209
|
+
#
|
210
|
+
def new_xcdatamodeld(path, sub_group_path = nil)
|
211
|
+
path = Pathname.new(path)
|
212
|
+
ref = project.new(XCVersionGroup)
|
213
|
+
ref.path = path.to_s
|
214
|
+
ref.source_tree = '<group>'
|
215
|
+
ref.version_group_type = 'wrapper.xcdatamodel'
|
216
|
+
|
217
|
+
last_child_ref = nil
|
218
|
+
if path.exist?
|
219
|
+
path.children.each do |child_path|
|
220
|
+
if File.extname(child_path) == '.xcdatamodel'
|
221
|
+
child_ref = ref.new_file_reference(child_path)
|
222
|
+
child_ref.source_tree = '<group>'
|
223
|
+
last_child_ref = child_ref
|
224
|
+
end
|
225
|
+
end
|
226
|
+
ref.current_version = last_child_ref
|
227
|
+
end
|
228
|
+
|
229
|
+
parent_group = find_subpath(sub_group_path, true)
|
230
|
+
parent_group.children << ref
|
231
|
+
set_file_refenrece_name_if_needed(ref, parent_group)
|
232
|
+
ref
|
142
233
|
end
|
143
234
|
|
144
235
|
# Creates a new group with the given name and adds it to the children
|
@@ -172,7 +263,7 @@ module Xcodeproj
|
|
172
263
|
#
|
173
264
|
# @param [String] sub_group_path @see new_file
|
174
265
|
#
|
175
|
-
# @return [PBXFileReference] the new
|
266
|
+
# @return [PBXFileReference] the new file reference.
|
176
267
|
#
|
177
268
|
def new_static_library(product_name, sub_group_path = nil)
|
178
269
|
file = new_file("lib#{product_name}.a", sub_group_path)
|
@@ -183,6 +274,22 @@ module Xcodeproj
|
|
183
274
|
file
|
184
275
|
end
|
185
276
|
|
277
|
+
# Creates a file reference to a new bundle.
|
278
|
+
#
|
279
|
+
# @param [#to_s] product_name
|
280
|
+
# the name of the bundle.
|
281
|
+
#
|
282
|
+
# @return [PBXFileReference] the new file reference.
|
283
|
+
#
|
284
|
+
def new_bundle(product_name)
|
285
|
+
file = new_file("#{product_name}.bundle")
|
286
|
+
file.explicit_file_type = 'wrapper.cfbundle'
|
287
|
+
file.include_in_index = '0'
|
288
|
+
file.source_tree = 'BUILT_PRODUCTS_DIR'
|
289
|
+
file.last_known_file_type = nil
|
290
|
+
file
|
291
|
+
end
|
292
|
+
|
186
293
|
# Creates a new group to represent a `xcdatamodel` file.
|
187
294
|
#
|
188
295
|
# @return [XCVersionGroup] The new group.
|
@@ -283,7 +390,6 @@ module Xcodeproj
|
|
283
390
|
end
|
284
391
|
end
|
285
392
|
end
|
286
|
-
|
287
393
|
end
|
288
394
|
|
289
395
|
#-----------------------------------------------------------------------#
|
@@ -36,6 +36,8 @@ module Xcodeproj
|
|
36
36
|
|
37
37
|
# @!group Helpers
|
38
38
|
|
39
|
+
# @return [String] the SDK that the target should use.
|
40
|
+
#
|
39
41
|
def sdk
|
40
42
|
build_configurations.first.build_settings['SDKROOT'] \
|
41
43
|
|| project.build_configurations.first.build_settings['SDKROOT']
|
@@ -103,6 +105,28 @@ module Xcodeproj
|
|
103
105
|
build_phases.select { |bp| bp.class == PBXShellScriptBuildPhase }
|
104
106
|
end
|
105
107
|
|
108
|
+
# Adds a dependency on the given target.
|
109
|
+
#
|
110
|
+
# @param [AbstractTarget] target
|
111
|
+
# the target which should be added to the dependencies list of
|
112
|
+
# the receiver.
|
113
|
+
#
|
114
|
+
# @return [void]
|
115
|
+
#
|
116
|
+
def add_dependency(target)
|
117
|
+
container_proxy = project.new(Xcodeproj::Project::PBXContainerItemProxy)
|
118
|
+
container_proxy.container_portal = project.root_object.uuid
|
119
|
+
container_proxy.proxy_type = '1'
|
120
|
+
container_proxy.remote_global_id_string = target.uuid
|
121
|
+
container_proxy.remote_info = target.name
|
122
|
+
|
123
|
+
dependency = project.new(Xcodeproj::Project::PBXTargetDependency)
|
124
|
+
dependency.target = target
|
125
|
+
dependency.target_proxy = container_proxy
|
126
|
+
|
127
|
+
dependencies << dependency
|
128
|
+
end
|
129
|
+
|
106
130
|
# Creates a new copy files build phase.
|
107
131
|
#
|
108
132
|
# @param [String] name
|
@@ -217,6 +241,21 @@ module Xcodeproj
|
|
217
241
|
end
|
218
242
|
end
|
219
243
|
|
244
|
+
# Adds resource files to the resources build phase of the target.
|
245
|
+
#
|
246
|
+
# @param [Array<PBXFileReference>] resource_file_references
|
247
|
+
# the files references of the resources to the target.
|
248
|
+
#
|
249
|
+
# @return [void]
|
250
|
+
#
|
251
|
+
def add_resources(resource_file_references)
|
252
|
+
resource_file_references.each do |file|
|
253
|
+
build_file = project.new(PBXBuildFile)
|
254
|
+
build_file.file_ref = file
|
255
|
+
resources_build_phase.files << build_file
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
220
259
|
# Finds or creates the headers build phase of the target.
|
221
260
|
#
|
222
261
|
# @note A target should have only one headers build phase.
|
@@ -22,7 +22,7 @@ module Xcodeproj
|
|
22
22
|
# - `LastUpgradeCheck`
|
23
23
|
# - `ORGANIZATIONNAME`
|
24
24
|
#
|
25
|
-
attribute :attributes, Hash, {'LastUpgradeCheck' =>
|
25
|
+
attribute :attributes, Hash, {'LastUpgradeCheck' => Constants::LAST_UPGRADE_CHECK }
|
26
26
|
|
27
27
|
# @return [XCConfigurationList] the configuration list of the project.
|
28
28
|
#
|
@@ -0,0 +1,254 @@
|
|
1
|
+
module Xcodeproj
|
2
|
+
class Project
|
3
|
+
module ProjectHelper
|
4
|
+
|
5
|
+
include Object
|
6
|
+
|
7
|
+
# @!group Targets
|
8
|
+
|
9
|
+
#-----------------------------------------------------------------------#
|
10
|
+
|
11
|
+
# Creates a new target and adds it to the project.
|
12
|
+
#
|
13
|
+
# The target is configured for the given platform and its file reference it
|
14
|
+
# is added to the {products_group}.
|
15
|
+
#
|
16
|
+
# The target is pre-populated with common build settings, and the
|
17
|
+
# appropriate Framework according to the platform is added to to its
|
18
|
+
# Frameworks phase.
|
19
|
+
#
|
20
|
+
# @param [Project] project
|
21
|
+
# the project to which the target should be added.
|
22
|
+
#
|
23
|
+
# @param [Symbol] type
|
24
|
+
# the type of target. Can be `:application`, `:dynamic_library` or
|
25
|
+
# `:static_library`.
|
26
|
+
#
|
27
|
+
# @param [String] name
|
28
|
+
# the name of the static library product.
|
29
|
+
#
|
30
|
+
# @param [Symbol] platform
|
31
|
+
# the platform of the static library. Can be `:ios` or `:osx`.
|
32
|
+
#
|
33
|
+
# @param [String] deployment_target
|
34
|
+
# the deployment target for the platform.
|
35
|
+
#
|
36
|
+
# @return [PBXNativeTarget] the target.
|
37
|
+
#
|
38
|
+
def self.new_target(project, type, name, platform, deployment_target, product_group)
|
39
|
+
|
40
|
+
# Target
|
41
|
+
target = project.new(PBXNativeTarget)
|
42
|
+
project.targets << target
|
43
|
+
target.name = name
|
44
|
+
target.product_name = name
|
45
|
+
target.product_type = Constants::PRODUCT_TYPE_UTI[type]
|
46
|
+
target.build_configuration_list = configuration_list(project, platform, deployment_target)
|
47
|
+
|
48
|
+
# Product
|
49
|
+
product = product_group.new_static_library(name)
|
50
|
+
target.product_reference = product
|
51
|
+
|
52
|
+
# Frameworks
|
53
|
+
framework_name = (platform == :ios) ? 'Foundation' : 'Cocoa'
|
54
|
+
framework_ref = project.add_system_framework(framework_name, target)
|
55
|
+
|
56
|
+
# Build phases
|
57
|
+
target.build_phases << project.new(PBXSourcesBuildPhase)
|
58
|
+
frameworks_phase = project.new(PBXFrameworksBuildPhase)
|
59
|
+
frameworks_phase.add_file_reference(framework_ref)
|
60
|
+
target.build_phases << frameworks_phase
|
61
|
+
|
62
|
+
target
|
63
|
+
end
|
64
|
+
|
65
|
+
# Creates a new resource bundles target and adds it to the project.
|
66
|
+
#
|
67
|
+
# The target is configured for the given platform and its file reference it
|
68
|
+
# is added to the {products_group}.
|
69
|
+
#
|
70
|
+
# The target is pre-populated with common build settings
|
71
|
+
#
|
72
|
+
# @param [Project] project
|
73
|
+
# the project to which the target should be added.
|
74
|
+
#
|
75
|
+
# @param [String] name
|
76
|
+
# the name of the resources bundle.
|
77
|
+
#
|
78
|
+
# @param [Symbol] platform
|
79
|
+
# the platform of the resources bundle. Can be `:ios` or `:osx`.
|
80
|
+
#
|
81
|
+
# @return [PBXNativeTarget] the target.
|
82
|
+
#
|
83
|
+
def self.new_resources_bundle(project, name, platform, product_group)
|
84
|
+
# Target
|
85
|
+
target = project.new(PBXNativeTarget)
|
86
|
+
project.targets << target
|
87
|
+
target.name = name
|
88
|
+
target.product_name = name
|
89
|
+
target.product_type = Constants::PRODUCT_TYPE_UTI[:bundle]
|
90
|
+
|
91
|
+
# Configuration List
|
92
|
+
build_settings = {
|
93
|
+
'PRODUCT_NAME' => '$(TARGET_NAME)',
|
94
|
+
'WRAPPER_EXTENSION' => 'bundle',
|
95
|
+
'SKIP_INSTALL' => 'YES'
|
96
|
+
}
|
97
|
+
|
98
|
+
if platform == :osx
|
99
|
+
build_settings['COMBINE_HIDPI_IMAGES'] = 'YES'
|
100
|
+
build_settings['SDKROOT'] = 'macosx'
|
101
|
+
else
|
102
|
+
build_settings['SDKROOT'] = 'iphoneos'
|
103
|
+
end
|
104
|
+
|
105
|
+
cl = project.new(XCConfigurationList)
|
106
|
+
cl.default_configuration_is_visible = '0'
|
107
|
+
cl.default_configuration_name = 'Release'
|
108
|
+
release_conf = project.new(XCBuildConfiguration)
|
109
|
+
release_conf.name = 'Release'
|
110
|
+
release_conf.build_settings = build_settings
|
111
|
+
debug_conf = project.new(XCBuildConfiguration)
|
112
|
+
debug_conf.name = 'Debug'
|
113
|
+
debug_conf.build_settings = build_settings
|
114
|
+
cl.build_configurations << release_conf
|
115
|
+
cl.build_configurations << debug_conf
|
116
|
+
cl
|
117
|
+
target.build_configuration_list = cl
|
118
|
+
|
119
|
+
# Product
|
120
|
+
product = product_group.new_bundle(name)
|
121
|
+
target.product_reference = product
|
122
|
+
|
123
|
+
# Build phases
|
124
|
+
target.build_phases << project.new(PBXSourcesBuildPhase)
|
125
|
+
target.build_phases << project.new(PBXFrameworksBuildPhase)
|
126
|
+
target.build_phases << project.new(PBXResourcesBuildPhase)
|
127
|
+
|
128
|
+
target
|
129
|
+
end
|
130
|
+
|
131
|
+
# @!group System Frameworks
|
132
|
+
|
133
|
+
#-----------------------------------------------------------------------#
|
134
|
+
|
135
|
+
# Adds a file reference for a system framework to the project.
|
136
|
+
#
|
137
|
+
# The file reference can then be added to the build files of a
|
138
|
+
# {PBXFrameworksBuildPhase}.
|
139
|
+
#
|
140
|
+
# @param [Project] project
|
141
|
+
# the project to which the configuration list should be added.
|
142
|
+
#
|
143
|
+
# @param [String] name
|
144
|
+
# The name of a framework.
|
145
|
+
#
|
146
|
+
# @param [PBXNativeTarget] target
|
147
|
+
# The target for which to add the framework.
|
148
|
+
#
|
149
|
+
# @note This method adds a reference to the highest know SDK for the
|
150
|
+
# given platform.
|
151
|
+
#
|
152
|
+
# @return [PBXFileReference] The generated file reference.
|
153
|
+
#
|
154
|
+
def self.add_system_framework(project, name, target)
|
155
|
+
sdk = target.sdk
|
156
|
+
raise "Unable to find and SDK for the target `#{target.name}`" unless sdk
|
157
|
+
if sdk.include?('iphoneos')
|
158
|
+
if sdk == 'iphoneos'
|
159
|
+
version = XcodebuildHelper.instance.last_ios_sdk || Constants::LAST_KNOWN_IOS_SDK
|
160
|
+
base_dir = "Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS#{version}.sdk/"
|
161
|
+
else
|
162
|
+
base_dir = "Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS#{sdk.gsub('iphoneos', '')}.sdk/"
|
163
|
+
end
|
164
|
+
elsif sdk.include?('macosx')
|
165
|
+
if sdk == 'macosx'
|
166
|
+
version = XcodebuildHelper.instance.last_osx_sdk || Constants::LAST_KNOWN_OSX_SDK
|
167
|
+
base_dir = "Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{version}.sdk/"
|
168
|
+
else
|
169
|
+
base_dir = "Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{sdk.gsub('macosx', '')}.sdk/"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
path = base_dir + "System/Library/Frameworks/#{name}.framework"
|
174
|
+
if ref = project.frameworks_group.files.find { |f| f.path == path }
|
175
|
+
ref
|
176
|
+
else
|
177
|
+
ref = project.frameworks_group.new_file(path)
|
178
|
+
ref.source_tree = 'DEVELOPER_DIR'
|
179
|
+
ref
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# @!group Private Helpers
|
184
|
+
|
185
|
+
#-----------------------------------------------------------------------#
|
186
|
+
|
187
|
+
# Returns a new configuration list, populated with release and debug
|
188
|
+
# configurations with common build settings for the given platform.
|
189
|
+
#
|
190
|
+
# @param [Project] project
|
191
|
+
# the project to which the configuration list should be added.
|
192
|
+
#
|
193
|
+
# @param [Symbol] platform
|
194
|
+
# the platform for the configuration list, can be `:ios` or `:osx`.
|
195
|
+
#
|
196
|
+
# @param [String] deployment_target
|
197
|
+
# the deployment target for the platform.
|
198
|
+
#
|
199
|
+
# @return [XCConfigurationList] the generated configuration list.
|
200
|
+
#
|
201
|
+
def self.configuration_list(project, platform, deployment_target = nil)
|
202
|
+
cl = project.new(XCConfigurationList)
|
203
|
+
cl.default_configuration_is_visible = '0'
|
204
|
+
cl.default_configuration_name = 'Release'
|
205
|
+
|
206
|
+
release_conf = project.new(XCBuildConfiguration)
|
207
|
+
release_conf.name = 'Release'
|
208
|
+
release_conf.build_settings = common_build_settings(:release, platform, deployment_target)
|
209
|
+
|
210
|
+
debug_conf = project.new(XCBuildConfiguration)
|
211
|
+
debug_conf.name = 'Debug'
|
212
|
+
debug_conf.build_settings = common_build_settings(:debug, platform, deployment_target)
|
213
|
+
|
214
|
+
cl.build_configurations << release_conf
|
215
|
+
cl.build_configurations << debug_conf
|
216
|
+
cl
|
217
|
+
end
|
218
|
+
|
219
|
+
# Returns the common build settings for a given platform and configuration
|
220
|
+
# name.
|
221
|
+
#
|
222
|
+
# @param [Symbol] type
|
223
|
+
# the type of the build configuration, can be `:release` or
|
224
|
+
# `:debug`.
|
225
|
+
#
|
226
|
+
# @param [Symbol] platform
|
227
|
+
# the platform for the build settings, can be `:ios` or `:osx`.
|
228
|
+
#
|
229
|
+
# @param [String] deployment_target
|
230
|
+
# the deployment target for the platform.
|
231
|
+
#
|
232
|
+
# @return [Hash] The common build settings
|
233
|
+
#
|
234
|
+
def self.common_build_settings(type, platform, deployment_target = nil)
|
235
|
+
common_settings = Constants::COMMON_BUILD_SETTINGS
|
236
|
+
settings = common_settings[:all].dup
|
237
|
+
settings.merge!(common_settings[type])
|
238
|
+
settings.merge!(common_settings[platform])
|
239
|
+
settings.merge!(common_settings[[platform, type]])
|
240
|
+
if deployment_target
|
241
|
+
if platform == :ios
|
242
|
+
settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
|
243
|
+
elsif platform == :osx
|
244
|
+
settings['MACOSX_DEPLOYMENT_TARGET'] = deployment_target
|
245
|
+
end
|
246
|
+
end
|
247
|
+
settings
|
248
|
+
end
|
249
|
+
|
250
|
+
#-----------------------------------------------------------------------#
|
251
|
+
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
data/lib/xcodeproj/project.rb
CHANGED
@@ -2,6 +2,7 @@ require 'fileutils'
|
|
2
2
|
require 'pathname'
|
3
3
|
require 'xcodeproj/xcodeproj_ext'
|
4
4
|
require 'xcodeproj/project/object'
|
5
|
+
require 'xcodeproj/project/project_helper'
|
5
6
|
|
6
7
|
module Xcodeproj
|
7
8
|
|
@@ -511,32 +512,7 @@ module Xcodeproj
|
|
511
512
|
# @return [PBXFileReference] The generated file reference.
|
512
513
|
#
|
513
514
|
def add_system_framework(name, target)
|
514
|
-
|
515
|
-
raise "Unable to find and SDK for the target `#{target.name}`" unless sdk
|
516
|
-
if sdk.include?('iphoneos')
|
517
|
-
if sdk == 'iphoneos'
|
518
|
-
base_dir = "Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS#{Constants::LAST_KNOWN_IOS_SDK}.sdk/"
|
519
|
-
else
|
520
|
-
base_dir = "Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS#{sdk.gsub('iphoneos', '')}.sdk/"
|
521
|
-
end
|
522
|
-
elsif sdk.include?('macosx')
|
523
|
-
if sdk == 'macosx'
|
524
|
-
base_dir = "Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{Constants::LAST_KNOWN_OSX_SDK}.sdk/"
|
525
|
-
else
|
526
|
-
base_dir = "Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{sdk.gsub('iphoneos', '')}.sdk/"
|
527
|
-
end
|
528
|
-
end
|
529
|
-
path = base_dir + "System/Library/Frameworks/#{name}.framework"
|
530
|
-
|
531
|
-
if file = frameworks_group.files.find { |f| f.path == path }
|
532
|
-
file
|
533
|
-
else
|
534
|
-
framework_ref = frameworks_group.new_file(path)
|
535
|
-
framework_ref.name = "#{name}.framework"
|
536
|
-
framework_ref.source_tree = 'DEVELOPER_DIR'
|
537
|
-
framework_ref.last_known_file_type = "wrapper.framework"
|
538
|
-
framework_ref
|
539
|
-
end
|
515
|
+
ProjectHelper.add_system_framework(self, name, target)
|
540
516
|
end
|
541
517
|
|
542
518
|
# Creates a new target and adds it to the project.
|
@@ -544,11 +520,9 @@ module Xcodeproj
|
|
544
520
|
# The target is configured for the given platform and its file reference it
|
545
521
|
# is added to the {products_group}.
|
546
522
|
#
|
547
|
-
# The target is pre-populated with common build
|
548
|
-
#
|
549
|
-
#
|
550
|
-
# @todo Adding all the Frameworks is required by CocoaPods and should be
|
551
|
-
# performed there.
|
523
|
+
# The target is pre-populated with common build settings, and the
|
524
|
+
# appropriate Framework according to the platform is added to to its
|
525
|
+
# Frameworks phase.
|
552
526
|
#
|
553
527
|
# @param [Symbol] type
|
554
528
|
# the type of target. Can be `:application`, `:dynamic_library` or
|
@@ -565,91 +539,29 @@ module Xcodeproj
|
|
565
539
|
#
|
566
540
|
# @return [PBXNativeTarget] the target.
|
567
541
|
#
|
568
|
-
def new_target(type, name, platform, deployment_target = nil)
|
569
|
-
|
570
|
-
|
571
|
-
target = new(PBXNativeTarget)
|
572
|
-
targets << target
|
573
|
-
target.name = name
|
574
|
-
target.product_name = name
|
575
|
-
target.product_type = Constants::PRODUCT_TYPE_UTI[type]
|
576
|
-
target.build_configuration_list = configuration_list(platform, deployment_target)
|
577
|
-
|
578
|
-
# Product
|
579
|
-
product = products_group.new_static_library(name)
|
580
|
-
target.product_reference = product
|
581
|
-
|
582
|
-
# Frameworks
|
583
|
-
framework_name = (platform == :ios) ? 'Foundation' : 'Cocoa'
|
584
|
-
framework_ref = add_system_framework(framework_name, target)
|
585
|
-
|
586
|
-
# Build phases
|
587
|
-
target.build_phases << new(PBXSourcesBuildPhase)
|
588
|
-
frameworks_phase = new(PBXFrameworksBuildPhase)
|
589
|
-
frameworks_phase.add_file_reference(framework_ref)
|
590
|
-
target.build_phases << frameworks_phase
|
591
|
-
|
592
|
-
target
|
542
|
+
def new_target(type, name, platform, deployment_target = nil, product_group = nil)
|
543
|
+
product_group ||= products_group
|
544
|
+
ProjectHelper.new_target(self, type, name, platform, deployment_target, product_group)
|
593
545
|
end
|
594
546
|
|
595
|
-
#
|
596
|
-
# configurations with common build settings for the given platform.
|
597
|
-
#
|
598
|
-
# @param [Symbol] platform
|
599
|
-
# the platform for the configuration list, can be `:ios` or `:osx`.
|
547
|
+
# Creates a new resource bundles target and adds it to the project.
|
600
548
|
#
|
601
|
-
#
|
602
|
-
#
|
603
|
-
#
|
604
|
-
# @return [XCConfigurationList] the generated configuration list.
|
549
|
+
# The target is configured for the given platform and its file reference it
|
550
|
+
# is added to the {products_group}.
|
605
551
|
#
|
606
|
-
|
607
|
-
cl = new(XCConfigurationList)
|
608
|
-
cl.default_configuration_is_visible = '0'
|
609
|
-
cl.default_configuration_name = 'Release'
|
610
|
-
|
611
|
-
release_conf = new(XCBuildConfiguration)
|
612
|
-
release_conf.name = 'Release'
|
613
|
-
release_conf.build_settings = common_build_settings(:release, platform, deployment_target)
|
614
|
-
|
615
|
-
debug_conf = new(XCBuildConfiguration)
|
616
|
-
debug_conf.name = 'Debug'
|
617
|
-
debug_conf.build_settings = common_build_settings(:debug, platform, deployment_target)
|
618
|
-
|
619
|
-
cl.build_configurations << release_conf
|
620
|
-
cl.build_configurations << debug_conf
|
621
|
-
cl
|
622
|
-
end
|
623
|
-
|
624
|
-
# Returns the common build settings for a given platform and configuration
|
625
|
-
# name.
|
552
|
+
# The target is pre-populated with common build settings
|
626
553
|
#
|
627
|
-
# @param [
|
628
|
-
# the
|
629
|
-
# `:debug`.
|
554
|
+
# @param [String] name
|
555
|
+
# the name of the resources bundle.
|
630
556
|
#
|
631
557
|
# @param [Symbol] platform
|
632
|
-
# the platform
|
558
|
+
# the platform of the resources bundle. Can be `:ios` or `:osx`.
|
633
559
|
#
|
634
|
-
# @
|
635
|
-
# the deployment target for the platform.
|
560
|
+
# @return [PBXNativeTarget] the target.
|
636
561
|
#
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
common_settings = Constants::COMMON_BUILD_SETTINGS
|
641
|
-
settings = common_settings[:all].dup
|
642
|
-
settings.merge!(common_settings[type])
|
643
|
-
settings.merge!(common_settings[platform])
|
644
|
-
settings.merge!(common_settings[[platform, type]])
|
645
|
-
if deployment_target
|
646
|
-
if platform == :ios
|
647
|
-
settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
|
648
|
-
elsif platform == :osx
|
649
|
-
settings['MACOSX_DEPLOYMENT_TARGET'] = deployment_target
|
650
|
-
end
|
651
|
-
end
|
652
|
-
settings
|
562
|
+
def new_resources_bundle(name, platform, product_group = nil)
|
563
|
+
product_group ||= products_group
|
564
|
+
ProjectHelper.new_resources_bundle(self, name, platform, product_group)
|
653
565
|
end
|
654
566
|
|
655
567
|
#-------------------------------------------------------------------------#
|
data/lib/xcodeproj/scheme.rb
CHANGED
@@ -1,46 +1,33 @@
|
|
1
1
|
require 'rexml/document'
|
2
2
|
|
3
3
|
module Xcodeproj
|
4
|
-
|
5
|
-
# This class represents a Scheme document represented by a ".xcscheme" file
|
6
|
-
# in a xcuserdata or xcshareddata (for a shared scheme)
|
7
|
-
#
|
4
|
+
|
5
|
+
# This class represents a Scheme document represented by a ".xcscheme" file
|
6
|
+
# usually stored in a xcuserdata or xcshareddata (for a shared scheme)
|
7
|
+
# folder.
|
8
|
+
#
|
8
9
|
class XCScheme
|
9
|
-
|
10
|
-
# @return [REXML::Document] the XML object that will be manipulated to save
|
10
|
+
|
11
|
+
# @return [REXML::Document] the XML object that will be manipulated to save
|
12
|
+
# the scheme file after.
|
11
13
|
#
|
12
14
|
attr_reader :doc
|
13
|
-
|
14
|
-
# @return [String] the name of the container (the project name file without
|
15
|
-
# used by the scheme.
|
15
|
+
|
16
|
+
# @return [String] the name of the container (the project name file without
|
17
|
+
# the extension) that have the targets used by the scheme.
|
16
18
|
#
|
17
19
|
attr_reader :container
|
18
20
|
|
19
|
-
# @return [Xcodeproj::Project::Object::AbstractTarget] the target used by
|
21
|
+
# @return [Xcodeproj::Project::Object::AbstractTarget] the target used by
|
22
|
+
# scheme in the build step.
|
20
23
|
#
|
21
24
|
attr_reader :build_target
|
22
25
|
|
23
|
-
# @return [Xcodeproj::Project::Object::AbstractTarget] the target used by
|
26
|
+
# @return [Xcodeproj::Project::Object::AbstractTarget] the target used by
|
27
|
+
# scheme in the test step.
|
24
28
|
#
|
25
29
|
attr_reader :test_target
|
26
30
|
|
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
31
|
# Create a new XCScheme instance
|
45
32
|
#
|
46
33
|
# @param [String] container
|
@@ -60,29 +47,29 @@ module Xcodeproj
|
|
60
47
|
@container = container
|
61
48
|
@build_target = build_target
|
62
49
|
@test_target = test_target
|
63
|
-
|
50
|
+
|
64
51
|
@doc = REXML::Document.new
|
65
52
|
@doc << REXML::XMLDecl.new(REXML::XMLDecl::DEFAULT_VERSION, 'UTF-8')
|
66
53
|
@doc.context[:attribute_quote] = :quote
|
67
|
-
|
54
|
+
|
68
55
|
scheme = @doc.add_element 'Scheme'
|
69
|
-
scheme.attributes['LastUpgradeVersion'] =
|
56
|
+
scheme.attributes['LastUpgradeVersion'] = Constants::LAST_UPGRADE_CHECK
|
70
57
|
scheme.attributes['version'] = '1.3'
|
71
|
-
|
58
|
+
|
72
59
|
build_action = scheme.add_element 'BuildAction'
|
73
60
|
build_action.attributes['parallelizeBuildables'] = 'YES'
|
74
61
|
build_action.attributes['buildImplicitDependencies'] = 'YES'
|
75
|
-
|
62
|
+
|
76
63
|
if (build_target.product_type == 'com.apple.product-type.application') then
|
77
64
|
build_action_entries = build_action.add_element 'BuildActionEntries'
|
78
|
-
|
65
|
+
|
79
66
|
build_action_entry = build_action_entries.add_element 'BuildActionEntry'
|
80
67
|
build_action_entry.attributes['buildForTesting'] = 'YES'
|
81
68
|
build_action_entry.attributes['buildForRunning'] = 'YES'
|
82
69
|
build_action_entry.attributes['buildForProfiling'] = 'YES'
|
83
70
|
build_action_entry.attributes['buildForArchiving'] = 'YES'
|
84
71
|
build_action_entry.attributes['buildForAnalyzing'] = 'YES'
|
85
|
-
|
72
|
+
|
86
73
|
buildable_reference = build_action_entry.add_element 'BuildableReference'
|
87
74
|
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
88
75
|
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
@@ -90,13 +77,13 @@ module Xcodeproj
|
|
90
77
|
buildable_reference.attributes['BlueprintName'] = build_target.name
|
91
78
|
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
92
79
|
end
|
93
|
-
|
80
|
+
|
94
81
|
test_action = scheme.add_element 'TestAction'
|
95
82
|
test_action.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
|
96
83
|
test_action.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
|
97
84
|
test_action.attributes['shouldUseLaunchSchemeArgsEnv'] = 'YES'
|
98
85
|
test_action.attributes['buildConfiguration'] = 'Debug'
|
99
|
-
|
86
|
+
|
100
87
|
testables = test_action.add_element 'Testables'
|
101
88
|
|
102
89
|
if (test_target != nil) then
|
@@ -121,7 +108,7 @@ module Xcodeproj
|
|
121
108
|
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
122
109
|
end
|
123
110
|
end
|
124
|
-
|
111
|
+
|
125
112
|
launch_action = scheme.add_element 'LaunchAction'
|
126
113
|
launch_action.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
|
127
114
|
launch_action.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
|
@@ -131,10 +118,10 @@ module Xcodeproj
|
|
131
118
|
launch_action.attributes['ignoresPersistentStateOnLaunch'] = 'NO'
|
132
119
|
launch_action.attributes['debugDocumentVersioning'] = 'YES'
|
133
120
|
launch_action.attributes['allowLocationSimulation'] = 'YES'
|
134
|
-
|
121
|
+
|
135
122
|
if (build_target.product_type == 'com.apple.product-type.application') then
|
136
123
|
buildable_product_runnable = launch_action.add_element 'BuildableProductRunnable'
|
137
|
-
|
124
|
+
|
138
125
|
buildable_reference = buildable_product_runnable.add_element 'BuildableReference'
|
139
126
|
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
140
127
|
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
@@ -142,19 +129,19 @@ module Xcodeproj
|
|
142
129
|
buildable_reference.attributes['BlueprintName'] = build_target.name
|
143
130
|
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
144
131
|
end
|
145
|
-
|
132
|
+
|
146
133
|
additional_options = launch_action.add_element 'AdditionalOptions'
|
147
|
-
|
134
|
+
|
148
135
|
profile_action = scheme.add_element 'ProfileAction'
|
149
136
|
profile_action.attributes['shouldUseLaunchSchemeArgsEnv'] = 'YES'
|
150
137
|
profile_action.attributes['savedToolIdentifier'] = ''
|
151
138
|
profile_action.attributes['useCustomWorkingDirectory'] = 'NO'
|
152
139
|
profile_action.attributes['buildConfiguration'] = 'Release'
|
153
140
|
profile_action.attributes['debugDocumentVersioning'] = 'YES'
|
154
|
-
|
141
|
+
|
155
142
|
if (build_target.product_type == 'com.apple.product-type.application') then
|
156
143
|
buildable_product_runnable = profile_action.add_element 'BuildableProductRunnable'
|
157
|
-
|
144
|
+
|
158
145
|
buildable_reference = buildable_product_runnable.add_element 'BuildableReference'
|
159
146
|
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
160
147
|
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
@@ -162,16 +149,64 @@ module Xcodeproj
|
|
162
149
|
buildable_reference.attributes['BlueprintName'] = build_target.name
|
163
150
|
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
164
151
|
end
|
165
|
-
|
152
|
+
|
166
153
|
analyze_action = scheme.add_element 'AnalyzeAction'
|
167
154
|
analyze_action.attributes['buildConfiguration'] = 'Debug'
|
168
|
-
|
155
|
+
|
169
156
|
archive_action = scheme.add_element 'ArchiveAction'
|
170
157
|
archive_action.attributes['buildConfiguration'] = 'Release'
|
171
158
|
archive_action.attributes['revealArchiveInOrganizer'] = 'YES'
|
172
159
|
end
|
173
160
|
|
174
|
-
|
161
|
+
public
|
162
|
+
|
163
|
+
# @!group Class methods
|
164
|
+
|
165
|
+
#-------------------------------------------------------------------------#
|
166
|
+
|
167
|
+
# Share a User Scheme. Basically this method move the xcscheme file from
|
168
|
+
# the xcuserdata folder to xcshareddata folder.
|
169
|
+
#
|
170
|
+
# @param [String] project_path
|
171
|
+
# Path of the .xcodeproj folder.
|
172
|
+
#
|
173
|
+
# @param [String] scheme_name
|
174
|
+
# The name of scheme that will be shared.
|
175
|
+
#
|
176
|
+
# @param [String] user
|
177
|
+
# The user name that have the scheme.
|
178
|
+
#
|
179
|
+
def self.share_scheme(project_path, scheme_name, user = nil)
|
180
|
+
to_folder = shared_data_dir(project_path)
|
181
|
+
to_folder.mkpath
|
182
|
+
to = to_folder + "#{scheme_name}.xcscheme"
|
183
|
+
from = self.user_data_dir(project_path, user) + "#{scheme_name}.xcscheme"
|
184
|
+
FileUtils.mv(from, to)
|
185
|
+
end
|
186
|
+
|
187
|
+
# @return [Pathname]
|
188
|
+
#
|
189
|
+
def self.shared_data_dir(project_path)
|
190
|
+
project_path = Pathname.new(project_path)
|
191
|
+
project_path + 'xcshareddata/xcschemes'
|
192
|
+
end
|
193
|
+
|
194
|
+
# @return [Pathname]
|
195
|
+
#
|
196
|
+
def self.user_data_dir(project_path, user = nil)
|
197
|
+
project_path = Pathname.new(project_path)
|
198
|
+
user ||= ENV['USER']
|
199
|
+
project_path + "xcuserdata/#{user}.xcuserdatad/xcschemes"
|
200
|
+
end
|
201
|
+
|
202
|
+
public
|
203
|
+
|
204
|
+
# @!group
|
205
|
+
|
206
|
+
#-------------------------------------------------------------------------#
|
207
|
+
|
208
|
+
# Returns the current value if the build target must be runned during the
|
209
|
+
# build step.
|
175
210
|
#
|
176
211
|
# @return [Boolean]
|
177
212
|
# true => run during the build step
|
@@ -190,9 +225,9 @@ module Xcodeproj
|
|
190
225
|
|
191
226
|
build_target_for_running == 'YES'
|
192
227
|
end
|
193
|
-
|
194
|
-
# Set the build target to run or not run during the build step.
|
195
|
-
#
|
228
|
+
|
229
|
+
# Set the build target to run or not run during the build step. Useful for
|
230
|
+
# cases where the build target is a unit test bundle.
|
196
231
|
#
|
197
232
|
# @param [Boolean] build_target_for_running
|
198
233
|
# true => run during the build step
|
@@ -200,13 +235,13 @@ module Xcodeproj
|
|
200
235
|
#
|
201
236
|
def build_target_for_running=(build_target_for_running)
|
202
237
|
build_action = @doc.root.elements['BuildAction']
|
203
|
-
|
238
|
+
|
204
239
|
if (build_action.elements['BuildActionEntries'] == nil) then
|
205
|
-
build_action_entries = build_action.add_element
|
240
|
+
build_action_entries = build_action.add_element('BuildActionEntries')
|
206
241
|
else
|
207
242
|
build_action_entries = build_action.elements['BuildActionEntries']
|
208
243
|
end
|
209
|
-
|
244
|
+
|
210
245
|
if (build_action_entries.elements['BuildActionEntry'] == nil) then
|
211
246
|
build_action_entry = build_action_entries.add_element 'BuildActionEntry'
|
212
247
|
build_action_entry.attributes['buildForTesting'] = 'YES'
|
@@ -216,9 +251,9 @@ module Xcodeproj
|
|
216
251
|
else
|
217
252
|
build_action_entry = build_action_entries.elements['BuildActionEntry']
|
218
253
|
end
|
219
|
-
|
254
|
+
|
220
255
|
build_action_entry.attributes['buildForRunning'] = build_target_for_running ? 'YES' : 'NO'
|
221
|
-
|
256
|
+
|
222
257
|
if (build_action_entry.elements['BuildableReference'] == nil) then
|
223
258
|
buildable_reference = build_action_entry.add_element 'BuildableReference'
|
224
259
|
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
@@ -228,10 +263,16 @@ module Xcodeproj
|
|
228
263
|
buildable_reference.attributes['ReferencedContainer'] = "container:#{container}.xcodeproj"
|
229
264
|
end
|
230
265
|
end
|
231
|
-
|
232
|
-
|
266
|
+
|
267
|
+
public
|
268
|
+
|
269
|
+
# @!group Serialization
|
270
|
+
|
271
|
+
#-------------------------------------------------------------------------#
|
272
|
+
|
273
|
+
# Serializes the current state of the object to a String.
|
233
274
|
#
|
234
|
-
# @return [String] the XML string value of the current state of the object
|
275
|
+
# @return [String] the XML string value of the current state of the object.
|
235
276
|
#
|
236
277
|
def to_s
|
237
278
|
formatter = REXML::Formatters::Pretty.new(2)
|
@@ -240,7 +281,7 @@ module Xcodeproj
|
|
240
281
|
formatter.write(@doc, out)
|
241
282
|
out
|
242
283
|
end
|
243
|
-
|
284
|
+
|
244
285
|
# Serializes the current state of the object to a ".xcscheme" file.
|
245
286
|
#
|
246
287
|
# @param [String, Pathname] project_path
|
@@ -256,17 +297,19 @@ module Xcodeproj
|
|
256
297
|
# scheme.save_as('path/to/Project.xcodeproj') #=> true
|
257
298
|
#
|
258
299
|
def save_as(project_path, shared = true)
|
259
|
-
if shared
|
260
|
-
scheme_folder_path =
|
300
|
+
if shared
|
301
|
+
scheme_folder_path = self.class.shared_data_dir(project_path)
|
261
302
|
else
|
262
|
-
scheme_folder_path =
|
303
|
+
scheme_folder_path = self.class.user_data_dir(project_path)
|
263
304
|
end
|
264
|
-
|
265
|
-
scheme_path =
|
305
|
+
scheme_folder_path.mkpath
|
306
|
+
scheme_path = scheme_folder_path + "#{build_target.name}.xcscheme"
|
266
307
|
File.open(scheme_path, 'w') do |f|
|
267
|
-
f.write(
|
308
|
+
f.write(to_s)
|
268
309
|
end
|
269
310
|
end
|
270
|
-
|
311
|
+
|
312
|
+
#-------------------------------------------------------------------------#
|
313
|
+
|
271
314
|
end
|
272
315
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Xcodeproj
|
2
|
+
|
3
|
+
# Helper class which returns information from xcodebuild.
|
4
|
+
#
|
5
|
+
class XcodebuildHelper
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@needs_to_parse_sdks = true
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [String] The version of the last iOS sdk.
|
12
|
+
#
|
13
|
+
def last_ios_sdk
|
14
|
+
parse_sdks_if_needed
|
15
|
+
verions_by_sdk[:ios].sort.last
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String] The version of the last OS X sdk.
|
19
|
+
#
|
20
|
+
def last_osx_sdk
|
21
|
+
parse_sdks_if_needed
|
22
|
+
verions_by_sdk[:osx].sort.last
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# !@group Private Helpers
|
28
|
+
|
29
|
+
#-------------------------------------------------------------------------#
|
30
|
+
|
31
|
+
# @return [Hash] The versions of the sdks grouped by name (`:ios`, or `:osx`).
|
32
|
+
#
|
33
|
+
attr_accessor :verions_by_sdk
|
34
|
+
|
35
|
+
# @return [void] Parses the SDKs returned by xcodebuild and stores the
|
36
|
+
# information in the `needs_to_parse_sdks` hash.
|
37
|
+
#
|
38
|
+
def parse_sdks_if_needed
|
39
|
+
if @needs_to_parse_sdks
|
40
|
+
@verions_by_sdk = {}
|
41
|
+
@verions_by_sdk[:osx] = []
|
42
|
+
@verions_by_sdk[:ios] = []
|
43
|
+
if xcodebuild_available?
|
44
|
+
skds = parse_sdks_information(xcodebuild_sdks)
|
45
|
+
skds.each do |(name, version)|
|
46
|
+
case
|
47
|
+
when name == 'macosx' then @verions_by_sdk[:osx] << version
|
48
|
+
when name == 'iphoneos' then @verions_by_sdk[:ios] << version
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [Bool] Whether xcodebuild is available.
|
56
|
+
#
|
57
|
+
def xcodebuild_available?
|
58
|
+
if @xcodebuild_available.nil?
|
59
|
+
`which xcodebuild 2>/dev/null`
|
60
|
+
@xcodebuild_available = $?.exitstatus.zero?
|
61
|
+
end
|
62
|
+
@xcodebuild_available
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [Array<Array<String>>] An array of tuples where the first element
|
66
|
+
# is the name of the SDK and the second is the version.
|
67
|
+
#
|
68
|
+
def parse_sdks_information(output)
|
69
|
+
output.scan(/-sdk (macosx|iphoneos)(.+\w)/)
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [String] The sdk information reported by xcodebuild.
|
73
|
+
#
|
74
|
+
def xcodebuild_sdks
|
75
|
+
`xcodebuild -showsdks 2>/dev/null`
|
76
|
+
end
|
77
|
+
|
78
|
+
public
|
79
|
+
|
80
|
+
#-------------------------------------------------------------------------#
|
81
|
+
|
82
|
+
# @!group Singleton
|
83
|
+
|
84
|
+
# @return [XcodebuildHelper] the current xcodebuild instance creating one
|
85
|
+
# if needed, which caches the information from the xcodebuild
|
86
|
+
# command line tool.
|
87
|
+
#
|
88
|
+
def self.instance
|
89
|
+
@instance ||= new
|
90
|
+
end
|
91
|
+
|
92
|
+
#-------------------------------------------------------------------------#
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
data/lib/xcodeproj.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Xcodeproj
|
2
|
-
VERSION = '0.
|
2
|
+
VERSION = '0.9.0' unless defined? Xcodeproj::VERSION
|
3
3
|
|
4
4
|
class PlainInformative < StandardError
|
5
5
|
end
|
@@ -10,13 +10,14 @@ module Xcodeproj
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
autoload :Command,
|
14
|
-
autoload :Config,
|
15
|
-
autoload :Constants,
|
16
|
-
autoload :Differ,
|
17
|
-
autoload :Helper,
|
18
|
-
autoload :Project,
|
19
|
-
autoload :UI,
|
20
|
-
autoload :Workspace,
|
21
|
-
autoload :XCScheme,
|
13
|
+
autoload :Command, 'xcodeproj/command'
|
14
|
+
autoload :Config, 'xcodeproj/config'
|
15
|
+
autoload :Constants, 'xcodeproj/constants'
|
16
|
+
autoload :Differ, 'xcodeproj/differ'
|
17
|
+
autoload :Helper, 'xcodeproj/helper'
|
18
|
+
autoload :Project, 'xcodeproj/project'
|
19
|
+
autoload :UI, 'xcodeproj/user_interface'
|
20
|
+
autoload :Workspace, 'xcodeproj/workspace'
|
21
|
+
autoload :XCScheme, 'xcodeproj/scheme'
|
22
|
+
autoload :XcodebuildHelper, 'xcodeproj/xcodebuild_helper'
|
22
23
|
end
|
metadata
CHANGED
@@ -1,62 +1,53 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcodeproj
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 8
|
9
|
-
- 1
|
10
|
-
version: 0.8.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Eloy Duran
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: activesupport
|
22
|
-
|
23
|
-
|
24
|
-
none: false
|
25
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
26
17
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 21
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 2
|
32
|
-
- 13
|
18
|
+
- !ruby/object:Gem::Version
|
33
19
|
version: 3.2.13
|
34
20
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: colored
|
38
21
|
prerelease: false
|
39
|
-
|
40
|
-
|
41
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
42
24
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.13
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colored
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
49
34
|
type: :runtime
|
50
|
-
|
51
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
description: Xcodeproj lets you create and modify Xcode projects from Ruby. Script
|
42
|
+
boring management tasks or build Xcode-friendly libraries. Also includes support
|
43
|
+
for Xcode workspaces (.xcworkspace) and configuration files (.xcconfig).
|
52
44
|
email: eloy.de.enige@gmail.com
|
53
|
-
executables:
|
45
|
+
executables:
|
54
46
|
- xcodeproj
|
55
|
-
extensions:
|
47
|
+
extensions:
|
56
48
|
- ext/xcodeproj/extconf.rb
|
57
49
|
extra_rdoc_files: []
|
58
|
-
|
59
|
-
files:
|
50
|
+
files:
|
60
51
|
- lib/xcodeproj/command/project_diff.rb
|
61
52
|
- lib/xcodeproj/command/show.rb
|
62
53
|
- lib/xcodeproj/command/target_diff.rb
|
@@ -81,10 +72,12 @@ files:
|
|
81
72
|
- lib/xcodeproj/project/object_attributes.rb
|
82
73
|
- lib/xcodeproj/project/object_dictionary.rb
|
83
74
|
- lib/xcodeproj/project/object_list.rb
|
75
|
+
- lib/xcodeproj/project/project_helper.rb
|
84
76
|
- lib/xcodeproj/project.rb
|
85
77
|
- lib/xcodeproj/scheme.rb
|
86
78
|
- lib/xcodeproj/user_interface.rb
|
87
79
|
- lib/xcodeproj/workspace.rb
|
80
|
+
- lib/xcodeproj/xcodebuild_helper.rb
|
88
81
|
- lib/xcodeproj.rb
|
89
82
|
- ext/xcodeproj/extconf.rb
|
90
83
|
- ext/xcodeproj/xcodeproj_ext.c
|
@@ -92,39 +85,29 @@ files:
|
|
92
85
|
- LICENSE
|
93
86
|
- bin/xcodeproj
|
94
87
|
homepage: https://github.com/cocoapods/xcodeproj
|
95
|
-
licenses:
|
88
|
+
licenses:
|
96
89
|
- MIT
|
90
|
+
metadata: {}
|
97
91
|
post_install_message:
|
98
92
|
rdoc_options: []
|
99
|
-
|
100
|
-
require_paths:
|
93
|
+
require_paths:
|
101
94
|
- ext
|
102
95
|
- lib
|
103
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
hash: 3
|
118
|
-
segments:
|
119
|
-
- 0
|
120
|
-
version: "0"
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
121
106
|
requirements: []
|
122
|
-
|
123
107
|
rubyforge_project:
|
124
|
-
rubygems_version:
|
108
|
+
rubygems_version: 2.0.3
|
125
109
|
signing_key:
|
126
110
|
specification_version: 3
|
127
111
|
summary: Create and modify Xcode projects from Ruby.
|
128
112
|
test_files: []
|
129
|
-
|
130
113
|
has_rdoc:
|