xcake 0.6.25 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile.lock +10 -10
  4. data/README.md +4 -0
  5. data/bin/xcake +1 -1
  6. data/docs/Cakefile.md +23 -4
  7. data/docs/Sample/Cakefile +365 -0
  8. data/lib/xcake/context/xcodeproj_context.rb +3 -4
  9. data/lib/xcake/generator/configuration_generator.rb +1 -1
  10. data/lib/xcake/generator/target_file_reference_generator.rb +24 -30
  11. data/lib/xcake/informative.rb +1 -1
  12. data/lib/xcake/path_classifier.rb +66 -0
  13. data/lib/xcake/project/sugar.rb +26 -0
  14. data/lib/xcake/project.rb +0 -1
  15. data/lib/xcake/target/configurable.rb +38 -0
  16. data/lib/xcake/target.rb +0 -39
  17. data/lib/xcake/ui.rb +2 -3
  18. data/lib/xcake/version.rb +1 -1
  19. data/lib/xcake/xcode/project.rb +35 -43
  20. data/lib/xcake/xcodeproj_ext/PBXGroup.rb +41 -0
  21. data/lib/xcake/xcodeproj_ext/PBXNativeTarget.rb +14 -0
  22. data/lib/xcake.rb +6 -2
  23. data/xcake.gemspec +1 -1
  24. metadata +10 -14
  25. data/lib/xcake/file_reference_installer/compile_source_file_reference_installer.rb +0 -15
  26. data/lib/xcake/file_reference_installer/compile_xcdatamodeld_file_reference_installer.rb +0 -22
  27. data/lib/xcake/file_reference_installer/copy_resources_file_reference_installer.rb +0 -25
  28. data/lib/xcake/file_reference_installer/copy_xcassets_file_reference_installer.rb +0 -22
  29. data/lib/xcake/file_reference_installer/header_file_reference_installer.rb +0 -11
  30. data/lib/xcake/file_reference_installer/link_library_file_reference_installer.rb +0 -21
  31. data/lib/xcake/file_reference_installer.rb +0 -83
  32. data/lib/xcake/node.rb +0 -138
  33. /data/{_hound.yml → hound.yml} +0 -0
  34. /data/{_rubocop.yml → rubocop.yml} +0 -0
  35. /data/{_rubocop_general.yml → rubocop_general.yml} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 954f88b7b00bed7c70662f39af63a8c6b03aebd6
4
- data.tar.gz: fc1dd6a7398f63d11e4a11187f5dcd4da9c19750
3
+ metadata.gz: 59b934c91bcb37c5f0d097d51c3e7a0871a9f1de
4
+ data.tar.gz: 50b91a77213c6682a9eafae98400a62b09f04883
5
5
  SHA512:
6
- metadata.gz: 813a3b569f4aeb7090c941b0084c0a26aeb4cb14939f1728fd670c4f6764f0593aa85fe65e644c4ea31df148fcb87ff168f54112dea9bd0798ade3de6cf19917
7
- data.tar.gz: 3d5839b23f3c8bafdff8ae861caab2c710d69819c2522a31cda9e30294757bfa75ae45e3c7258c77e346417eda8f6cc2dd390f11df7c0da0f251b738c9294f9d
6
+ metadata.gz: 7288c8d779b598cf328b77635dc16e5c183c00a2e7765691b96f261b7dfabb0547c6bc199bc3420bbf09e6981995f0aed71735418d2878e2f44e39a16e105866
7
+ data.tar.gz: 4eb8286ac978fc3cce5556e363fd2419a16b71a3306183219ed2db619063eac195f66a6f080383b3dac7afd70da3366cff15c344a0e991a4323cc34b3ad375c6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ v0.7.0
2
+ ======
3
+ - Simplified Target File Reference Generator.
4
+ - Adds support for UI Tests.
5
+ - Adds sample Cakefile to documentation.
6
+ - Adds support for extension targets.
7
+
1
8
  v0.6.25
2
9
  =======
3
10
  - Fixed bug where Xcake would set incorrect path for a group of a Localized file.
@@ -117,6 +124,7 @@ v0.6.1
117
124
  v0.6.0
118
125
  ======
119
126
  - Infers build phases for the apple watch.
127
+ - Re-engineered generator infastructure.
120
128
  - Fixes bug where configurations lacked a name when using shorthand syntax. (Thanks to @colinta).
121
129
  - Adds support for custom script build phases (Thanks to @colinta).
122
130
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xcake (0.6.25)
4
+ xcake (0.7.0)
5
5
  activesupport (< 5)
6
6
  claide (>= 0.9.1, < 2.0)
7
7
  cork
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (4.2.6)
14
+ activesupport (4.2.7.1)
15
15
  i18n (~> 0.7)
16
16
  json (~> 1.7, >= 1.7.7)
17
17
  minitest (~> 5.1)
@@ -21,14 +21,14 @@ GEM
21
21
  claide (1.0.0)
22
22
  coderay (1.1.1)
23
23
  colored (1.2)
24
- cork (0.1.0)
24
+ cork (0.2.0)
25
25
  colored (~> 1.2)
26
- coveralls (0.8.14)
26
+ coveralls (0.8.15)
27
27
  json (>= 1.8, < 3)
28
28
  simplecov (~> 0.12.0)
29
29
  term-ansicolor (~> 1.3)
30
30
  thor (~> 0.19.1)
31
- tins (~> 1.6.0)
31
+ tins (>= 1.6.0, < 2)
32
32
  diff-lcs (1.2.5)
33
33
  docile (1.1.5)
34
34
  hooks (0.4.1)
@@ -40,7 +40,7 @@ GEM
40
40
  parser (2.3.1.2)
41
41
  ast (~> 2.2)
42
42
  powerpack (0.1.1)
43
- pry (0.10.3)
43
+ pry (0.10.4)
44
44
  coderay (~> 1.1.0)
45
45
  method_source (~> 0.8.1)
46
46
  slop (~> 3.4)
@@ -59,7 +59,7 @@ GEM
59
59
  diff-lcs (>= 1.2.0, < 2.0)
60
60
  rspec-support (~> 3.4.0)
61
61
  rspec-support (3.4.1)
62
- rubocop (0.41.1)
62
+ rubocop (0.42.0)
63
63
  parser (>= 2.3.1.1, < 3.0)
64
64
  powerpack (~> 0.1)
65
65
  rainbow (>= 1.99.1, < 3.0)
@@ -78,16 +78,16 @@ GEM
78
78
  tins (~> 1.0)
79
79
  thor (0.19.1)
80
80
  thread_safe (0.3.5)
81
- tins (1.6.0)
81
+ tins (1.12.0)
82
82
  tzinfo (1.2.2)
83
83
  thread_safe (~> 0.1)
84
84
  uber (0.0.15)
85
85
  unicode-display_width (1.1.0)
86
- xcodeproj (1.1.0)
86
+ xcodeproj (1.2.0)
87
87
  activesupport (>= 3)
88
88
  claide (>= 1.0.0, < 2.0)
89
89
  colored (~> 1.2)
90
- yard (0.9.0)
90
+ yard (0.9.5)
91
91
 
92
92
  PLATFORMS
93
93
  ruby
data/README.md CHANGED
@@ -95,6 +95,10 @@ Usually you'll use xcake by running the command
95
95
 
96
96
  Xcake will then generate a Xcode project based on your Cakefile
97
97
 
98
+ ## Sample Cakefile
99
+
100
+ To get better understanding of how to start using Xcake in a real project, see sample [Cakefile](https://github.com/jcampbell05/xcake/blob/master/docs/Sample/Cakefile).
101
+
98
102
  ## Need help?
99
103
  Please submit an issue on GitHub and provide information about your setup
100
104
 
data/bin/xcake CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  require 'xcake'
4
4
 
5
- #TODO: Make UI and EventHooks DI-able
5
+ # TODO: Make UI and EventHooks DI-able
6
6
  Xcake::UI.register_ui_hooks
7
7
  Xcake::Command.run(ARGV)
data/docs/Cakefile.md CHANGED
@@ -1,4 +1,4 @@
1
- #Cakefile Syntax Reference
1
+ # Cakefile Syntax Reference
2
2
 
3
3
  The `Cakefile` contains a lightweight DSL which provides the instructions on how to generate
4
4
  a project file. We adopt the convention over configuration and thus it can be very simple:
@@ -92,7 +92,7 @@ Mac App:
92
92
  application_for :mac, 8.0
93
93
  ```
94
94
 
95
- ###Tests
95
+ ### Tests
96
96
 
97
97
  We can also specify a testing targets for other targets as well:
98
98
 
@@ -115,13 +115,32 @@ application_for :mac, 8.0 do |target|
115
115
  test_target.include_files = ["Tests/**/*.*"]
116
116
 
117
117
  # configure any other target-related properties
118
- # as you would do with normal target
118
+ # as you would do with application target
119
119
 
120
120
  end
121
121
  end
122
122
  ```
123
123
 
124
- ###Watch
124
+ ### UI Tests
125
+
126
+ To create UI tests target, you do everything the same as for unit tests, but instead of "unit_tests_for" use "ui_tests_for", like this:
127
+
128
+ ```ruby
129
+ application_for :mac, 8.0 do |target|
130
+
131
+ ui_tests_for target do |test_target|
132
+
133
+ test_target.name = "MyAwesomeUITests"
134
+ test_target.include_files = ["UITests/**/*.*"]
135
+
136
+ # configure any other target-related properties
137
+ # as you would do with application target
138
+
139
+ end
140
+ end
141
+ ```
142
+
143
+ ### Watch
125
144
 
126
145
  To create watch applications we can simply use the `watch_app_for` method:
127
146
 
@@ -0,0 +1,365 @@
1
+ # https://github.com/jcampbell05/xcake
2
+ # http://www.rubydoc.info/github/jcampbell05/xcake/master/file/docs/Cakefile.md
3
+
4
+ # this is a sample Cakefile for a fictional project that is called "CakeMania"
5
+
6
+ #===
7
+
8
+ # lets define high level project settings
9
+
10
+ project.name = "CakeMania"
11
+ project.class_prefix = "CMN"
12
+ project.organization = "CakeMania Inc."
13
+
14
+ #===
15
+
16
+ # Below we explicitly define the list of project build configurations.
17
+ # If you do not define it explicitly, Xcake will implicitly define default ones,
18
+ # that are equivalent to this:
19
+ #
20
+ # project.debug_configuration :Debug
21
+ # project.release_configuration :Release
22
+ #
23
+
24
+ project.debug_configuration :Debug # for local development/debugging only, pointing to "test.*" API server
25
+ project.release_configuration :Staging # for alpha and beta AdHoc builds, pointing to "test.*" API server
26
+ project.release_configuration :RC # for release candidate AdHoc builds, pointing to "rc.*" API server
27
+ project.release_configuration :Production # for App Store ready AdHoc builds, pointing to "www." API server
28
+ project.release_configuration :AppStore # for App Store builds, pointing to "www." API server
29
+
30
+ # Note, that Xcake will also automatically create set of project "Schemes" -
31
+ # one for each build configuration, their names will be constructed from
32
+ # project name and configuration name, separated by dash, like this:
33
+ #
34
+ # "<project_name>-<configuration_name>"
35
+ #
36
+ # NOTE: every scheme will have the same build configiuration
37
+ # for all phases (Run, Test, Profile, Archive). If you need different build configurations
38
+ # based on phase - lets say one configuration for Run, but different one for Archive -
39
+ # consider to have different build configurations (and as result - build shemes) for these purposes
40
+ # (as proposed in this sample file).
41
+ #
42
+ # For this example, shemes will be:
43
+ #
44
+ # "CakeMania-Debug"
45
+ # "CakeMania-Staging"
46
+ # "CakeMania-RC"
47
+ # "CakeMania-Production"
48
+ # "CakeMania-AppStore"
49
+
50
+ #===
51
+
52
+ # Below we define "project level" build configurations.
53
+ # REMEMBER this entiire file is just an interpretable script,
54
+ # and the structure below is just a loop.
55
+ # At every iteration we have reference to one
56
+ # of the build configurations defined above explicitly or implicitly.
57
+
58
+ # In this case, we set the same build settings to each configuration,
59
+ # but, if we need to have some settings to be different for different
60
+ # configurations, then you can use "if" expression to set different build settings
61
+ # dependiong on "configuration.name" (we will see example of that in target settings below in this document).
62
+
63
+ project.all_configurations.each do |configuration|
64
+
65
+ # the settings listed below are just a copy
66
+ # of what Xcode sets explicitly in a newly created Xcode
67
+ # project file in comparison with default values
68
+ # (the values that are marked with bold font).
69
+
70
+ configuration.settings["ENABLE_BITCODE"] = "YES"
71
+
72
+ configuration.settings["SDKROOT"] = "iphoneos"
73
+ configuration.settings["GCC_DYNAMIC_NO_PIC"] = "NO"
74
+ configuration.settings["OTHER_CFLAGS"] = "$(inherited) -DNS_BLOCK_ASSERTIONS=1"
75
+ configuration.settings["GCC_C_LANGUAGE_STANDARD"] = "gnu99"
76
+ configuration.settings["CLANG_ENABLE_MODULES"] = "YES"
77
+ configuration.settings["CLANG_ENABLE_OBJC_ARC"] = "YES"
78
+ configuration.settings["ENABLE_NS_ASSERTIONS"] = "NO"
79
+ configuration.settings["ENABLE_STRICT_OBJC_MSGSEND"] = "YES"
80
+ configuration.settings["CLANG_WARN_EMPTY_BODY"] = "YES"
81
+ configuration.settings["CLANG_WARN_BOOL_CONVERSION"] = "YES"
82
+ configuration.settings["CLANG_WARN_CONSTANT_CONVERSION"] = "YES"
83
+ configuration.settings["GCC_WARN_64_TO_32_BIT_CONVERSION"] = "YES"
84
+ configuration.settings["CLANG_WARN_INT_CONVERSION"] = "YES"
85
+ configuration.settings["GCC_WARN_ABOUT_RETURN_TYPE"] = "YES_ERROR"
86
+ configuration.settings["GCC_WARN_UNINITIALIZED_AUTOS"] = "YES_AGGRESSIVE"
87
+ configuration.settings["CLANG_WARN_UNREACHABLE_CODE"] = "YES"
88
+ configuration.settings["GCC_WARN_UNUSED_FUNCTION"] = "YES"
89
+ configuration.settings["GCC_WARN_UNUSED_VARIABLE"] = "YES"
90
+ configuration.settings["CLANG_WARN_DIRECT_OBJC_ISA_USAGE"] = "YES_ERROR"
91
+ configuration.settings["CLANG_WARN__DUPLICATE_METHOD_MATCH"] = "YES"
92
+ configuration.settings["GCC_WARN_UNDECLARED_SELECTOR"] = "YES"
93
+ configuration.settings["CLANG_WARN_OBJC_ROOT_CLASS"] = "YES_ERROR"
94
+ configuration.settings["DEFINES_MODULE"] = "YES" # http://stackoverflow.com/a/27251979
95
+
96
+ configuration.settings["CURRENT_PROJECT_VERSION"] = "1" # just default non-empty value
97
+
98
+ end
99
+
100
+ #=== 3d-party integration keys (global variables)
101
+
102
+ # The values below will be used to set "user-defined" build settings
103
+ # for build configurations on target level,
104
+ # so we can reuse the same, lets say, "test" FB key
105
+ # within several "test" configurations (for example, the same test key
106
+ # would be used for "Debug" and "Staging" configurations), and can easily
107
+ # see what is the value/key we use for testing and production,
108
+ # and even update it in future if needed.
109
+
110
+ # "FACEBOOK_KEY"
111
+
112
+ facebookProdKey = "888888888888888"
113
+ facebookTestKey = "999999999999999"
114
+
115
+ #=== Targets
116
+
117
+ # So far, we've defined poject settings and
118
+ # project level build configuration settings
119
+ # (which define defaults for target level build configurations).
120
+ #
121
+ # Now it's time to define target-level build settings.
122
+
123
+ # Below we define "application"-type target and
124
+ # put all it's settings (including definition or related unit test targets)
125
+ # inside "application_for ... do ... end" structure.
126
+
127
+ application_for :ios, 8.0 do |target|
128
+
129
+ # first of all, we set target settings
130
+
131
+ target.name = "CakeMania"
132
+ target.language = :swift
133
+
134
+ #===
135
+
136
+ # Now lets set target-level build settigns.
137
+ # Again, the structure below is just a loop,
138
+ # everything between "target.all_configurations.each do |configuration|"
139
+ # and corresponding "end" (see below on the same level in the very bottom of the file)
140
+ # is body of this loop, that repeats every iteration. This loop goes through
141
+ # the list of build configurations (defined above) and on each iteration
142
+ # we have variable "configuration" that contains reference to one
143
+ # of the build configurations in CONTEXT of the TARGET. This is equivalent of setting
144
+ # build settings on target-level in Xcode (you can access it if you choose to
145
+ # see build settigns by "Levels", not "Combined").
146
+
147
+ # Imagine we have project folder structure like this:
148
+ #
149
+ # - Cakefile
150
+ # - Info/
151
+ # | - CakeMania.plist
152
+ # | - CakeManiaTests.plist
153
+ # | - CakeManiaUITests.plist
154
+ # - Src/
155
+ # | - ...
156
+ # | - ObjC/
157
+ # | - Prefix.pch
158
+ # | - CakeMania-Bridging-Header.h
159
+ # | - ...
160
+ # - Res/
161
+ # | - CakeMania.entitlements
162
+ # | - CakeMania-test.entitlements
163
+ # | - ...
164
+ # | - CakeMania.xcassets/
165
+ # | - ...
166
+ # | - AppIcon.appiconset/
167
+ # | - ...
168
+ # | - Brand Assets.launchimage/
169
+ # | - ...
170
+ # | - ...
171
+ # - Lib/
172
+ # | - ...
173
+ # - Tst/
174
+ # | - ...
175
+ # - UITst/
176
+ # | - ...
177
+ #
178
+
179
+ target.all_configurations.each do |configuration|
180
+
181
+ #=== Build Settings - Core
182
+
183
+ configuration.product_bundle_identifier = "com.CakeMania.theApp"
184
+
185
+ configuration.settings["INFOPLIST_FILE"] = "Info/CakeMania.plist"
186
+
187
+ configuration.settings["PRODUCT_NAME"] = "$(TARGET_NAME)"
188
+ configuration.settings["CODE_SIGN_ENTITLEMENTS"] = "Res/CakeMania.entitlements"
189
+ configuration.settings["GCC_PREFIX_HEADER"] = "Src/ObjC/Prefix.pch"
190
+ # configuration.settings["FRAMEWORK_SEARCH_PATHS"] = "$(inherited)"
191
+ configuration.settings["LIBRARY_SEARCH_PATHS"] = "$(inherited) $(SRCROOT)/Lib/**"
192
+ configuration.settings["ASSETCATALOG_COMPILER_APPICON_NAME"] = "AppIcon"
193
+ configuration.settings["ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME"] = "Brand Assets"
194
+ configuration.settings["SWIFT_OBJC_BRIDGING_HEADER"] = "Src/ObjC/CakeMania-Bridging-Header.h"
195
+ configuration.settings["OTHER_LDFLAGS"] = "$(inherited) -ObjC"
196
+
197
+ # make configuration name available in run time:
198
+ configNameFlag = "CONFIG_" + configuration.name.upcase
199
+ configuration.settings["GCC_PREPROCESSOR_DEFINITIONS"] = "$(inherited) " + configNameFlag + "=1" # Obj-C support
200
+ configuration.settings["OTHER_SWIFT_FLAGS"] = "$(inherited) -D" + configNameFlag # Swift support
201
+
202
+ # This will show "Automatic" in Xcode,
203
+ # relies on proper/valid "PROVISIONING_PROFILE" value:
204
+ configuration.settings["CODE_SIGN_IDENTITY[sdk=iphoneos*]"] = nil
205
+
206
+ #=== Build Settings - Per-configuration
207
+
208
+ # NOTE: any configuration-specific settings below will override
209
+ # common settings that you already applied above inside this
210
+ # "target.all_configurations.each do |configuration|" block
211
+
212
+ if configuration.name == "Debug"
213
+
214
+ #=== Config
215
+
216
+ configuration.settings["PROVISIONING_PROFILE"] = "f39ljkcf-2be6-49ee-8088-5741718g0969" # dev
217
+
218
+ configuration.settings["CODE_SIGN_ENTITLEMENTS"] = "Res/CakeMania-test.entitlements"
219
+
220
+ #=== Config - User Defined Build Settings
221
+
222
+ configuration.settings["BRANCH_KEY"] = branchTestKey
223
+ configuration.settings["FACEBOOK_KEY"] = facebookTestKey
224
+
225
+ end
226
+
227
+ #===
228
+
229
+ if configuration.name == "Staging"
230
+
231
+ #=== Config
232
+
233
+ configuration.settings["PROVISIONING_PROFILE"] = "19701b9a-p784-4476-ac01-af327a8deea8" # AdHoc
234
+
235
+ configuration.settings["CODE_SIGN_ENTITLEMENTS"] = "Res/CakeMania-test.entitlements"
236
+
237
+ #=== Config - User Defined Build Settings
238
+
239
+ configuration.settings["FACEBOOK_KEY"] = facebookTestKey
240
+
241
+ end
242
+
243
+ #===
244
+
245
+ if configuration.name == "RC"
246
+
247
+ #=== Config
248
+
249
+ configuration.settings["PROVISIONING_PROFILE"] = "19701b9a-p784-4476-ac01-af327a8deea8" # AdHoc
250
+
251
+ configuration.settings["CODE_SIGN_ENTITLEMENTS"] = "Res/CakeMania-test.entitlements"
252
+
253
+ #=== Config - User Defined Build Settings
254
+
255
+ configuration.settings["FACEBOOK_KEY"] = facebookTestKey
256
+
257
+ end
258
+
259
+ #===
260
+
261
+ if configuration.name == "Production"
262
+
263
+ #=== Config
264
+
265
+ configuration.settings["PROVISIONING_PROFILE"] = "19701b9a-p784-4476-ac01-af327a8deea8" # AdHoc
266
+
267
+ #=== Config - User Defined Build Settings
268
+
269
+ configuration.settings["FACEBOOK_KEY"] = facebookProdKey
270
+
271
+ end
272
+
273
+ #===
274
+
275
+ if configuration.name == "AppStore"
276
+
277
+ #=== Config
278
+
279
+ configuration.settings["PROVISIONING_PROFILE"] = "ba8502ed-6d0b-4aab-07do-61a7ad4dd5cb" # App Store
280
+
281
+ #=== Config - User Defined Build Settings
282
+
283
+ configuration.settings["FACEBOOK_KEY"] = facebookProdKey
284
+
285
+ end
286
+
287
+ end
288
+
289
+ #=== Extra System Frameworks
290
+
291
+ # Here is how we tell Xcake to include Apple system framework
292
+ # into the target.
293
+
294
+ # NOTE: "target.system_frameworks" is an array, that always have at least
295
+ # "Foundation" and "UIKit", os it's always non-empty and we should not initialize it
296
+ # before adding something there, so we jsut add values, one at a time (one per each line below).
297
+
298
+ target.system_frameworks << "AdSupport"
299
+ target.system_frameworks << "QuartzCore"
300
+
301
+ #=== Source Files
302
+
303
+ # Here is how we tell Xcake where to look for source files
304
+ # which need to be added into the target. Moreover, the folder struture
305
+ # will be re-created with Xcode groups.
306
+
307
+ # NOTE: "target.include_files" is an array, that is empty by default
308
+ # (no source files will be added to the target). So it's our responsibility
309
+ # to initialize this array (with "=" operand) before adding values/elements
310
+ # into it (with "<<" operand). Remember, this file is a Ruby script, and
311
+ # that's just how Ruby works.
312
+
313
+ target.include_files = ["Src/**/*.*"] # initialize array with 1 element
314
+ target.include_files << "Lib/**/*.*" # add value into already non-empty array
315
+
316
+ target.include_files << "Res/**/*.*" # add another value
317
+
318
+ #=== Tests
319
+
320
+ # Below we define unit tests target for the application target.
321
+ # "unit_tests_for" is a reserved word, then you put variable that contains reference
322
+ # to the application target that you want to create unit tests for, it's "target" in our case.
323
+ # The "test_target" is reference to the newly created unit test target
324
+ # so we can configure it as we want - set name, build configurations (at least info plist file)
325
+ # and its source files, or course. The rules of how we work with test target (set its settings)
326
+ # are the same, as we work with application target.
327
+
328
+ unit_tests_for target do |test_target|
329
+
330
+ test_target.name = "CakeManiaTests"
331
+
332
+ test_target.all_configurations.each do |configuration|
333
+
334
+ configuration.settings["INFOPLIST_FILE"] = "Info/CakeManiaTests.plist"
335
+
336
+ end
337
+
338
+ #=== Source Files
339
+
340
+ test_target.include_files = ["Tst/**/*.*"] # we set array with 1 element here!
341
+
342
+ end
343
+
344
+ #===
345
+
346
+ # Below we define UI tests target for the application target.
347
+ # See https://github.com/jcampbell05/xcake/issues/44
348
+
349
+ ui_tests_for target do |test_target|
350
+
351
+ test_target.name = "CakeManiaUITests"
352
+
353
+ test_target.all_configurations.each do |configuration|
354
+
355
+ configuration.settings["INFOPLIST_FILE"] = "Info/CakeManiaUITests.plist"
356
+
357
+ end
358
+
359
+ #=== Source Files
360
+
361
+ test_target.include_files = ["UITst/**/*.*"] # we set array with 1 element here!
362
+
363
+ end
364
+
365
+ end
@@ -1,3 +1,4 @@
1
+ require 'pathname'
1
2
  require 'xcodeproj'
2
3
 
3
4
  module Xcake
@@ -16,13 +17,10 @@ module Xcake
16
17
  create_object_for_configuration(dsl_object)
17
18
  when Node
18
19
  create_object_for_node(dsl_object)
19
- else
20
- nil
21
20
  end
22
21
  end
23
22
 
24
23
  def create_object_for_project(project)
25
- # TODO: Make setup of project testable
26
24
  @project = Xcode::Project.new("./#{project.name}.xcodeproj", true)
27
25
  @project.setup_for_xcake
28
26
  @project
@@ -41,7 +39,8 @@ module Xcake
41
39
  end
42
40
 
43
41
  def file_reference_for_path(path)
44
- @project.reference_for_path(path) || @project.new_file_reference(path)
42
+ pathname = Pathname.new path
43
+ @project.file_reference_for_path(pathname)
45
44
  end
46
45
  end
47
46
  end
@@ -6,7 +6,7 @@ module Xcake
6
6
  #
7
7
  class ConfigurationGenerator < Generator
8
8
  def self.dependencies
9
- [TargetGenerator, ProjectStructureGenerator, TargetFileReferenceGenerator]
9
+ [TargetGenerator, ProjectStructureGenerator]
10
10
  end
11
11
 
12
12
  def visit_project(project)
@@ -1,51 +1,45 @@
1
+ require 'pathname'
2
+
1
3
  module Xcake
4
+ # This generator processes the files to add to the project from the
5
+ # `include_files` and `exclude_files`
6
+ #
2
7
  class TargetFileReferenceGenerator < Generator
3
- attr_accessor :root_node
4
- attr_accessor :dependency_provider
5
-
6
8
  def initialize(context)
7
9
  @context = context
8
- @root_node = Node.new
9
-
10
- @dependency_provider = DependencyProvider.new(FileReferenceInstaller)
11
10
  end
12
11
 
13
12
  def self.dependencies
14
13
  [TargetGenerator]
15
14
  end
16
15
 
17
- def process_files_for_target(target)
18
- native_target = @context.native_object_for(target)
16
+ def visit_target(target)
19
17
 
20
- Dir.glob(target.include_files).each do |file|
21
- @root_node.create_children_with_path(file, native_target)
22
- end if target.include_files
18
+ paths_to_include = Dir.glob(target.include_files).map { |f|
19
+ Pathname.new(f).cleanpath.to_s
20
+ }
21
+ paths_to_exclude = Dir.glob(target.exclude_files).map { |f|
22
+ Pathname.new(f).cleanpath.to_s
23
+ }
23
24
 
24
- Dir.glob(target.exclude_files).each do |file|
25
- @root_node.remove_children_with_path(file, native_target)
26
- end if target.exclude_files
27
- end
28
-
29
- def visit_project(project)
30
- project.targets.each do |target|
31
- process_files_for_target(target)
25
+ paths = paths_to_include - paths_to_exclude
26
+ paths.each do |p|
27
+ include_file_for_path_and_target(p, target) if PathClassifier.should_include_path?(p)
32
28
  end
33
-
34
- root_node.accept(self)
35
29
  end
36
30
 
37
- def visit_node(node)
38
- return unless node.path
31
+ private
39
32
 
40
- EventHooks.run_hook :before_adding_file, node
33
+ def include_file_for_path_and_target(path, target)
34
+ file_reference = @context.file_reference_for_path(path)
35
+ native_target = @context.native_object_for(target)
41
36
 
42
- installer_class = @dependency_provider.tsort.detect do |i|
43
- i.can_install_node(node)
44
- end
37
+ build_phase_symbol = PathClassifier.classification_for_path(path)
45
38
 
46
- unless installer_class.nil?
47
- installer = installer_class.new(context)
48
- node.accept(installer)
39
+ if PathClassifier.should_create_build_phase_for_classification?(build_phase_symbol)
40
+ build_phase_class = Xcodeproj::Project::Object.const_get(build_phase_symbol)
41
+ build_phase = native_target.build_phase_by_class(build_phase_class)
42
+ build_phase.add_file_reference(file_reference)
49
43
  end
50
44
  end
51
45
  end
@@ -1,6 +1,6 @@
1
1
  require 'claide'
2
2
 
3
- #TODO: Hook into UI Class somehow.
3
+ # TODO: Hook into UI Class somehow.
4
4
  module Xcake
5
5
  class Informative < StandardError
6
6
  include CLAide::InformativeError