fastlane-plugin-xcconfig_actions 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +45 -14
  3. data/lib/fastlane/plugin/xcconfig_actions.rb +2 -0
  4. data/lib/fastlane/plugin/xcconfig_actions/actions/build_settings_to_flags_action.rb +24 -0
  5. data/lib/fastlane/plugin/xcconfig_actions/actions/read_xcconfig_action.rb +21 -0
  6. data/lib/fastlane/plugin/xcconfig_actions/actions/validate_xcconfig_action.rb +17 -3
  7. data/lib/fastlane/plugin/xcconfig_actions/helper/xcconfig_actions_helper.rb +9 -1
  8. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspec.rb +63 -3
  9. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.1/README.md +78 -78
  10. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Clang LLVM 1.0.xcspec +6001 -0
  11. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/CopyPNGFile.xcspec +113 -0
  12. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Core Data.xcspec +289 -0
  13. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/CoreBuildSystem.xcspec +4050 -0
  14. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Cpp.xcspec +63 -0
  15. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/DTrace.xcspec +89 -0
  16. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Intents.xcspec +80 -0
  17. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Ld.xcspec +868 -0
  18. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Lex.xcspec +100 -0
  19. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/MLKit.xcspec +137 -0
  20. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Metal Compiler.xcspec +466 -0
  21. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Metal Linker.xcspec +105 -0
  22. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Nasm.xcspec +101 -0
  23. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Native Build System.xcspec +53 -0
  24. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/NativeBuildSystem.xcspec +1615 -0
  25. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/OSACompile.xcspec +63 -0
  26. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/OpenCL.xcspec +158 -0
  27. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/README.md +15250 -0
  28. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Rez.xcspec +209 -0
  29. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Swift.xcspec +886 -0
  30. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/Yacc.xcspec +100 -0
  31. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2/README.md +78 -78
  32. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Clang LLVM 1.0.xcspec +6091 -0
  33. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/CopyPNGFile.xcspec +113 -0
  34. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Core Data.xcspec +289 -0
  35. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/CoreBuildSystem.xcspec +4292 -0
  36. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Cpp.xcspec +63 -0
  37. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/DTrace.xcspec +89 -0
  38. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Intents.xcspec +80 -0
  39. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Ld.xcspec +869 -0
  40. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Lex.xcspec +100 -0
  41. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/MLKit.xcspec +137 -0
  42. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Metal Compiler.xcspec +612 -0
  43. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Metal Linker.xcspec +105 -0
  44. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Nasm.xcspec +101 -0
  45. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Native Build System.xcspec +41 -0
  46. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/NativeBuildSystem.xcspec +1649 -0
  47. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/OSACompile.xcspec +63 -0
  48. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/OpenCL.xcspec +158 -0
  49. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/README.md +15973 -0
  50. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Rez.xcspec +209 -0
  51. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Swift.xcspec +969 -0
  52. data/lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/Yacc.xcspec +100 -0
  53. data/lib/fastlane/plugin/xcconfig_actions/version.rb +2 -1
  54. metadata +60 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 308efdc017fd28d18ce6134cd9212a3bda5fafb275a0b7ebaac1804ed78c8f18
4
- data.tar.gz: e650b28da0a5af7a9bcea3e3ea5976f9506786bc3552fe0b2e3616e62aa95e71
3
+ metadata.gz: f4140013ca2ed02bd50fe835cdbaedf563a629c749bbc735f983ec674c45a5fe
4
+ data.tar.gz: 8ee98b8eb448bd27f568ae5c3451771963fbaf7b7fb71d207c740ddc2512d9cb
5
5
  SHA512:
6
- metadata.gz: 95b1a3130f4b6fd4564c79b9331ad28758c34f576d550ea6893720cdc938782100900094b9c44a7c750967b46fe251904f02dd37a59d35007fa688ab79d24365
7
- data.tar.gz: 48907de2bcc9f49f6d05fc15fccf7197215a90e28338f27f1f3321582d8b3d68e1ef8559903dca0cb513217f69ddc3dd4448e23953abc797b624bcbc01cb0715
6
+ metadata.gz: 57606e7e64e7a098761c554ce706a44e17564f27c7898b60e29d69960246d91f097d710e23e9be16ac95f802b8fcbe990933d225833a617bab6338ba451a200d
7
+ data.tar.gz: 746f8bb2736da3d396c6883284aadd82217a11d04b87071780e91502b5cc3797a696e2efb4162048f3d9c5a020596bce9e3270d627feb190da49d4ed00173861
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # xcconfig_actions plugin
2
2
 
3
+ [![license](https://img.shields.io/github/license/mgrebenets/fastlane-plugin-xcconfig_actions.svg)](https://github.com/mgrebenets/fastlane-plugin-xcconfig_actions)
3
4
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-xcconfig_actions)
4
5
  [![version](https://img.shields.io/github/tag/mgrebenets/fastlane-plugin-xcconfig_actions.svg?color=green&label=version)](https://github.com/mgrebenets/fastlane-plugin-xcconfig_actions)
5
6
  [![CircleCI](https://circleci.com/gh/mgrebenets/fastlane-plugin-xcconfig_actions.svg?style=svg)](https://circleci.com/gh/mgrebenets/fastlane-plugin-xcconfig_actions)
6
7
  [![Travis CI](https://img.shields.io/travis/mgrebenets/fastlane-plugin-xcconfig_actions.svg?label=%20&logo=travis)](https://travis-ci.org/mgrebenets/fastlane-plugin-xcconfig_actions)
7
8
  [![Coverage Status](https://coveralls.io/repos/github/mgrebenets/fastlane-plugin-xcconfig_actions/badge.svg)](https://coveralls.io/github/mgrebenets/fastlane-plugin-xcconfig_actions)
9
+ [![Inline docs](http://inch-ci.org/github/mgrebenets/fastlane-plugin-xcconfig_actions.svg)](http://inch-ci.org/github/mgrebenets/fastlane-plugin-xcconfig_actions)
8
10
 
9
11
  ## Getting Started
10
12
 
@@ -52,30 +54,36 @@ The result is a dictionary with following keys:
52
54
  - `swift_compiler_flags` for Swift compiler.
53
55
  - `linker_flags` for Clang linker.
54
56
 
55
- <!-- TODO: Add info on how it works. -->
57
+ #### Unofficial Build Settings References
56
58
 
57
- References:
59
+ The following are unofficial build settings references.
60
+ Unlike official help page, these pages contain extra information, such as build settings cross-reference and compiler and linker flags mapping.
58
61
 
59
- - [Xcode 10.1 Build Settings](lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.1/README.md)
62
+ - [Xcode 11.0 Beta 2 Build Settings](lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/11.0/README.md)
63
+ - [Xcode 10.2.1 Build Settings](lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2.1/README.md)
60
64
  - [Xcode 10.2 Build Settings](lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.2/README.md)
65
+ - [Xcode 10.1 Build Settings](lib/fastlane/plugin/xcconfig_actions/helper/xcspecs/10.1/README.md)
66
+
67
+ #### References
61
68
 
62
69
  - [Xcode Build Settings](https://help.apple.com/xcode/mac/10.2/#/itcaec37c2a6)
63
70
  - [LLVM Clang Command Line Options](https://clang.llvm.org/docs/ClangCommandLineReference.html)
64
71
  - [LLVM Clang Diagnostics](https://clang.llvm.org/docs/DiagnosticsReference.html)
65
72
  - [GCC Warning Options](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html)
66
73
  - https://gist.github.com/fabiopelosin/4560417
67
- - https://pewpewthespells.com/blog/xcode_build_system.html
74
+ - [Xcode Build System](https://pewpewthespells.com/blog/xcode_build_system.html)
68
75
 
69
76
  #### Caveats
70
77
 
71
- Flags like `-sdk iphoneos` and `-isysroot iphoneos` may not be suitable for all uses.
78
+ Flags like `-sdk iphoneos` and `-isysroot iphoneos` may not be suitable for all use cases.
72
79
  These settings only get generated if you add `SDKROOT = iphoneos` to your xcconfigs, so don't define `SDKROOT` in xcconfigs and leave it to build tool.
73
80
 
74
81
  ##### Code Coverage
75
82
 
76
83
  Flags like `CLANG_ENABLE_CODE_COVERAGE` will not have effect if set to `YES`.
77
- This flag needs to be accompanied to changes in Xcode scheme UI to enable code coverage.
78
- When ran from command just settings `CLANG_ENABLE_CODE_COVERAGE=YES` has no effect either, instead the `-enableCodeCoverage YES` option has to be used.
84
+ This flag needs to be accompanied by changes in Xcode scheme UI to enable code coverage.
85
+
86
+ When used from command just setting `CLANG_ENABLE_CODE_COVERAGE=YES` has no effect either, instead the `-enableCodeCoverage YES` option has to be used.
79
87
 
80
88
  In case of `CLANG_ENABLE_CODE_COVERAGE` add `CLANG_COVERAGE_MAPPING = YES` to xcconfigs to get proper flags mapping.
81
89
 
@@ -83,6 +91,29 @@ In case of `CLANG_ENABLE_CODE_COVERAGE` add `CLANG_COVERAGE_MAPPING = YES` to xc
83
91
 
84
92
  - [ ] The flags like `-std=gnu++14` are added to `compiler_flags` but are not applicable for C/Objective-C code.
85
93
  Most tools have differentiation between C flags (C and Objective-C) and Cxx flags (C++/Objective-C++).
94
+ The solution would be to return 2 sets of flags for C and Cxx families, instead of just one `compiler_flags` option.
95
+ - [ ] [Build setting transformations](http://codeworkshop.net/posts/xcode-build-setting-transformations) like `$(PRODUCT_NAME:c99extidentifer)` are [not supported yet](https://github.com/mgrebenets/fastlane-plugin-xcconfig_actions/issues/1).
96
+ - [ ] Xcconfig includes are resolved **before** variable references. For example:
97
+
98
+ ```c
99
+ #include "A.xcconfig"
100
+ VAR = A
101
+ #include "B.xcconfig" // Contains "VAR = B" statement.
102
+
103
+ // Resolved value of `VAR` is "B".
104
+ ```
105
+
106
+ Will be resolved in the following order:
107
+
108
+ ```c
109
+ #include "A.xcconfig"
110
+ #include "B.xcconfig"
111
+ VAR = A
112
+
113
+ // Resolved value of `VAR` is "A"!
114
+ ```
115
+
116
+ This will cause issues if value of `VAR` is set in `B.xcconfig`.
86
117
 
87
118
  ### validate_xcconfig
88
119
 
@@ -92,33 +123,33 @@ Validate xcconfig using set of very opinionated rules:
92
123
  - Include flow is unidirectional, i.e. top-down only:
93
124
 
94
125
  ```c
95
- #include "../level_up.xcconfig" // File is in parent directory.
126
+ #include "../level_up.xcconfig" // ERROR: File is in parent directory.
96
127
  ```
97
128
 
98
129
  - Files do not include other files on the same level:
99
130
 
100
131
  ```c
101
- #include "same_level.xcconfig" // Included file is on the same level.
132
+ #include "same_level.xcconfig" // ERROR: Included file is on the same level.
102
133
  ```
103
134
 
104
135
  - Files do not include other files more than 1 level down
105
136
 
106
137
  ```c
107
- #include "level1/level2/level2.xcconfig" // 2 levels down: level1/level2.
138
+ #include "level1/level2/level2.xcconfig" // ERROR: 2 levels down: level1/level2.
108
139
  ```
109
140
 
110
141
  - Duplicated includes are not allowed
111
142
 
112
143
  ```c
113
144
  #include "other.xcconfig"
114
- #include "other.xcconfig" // Duplicated include.
145
+ #include "other.xcconfig" // ERROR: Duplicated include.
115
146
  ```
116
147
 
117
148
  - Circular includes are not allowed
118
149
 
119
150
  ```c
120
151
  // example.xcconfig file
121
- #include "example.xcconfig" // Include self creates circular include.
152
+ #include "example.xcconfig" // ERROR: Include self creates circular include.
122
153
  ```
123
154
 
124
155
  Things **not supported** at the moment:
@@ -130,8 +161,8 @@ Things **not supported** at the moment:
130
161
  Xcconfigs are too easy to get out of hand.
131
162
  Ability to use arbitrary include paths complicates usage of xcconfigs in quite a few ways:
132
163
 
133
- - Hard to track where the variables are declared and the overwritten
134
- - Xcode does not always report an error when a file is missing
164
+ - Hard to track where the variables are declared and then overwritten
165
+ - Xcode does not always report an error when a file is missing, but silently fails to resolve variables instead
135
166
 
136
167
  These rules introduce convention to organizing xcconfigs.
137
168
  The end goal is to make config files more manageable.
@@ -1,6 +1,8 @@
1
1
  require 'fastlane/plugin/xcconfig_actions/version'
2
2
 
3
+ # Extension for Fastlane module.
3
4
  module Fastlane
5
+ # Main module for xcconfig actions plugin.
4
6
  module XcconfigActions
5
7
  # Return all .rb files inside the "actions" and "helper" directory
6
8
  def self.all_classes
@@ -4,14 +4,21 @@ require_relative '../helper/xcspec'
4
4
 
5
5
  module Fastlane
6
6
  module Actions
7
+ # Alias for helper class.
7
8
  ActionHelper = Fastlane::Helper::XcconfigActionsHelper
9
+ # Alias for Xcspec class.
8
10
  Xcspec = Fastlane::Helper::Xcspec
9
11
 
10
12
  module SharedValues
13
+ # Key for accessing build flags shared value in lane context.
11
14
  XCCONFIG_ACTIONS_BUILD_FLAGS = :XCCONFIG_ACTIONS_BUILD_FLAGS
12
15
  end
13
16
 
17
+ # Action to map build settings to build flags.
14
18
  class BuildSettingsToFlagsAction < Action
19
+ # Run action.
20
+ # @param [Hash] params Action parameters.
21
+ # @return [Hash] Build flags.
15
22
  def self.run(params)
16
23
  build_settings = params[:build_settings] || Actions.lane_context[SharedValues::XCCONFIG_ACTIONS_BUILD_SETTINGS]
17
24
  UI.user_error!("Missing build settings input") unless build_settings
@@ -50,6 +57,10 @@ module Fastlane
50
57
  # @!group Xcspecs
51
58
  ###
52
59
 
60
+ # Load complete spec.
61
+ # @param [String] name Name of the xcspec.
62
+ # @param [String] xcode Path to or version of Xcode.
63
+ # @return [Xcspec] Xcspec that includes Core Build System options.
53
64
  def self.load_complete_spec(name, xcode:)
54
65
  Xcspec.new(
55
66
  ActionHelper.find_xcspec(name, xcode: xcode),
@@ -57,6 +68,10 @@ module Fastlane
57
68
  )
58
69
  end
59
70
 
71
+ # Load xcspec.
72
+ # @param [String] name Spec name.
73
+ # @param [String] xcode Path to or version of Xcode.
74
+ # @return [Xcspec] Loaded xcspecs.
60
75
  def self.load_spec(name, xcode:)
61
76
  spec_path = ActionHelper.find_xcspec(name, xcode: xcode)
62
77
  Xcspec.new(spec_path)
@@ -66,18 +81,22 @@ module Fastlane
66
81
  # @!group Info and Options
67
82
  ###
68
83
 
84
+ # Plugin action description.
69
85
  def self.description
70
86
  "Map xcconfig build settings to compiler and linker build flags"
71
87
  end
72
88
 
89
+ # Plugin action authors.
73
90
  def self.authors
74
91
  ["Maksym Grebenets"]
75
92
  end
76
93
 
94
+ # Plugin action return value.
77
95
  def self.return_value
78
96
  "Build flags dictionary"
79
97
  end
80
98
 
99
+ # Plugin action details.
81
100
  def self.details
82
101
  [
83
102
  "Build flags keys:",
@@ -87,10 +106,12 @@ module Fastlane
87
106
  ].join("\n")
88
107
  end
89
108
 
109
+ # Plugin action category.
90
110
  def self.category
91
111
  :building
92
112
  end
93
113
 
114
+ # Plugin action available options.
94
115
  def self.available_options
95
116
  [
96
117
  FastlaneCore::ConfigItem.new(key: :build_settings,
@@ -115,6 +136,9 @@ module Fastlane
115
136
  ]
116
137
  end
117
138
 
139
+ # Check if platform is supported by the action.
140
+ # @param [Symbol] platform Platform to check.
141
+ # @return [Boolean] A Boolean indicating whether the platform is supported by the action.
118
142
  def self.is_supported?(platform)
119
143
  [:ios, :mac].include?(platform)
120
144
  end
@@ -3,12 +3,19 @@ require 'json'
3
3
  require_relative '../helper/xcconfig_actions_helper'
4
4
 
5
5
  module Fastlane
6
+ # Extension for Fastlane::Actions.
6
7
  module Actions
8
+ # Values shared by action.
7
9
  module SharedValues
10
+ # Key for accessing xcconfig shared value in lane context.
8
11
  XCCONFIG_ACTIONS_BUILD_SETTINGS = :XCCONFIG_ACTIONS_BUILD_SETTINGS
9
12
  end
10
13
 
14
+ # Action to read and resolve values in Xcconfig files.
11
15
  class ReadXcconfigAction < Action
16
+ # Run action.
17
+ # @param [Hash] params Action parameters.
18
+ # @return [Hash] Xcconfig dictionary.
12
19
  def self.run(params)
13
20
  path = params[:path]
14
21
  parent = params[:parent]
@@ -33,6 +40,11 @@ module Fastlane
33
40
  ###
34
41
 
35
42
  # Resolve config using parent information.
43
+ # @param [Hash] config Config to resolve.
44
+ # @param [Hash] parent Parent config.
45
+ # @param [String] srcroot Path to use for $(SRCROOT).
46
+ # @param [String] target_name Name to use for $(TARGET_NAME)
47
+ # @return [Hash] Resolved config.
36
48
  def self.resolve(config, parent, srcroot, target_name)
37
49
  parent_config = read_config(parent)
38
50
 
@@ -139,26 +151,32 @@ module Fastlane
139
151
  # @!group Info and Options
140
152
  ###
141
153
 
154
+ # Plugin action description.
142
155
  def self.description
143
156
  "Read and resolve contents of xcconfig file and return as JSON"
144
157
  end
145
158
 
159
+ # Plugin action authors.
146
160
  def self.authors
147
161
  ["Maksym Grebenets"]
148
162
  end
149
163
 
164
+ # Plugin action return value.
150
165
  def self.return_value
151
166
  "Parse and resolved build settings from xcconfig represented as JSON"
152
167
  end
153
168
 
169
+ # Plugin action details.
154
170
  def self.details
155
171
  ""
156
172
  end
157
173
 
174
+ # Plugin action category.
158
175
  def self.category
159
176
  :building
160
177
  end
161
178
 
179
+ # Plugin action available options.
162
180
  def self.available_options
163
181
  [
164
182
  FastlaneCore::ConfigItem.new(key: :path,
@@ -200,6 +218,9 @@ module Fastlane
200
218
  ]
201
219
  end
202
220
 
221
+ # Check if platform is supported by the action.
222
+ # @param [Symbol] platform Platform to check.
223
+ # @return [Boolean] A Boolean indicating whether the platform is supported by the action.
203
224
  def self.is_supported?(platform)
204
225
  [:ios, :mac].include?(platform)
205
226
  end
@@ -3,7 +3,11 @@ require_relative '../helper/xcconfig_actions_helper'
3
3
 
4
4
  module Fastlane
5
5
  module Actions
6
+ # Action for validating Xcconfig files.
6
7
  class ValidateXcconfigAction < Action
8
+ # Run action.
9
+ # @param [Hash] params Action parameters.
10
+ # @return [Array<String>] List of validation issues.
7
11
  def self.run(params)
8
12
  path = params[:path]
9
13
  root_path = params[:root_path]
@@ -17,9 +21,10 @@ module Fastlane
17
21
  ###
18
22
 
19
23
  # Validate xcconfig file.
20
- # @param [String] xcconfig path to xcconfig.
21
- # @param [String] root_path root path for all xcconfigs validated in this method.
22
- # @param [Array<String>] list of files included so far, used to detect circular includes.
24
+ # @param [String] xcconfig Path to xcconfig.
25
+ # @param [String] root_path Root path for all xcconfigs validated in this method.
26
+ # @param [Array<String>] included_paths List of files included so far, used to detect circular includes.
27
+ # @param [Int] level Nesting level of xcconfig.
23
28
  # @return [Array<String>] list of issues.
24
29
  def self.validate_xcconfig(xcconfig, root_path:, included_paths: [], level: 0)
25
30
  require "pathname"
@@ -68,18 +73,22 @@ module Fastlane
68
73
  # @!group Info and Options
69
74
  ###
70
75
 
76
+ # Plugin action description.
71
77
  def self.description
72
78
  "Validate xcconfig file"
73
79
  end
74
80
 
81
+ # Plugin action authors.
75
82
  def self.authors
76
83
  ["Maksym Grebenets"]
77
84
  end
78
85
 
86
+ # Plugin action return value.
79
87
  def self.return_value
80
88
  "List of validation issues"
81
89
  end
82
90
 
91
+ # Plugin action details.
83
92
  def self.details
84
93
  [
85
94
  "Validation rules:",
@@ -91,10 +100,12 @@ module Fastlane
91
100
  ].join("\n")
92
101
  end
93
102
 
103
+ # Plugin action category.
94
104
  def self.category
95
105
  :linting
96
106
  end
97
107
 
108
+ # Plugin action available options.
98
109
  def self.available_options
99
110
  [
100
111
  FastlaneCore::ConfigItem.new(key: :path,
@@ -116,6 +127,9 @@ module Fastlane
116
127
  ]
117
128
  end
118
129
 
130
+ # Check if platform is supported by the action.
131
+ # @param [Symbol] platform Platform to check.
132
+ # @return [Boolean] A Boolean indicating whether the platform is supported by the action.
119
133
  def self.is_supported?(platform)
120
134
  [:ios, :mac].include?(platform)
121
135
  end
@@ -4,15 +4,17 @@ module Fastlane
4
4
  UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
5
 
6
6
  module Helper
7
+ # Helper module for Xcconfig actions plugin.
7
8
  class XcconfigActionsHelper
8
9
  # Check if shell command exists.
10
+ # @param [String] cmd Shell command.
11
+ # @return [Boolean] A Boolean indicating whether the shell command exists.
9
12
  def self.command_exist?(cmd)
10
13
  `which #{cmd} 2>/dev/null`.chomp != ""
11
14
  end
12
15
 
13
16
  # class methods that you define here become available in your action
14
17
  # as `Helper::XcconfigActionsHelper.your_method`
15
- #
16
18
  def self.show_message
17
19
  UI.message("Hello from the xcconfig_actions plugin helper!")
18
20
  end
@@ -21,6 +23,8 @@ module Fastlane
21
23
  # 'config' containing the hash-map of resolved variables,
22
24
  # 'includes' containing an array of include paths.
23
25
  # The config values are not resolved.
26
+ # @param [String] path Xcconfig path.
27
+ # @return [Hash] Dictionary representing xcconfig.
24
28
  def self.read_xcconfig(path)
25
29
  # Get rid of comments and blank lines.
26
30
  contents = File.read(path).gsub(%r{\s*//.*$}, "").gsub(/^$\n/, "")
@@ -43,6 +47,10 @@ module Fastlane
43
47
  }
44
48
  end
45
49
 
50
+ # Find xcspec by name.
51
+ # @param [String] name Xcspec name.
52
+ # @param [String] xcode Path to Xcode app or Xcode version for version of bundled xcspecs, e.g. "10.2".
53
+ # @return [String] Path to xcspec file.
46
54
  def self.find_xcspec(name, xcode:)
47
55
  search_path = File.exist?(xcode) ? File.join(xcode, "Contents/{Plugins,Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications}") : File.join(File.dirname(__FILE__), "xcspecs", xcode)
48
56
 
@@ -2,23 +2,36 @@ require "plist"
2
2
  require "nokogiri-plist"
3
3
 
4
4
  module Fastlane
5
+ # Alias for displaying UI messages.
5
6
  UI = UI unless Fastlane.const_defined?("UI")
6
7
 
8
+ # Extension for Fastlane::Helper module.
7
9
  module Helper
8
10
  # Xcspec helper class.
9
11
  class Xcspec
10
12
  ###
11
13
  # @!group Mapping
12
14
  ###
15
+
16
+ # Class for managing build flags mapping.
13
17
  class Mapping
14
- attr_reader :flags, :linker_flags
18
+ # Main tool flags.
19
+ attr_reader :flags
20
+
21
+ # Additional linker flags
22
+ attr_reader :linker_flags
15
23
 
24
+ # Initialize new mapping.
25
+ # @param [String] flags Main tool flags.
26
+ # @param [String] linker_flags Additional linker flags.
16
27
  def initialize(flags = "", linker_flags = "")
17
28
  @flags = flags
18
29
  @linker_flags = linker_flags
19
30
  end
20
31
 
21
32
  # Join with other mapping and return new mapping.
33
+ # @param [Mapping] other Other mapping to join with.
34
+ # @return [Mapping] New joined mapping.
22
35
  def join(other)
23
36
  return self if other.nil?
24
37
 
@@ -33,8 +46,15 @@ module Fastlane
33
46
  # @!group Initialization
34
47
  ###
35
48
 
36
- attr_reader :path, :options
49
+ # Path to xcspec file.
50
+ attr_reader :path
37
51
 
52
+ # @return [Array<Hash>] Xcspec options.
53
+ attr_reader :options
54
+
55
+ # Create new instance.
56
+ # @param [String] path Path to xcspec file.
57
+ # @param [Xcspec] core_build_system_spec Core build system spec.
38
58
  def initialize(path, core_build_system_spec: nil)
39
59
  UI.user_error!("No such file: #{path}") unless path && File.exist?(path)
40
60
 
@@ -47,6 +67,9 @@ module Fastlane
47
67
  @options += core_build_system_spec.options if core_build_system_spec
48
68
  end
49
69
 
70
+ # Load plist as a dictionary.
71
+ # @param [String] path Path to plist file.
72
+ # @return [Hash] Plist dictionary.
50
73
  def self.load_plist(path)
51
74
  file_type = `file -b --mime-type #{path.shellescape}`.chomp
52
75
  if file_type == "text/xml" || file_type == "application/xml"
@@ -69,6 +92,9 @@ module Fastlane
69
92
  # @!group Helpers
70
93
  ###
71
94
 
95
+ # Find option by name.
96
+ # @param [String] name Option name.
97
+ # @return [Hash] Option or `nil`.
72
98
  def find_option(name)
73
99
  @options.find { |o| o["Name"] == name }
74
100
  end
@@ -77,6 +103,9 @@ module Fastlane
77
103
  # @!group Mapping
78
104
  ###
79
105
 
106
+ # Map build settings to build flags.
107
+ # @param [Hash] build_settings Build settings.
108
+ # @return [Hash] Build flags.
80
109
  def map_build_settings(build_settings)
81
110
  # Some settings like ENABLE_TESTABILITY are used as default value for other build settings,
82
111
  # e.g. SWIFT_ENABLE_TESTABILITY.
@@ -105,6 +134,11 @@ module Fastlane
105
134
  mappings.reduce(Mapping.new) { |memo, m| memo.join(m) }
106
135
  end
107
136
 
137
+ # Map single build setting value.
138
+ # @param [String] name Build setting name.
139
+ # @param [String] value Build setting value.
140
+ # @param [Hash] build_settings Dictionary of build settings to resolve the values against.
141
+ # @return [Array<Mapping>] List of mappings for this build setting value.
108
142
  def map_build_setting_value(name, value, build_settings)
109
143
  option = find_option(name)
110
144
  return nil unless option
@@ -112,6 +146,11 @@ module Fastlane
112
146
  map_option(option, value, build_settings)
113
147
  end
114
148
 
149
+ # Map the spec option to build settings using the value.
150
+ # @param [Hash] option Xcspec option describing build setting.
151
+ # @param [String] value Build setting value.
152
+ # @param [Hash] build_settings Dictionary of all build settings.
153
+ # @return [Array<Mapping>] List of mappings.
115
154
  def map_option(option, value, build_settings)
116
155
  # Evaluate and check the 'Condition'.
117
156
  return nil unless check_condition(option, build_settings)
@@ -122,6 +161,11 @@ module Fastlane
122
161
  scalar_values.flat_map { |v| map_option_scalar_value(option, v, build_settings) }.compact
123
162
  end
124
163
 
164
+ # Map the spec option scalar value to build flags.
165
+ # @param [Hash] option Xcspec option for build setting.
166
+ # @param [String] value Scalar value of the build setting.
167
+ # @param [Hash] build_settings Dictionary of all resolved build settings.
168
+ # @return [Mapping] Mapping for the specified scalar value.
125
169
  def map_option_scalar_value(option, value, build_settings)
126
170
  # At this point we deal with scalar value.
127
171
 
@@ -196,6 +240,12 @@ module Fastlane
196
240
  Mapping.new(flags, linker_flags)
197
241
  end
198
242
 
243
+ # Map command line arguments to build flags.
244
+ # @param [Hash] option Xcspec option for build setting.
245
+ # @param [Array<String>] args List of arguments to map.
246
+ # @param [String] value Value of the build setting.
247
+ # @param [Hash] build_settings All build settings to use for mapping.
248
+ # @return [String] Resolved value.
199
249
  def map_args(option, args, value, build_settings)
200
250
  return "" unless args
201
251
 
@@ -216,14 +266,24 @@ module Fastlane
216
266
  end
217
267
  end
218
268
 
269
+ ###
270
+ # @!group Evaluating Conditions
271
+ ###
272
+
219
273
  # Constants for condition evaluation.
274
+
275
+ # Value to use for `NO`.
220
276
  NO = false
277
+ # Value to use for `YES`.
221
278
  YES = true
222
279
 
223
280
  # Evaluate and check the condition.
224
281
  # Conditions come in form like this:
225
282
  # "$(COMPILER_INDEX_STORE_ENABLE) == YES || ( $(COMPILER_INDEX_STORE_ENABLE) == Default && $(GCC_OPTIMIZATION_LEVEL) == 0 )"
226
283
  # Return true if there's no condition to evaluate.
284
+ # @param [Hash] option Xcspec option for build setting.
285
+ # @param [Hash] build_settings All resolved build settings.
286
+ # @return [Boolean] A Boolean indicating whether condition passes or not.
227
287
  def check_condition(option, build_settings)
228
288
  condition = option["Condition"]
229
289
  return true unless condition
@@ -247,7 +307,7 @@ module Fastlane
247
307
  # which are replaced with `true` and `false`.
248
308
  # However, xcspecs are very inconsistent when it comes to strings.
249
309
  # Some values are used unquoted in the conditions, such as:
250
- # Defatult, mh_object, bitcode.
310
+ # Default, mh_object, bitcode.
251
311
  # There's also use of '' and \"\" for empty string, the latter may cause issues.
252
312
  # Then "same-as-input" that may have to be resolved - do not handle for now.
253
313
  # Finally, $(variant) == profile - just leave it for now.