xcodeproj 1.4.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 192dc46594552b9f7ef13f59410e344bbcdf526f
4
- data.tar.gz: 8ce16e389789992902014ed549b9859236ec1d20
3
+ metadata.gz: f8046e57ba42d21845af2c95f063f5c51fd87625
4
+ data.tar.gz: 261b049b8d6d5dbc3884901e1bd6a6d184a6b0ed
5
5
  SHA512:
6
- metadata.gz: 1e5d6e72e955a40a422695d554e1cb9fe8e7cec0021c19047149f3c0d4ec44408d57ff7a9f6bef5f32ddc5fde2ddb1281b53446cac943a136f61a05ad97dd7e9
7
- data.tar.gz: 23d02d150fabb995dba2d27b38db0f3e859fe98a0d7994cf1409b9cf11901bad987daaa5b49dd9ad9d4283321bbd45bd229d6645c25e41e5e824fd30cd981e10
6
+ metadata.gz: 4c6bdef5a2db8877086391a9ba5382ec220a58fa4cd212c432ddb2dd7659a964baf30f96566ec83c54a9de6ff427f7e4a27f161997670298ea898205390899b7
7
+ data.tar.gz: 31e7ec5eb73b9c36733b21d53997fc06e6ca986d8eb11438f611aeda9fbb7fad607e65438d9f11a452f590c538d5bc3e418b0f3f141d5a823dc99c5bae326b90
@@ -383,5 +383,12 @@ module Xcodeproj
383
383
  # @return [Array] The extensions which are associated with header files.
384
384
  #
385
385
  HEADER_FILES_EXTENSIONS = %w(.h .hh .hpp .ipp .tpp .hxx .def).freeze
386
+
387
+ # @return [Array] The keywords Xcode use to identify a build setting can
388
+ # inherit values from a previous precedence level
389
+ INHERITED_KEYWORDS = %w(
390
+ $(inherited)
391
+ ${inherited}
392
+ ).freeze
386
393
  end
387
394
  end
@@ -1,5 +1,5 @@
1
1
  module Xcodeproj
2
2
  # The version of the xcodeproj gem.
3
3
  #
4
- VERSION = '1.4.4'.freeze unless defined? Xcodeproj::VERSION
4
+ VERSION = '1.5.0'.freeze unless defined? Xcodeproj::VERSION
5
5
  end
@@ -809,6 +809,8 @@ module Xcodeproj
809
809
  targets.each do |target|
810
810
  scheme = XCScheme.new
811
811
  scheme.add_build_target(target)
812
+ scheme.add_test_target(target) if target.test_target_type?
813
+ yield scheme, target if block_given?
812
814
  scheme.save_as(path, target.name, false)
813
815
  xcschememanagement['SchemeUserState']["#{target.name}.xcscheme"] = {}
814
816
  xcschememanagement['SchemeUserState']["#{target.name}.xcscheme"]['isShown'] = visible
@@ -57,7 +57,7 @@ module Xcodeproj
57
57
  # debugging.
58
58
  #
59
59
  def debug?
60
- gcc_preprocessor_definitions = build_settings['GCC_PREPROCESSOR_DEFINITIONS']
60
+ gcc_preprocessor_definitions = resolve_build_setting('GCC_PREPROCESSOR_DEFINITIONS')
61
61
  gcc_preprocessor_definitions && gcc_preprocessor_definitions.include?('DEBUG=1')
62
62
  end
63
63
 
@@ -68,10 +68,41 @@ module Xcodeproj
68
68
  debug? ? :debug : :release
69
69
  end
70
70
 
71
+ # @!group Helpers
72
+ #---------------------------------------------------------------------#
73
+
74
+ # Gets the value for the given build setting considering any configuration
75
+ # file present and resolving inheritance between them
76
+ #
77
+ # @param [String] key
78
+ # the key of the build setting.
79
+ #
80
+ # @return [String] The value of the build setting
81
+ #
82
+ def resolve_build_setting(key)
83
+ setting = build_settings[key]
84
+ config_setting = base_configuration_reference && config[key]
85
+
86
+ project_setting = project.build_configuration_list[name]
87
+ project_setting = nil if project_setting == self
88
+ project_setting &&= project_setting.resolve_build_setting(key)
89
+
90
+ [project_setting, config_setting, setting].compact.reduce do |inherited, value|
91
+ expand_build_setting(value, inherited)
92
+ end
93
+ end
94
+
71
95
  #---------------------------------------------------------------------#
72
96
 
73
97
  private
74
98
 
99
+ def expand_build_setting(build_setting_value, config_value)
100
+ default = build_setting_value.is_a?(String) ? '' : []
101
+ inherited = config_value || default
102
+ return build_setting_value.gsub(Regexp.union(Constants::INHERITED_KEYWORDS), inherited) if build_setting_value.is_a? String
103
+ build_setting_value.map { |value| Constants::INHERITED_KEYWORDS.include?(value) ? inherited : value }.flatten
104
+ end
105
+
75
106
  def sorted_build_settings
76
107
  sorted = {}
77
108
  build_settings.keys.sort.each do |key|
@@ -126,6 +157,12 @@ module Xcodeproj
126
157
  string.scan(regexp).map(&:first)
127
158
  end
128
159
 
160
+ def config
161
+ @config ||= Xcodeproj::Config.new(base_configuration_reference.real_path).to_hash.tap do |hash|
162
+ normalize_array_settings(hash)
163
+ end
164
+ end
165
+
129
166
  #---------------------------------------------------------------------#
130
167
  end
131
168
  end
@@ -62,13 +62,17 @@ module Xcodeproj
62
62
  # @param [String] key
63
63
  # the key of the build setting.
64
64
  #
65
+ # @param [Bool] resolve_against_xcconfig
66
+ # wether the retrieved setting should take in consideration any
67
+ # configuration file present.
68
+ #
65
69
  # @return [Hash{String => String}] The value of the build setting
66
70
  # grouped by the name of the build configuration.
67
71
  #
68
- def get_setting(key)
72
+ def get_setting(key, resolve_against_xcconfig = false)
69
73
  result = {}
70
74
  build_configurations.each do |bc|
71
- result[bc.name] = bc.build_settings[key]
75
+ result[bc.name] = resolve_against_xcconfig ? bc.resolve_build_setting(key) : bc.build_settings[key]
72
76
  end
73
77
  result
74
78
  end
@@ -41,18 +41,30 @@ module Xcodeproj
41
41
  # @param [String] key
42
42
  # the key of the build setting.
43
43
  #
44
+ # @param [Bool] resolve_against_xcconfig
45
+ # wether the resolved setting should take in consideration any
46
+ # configuration file present.
47
+ #
44
48
  # @return [Hash{String => String}] The value of the build setting
45
49
  # grouped by the name of the build configuration.
46
50
  #
47
51
  # TODO: Full support for this would require to take into account
48
- # any associated xcconfig and the default values for the
49
- # platform.
52
+ # the default values for the platform.
50
53
  #
51
- def resolved_build_setting(key)
52
- target_settings = build_configuration_list.get_setting(key)
53
- project_settings = project.build_configuration_list.get_setting(key)
54
+ def resolved_build_setting(key, resolve_against_xcconfig = false)
55
+ target_settings = build_configuration_list.get_setting(key, resolve_against_xcconfig)
56
+ project_settings = project.build_configuration_list.get_setting(key, resolve_against_xcconfig)
54
57
  target_settings.merge(project_settings) do |_key, target_val, proj_val|
55
- target_val || proj_val
58
+ target_includes_inherited = Constants::INHERITED_KEYWORDS.any? { |keyword| target_val.include?(keyword) } if target_val
59
+ if target_includes_inherited && proj_val
60
+ if target_val.is_a? String
61
+ target_val.gsub(Regexp.union(Constants::INHERITED_KEYWORDS), proj_val)
62
+ else
63
+ target_val.map { |value| Constants::INHERITED_KEYWORDS.include?(value) ? proj_val : value }.flatten
64
+ end
65
+ else
66
+ target_val || proj_val
67
+ end
56
68
  end
57
69
  end
58
70
 
@@ -143,6 +143,43 @@ module Xcodeproj
143
143
  target
144
144
  end
145
145
 
146
+ # Creates a new legacy target and adds it to the project.
147
+ #
148
+ # The target is configured for the given platform.
149
+ #
150
+ # @param [Project] project
151
+ # the project to which the target should be added.
152
+ #
153
+ # @param [String] name
154
+ # the name of the aggregate target.
155
+ #
156
+ # @param [String] build_tool_path
157
+ # the build tool path to use for this target.
158
+ #
159
+ # @param [String] build_arguments_string
160
+ # the build arguments string to use for this target.
161
+ #
162
+ # @param [String] build_working_directory
163
+ # the build working directory to use for this target.
164
+ #
165
+ # @param [String] pass_build_settings_in_environment
166
+ # whether to pass build settings in the environment during execution of this target.
167
+ #
168
+ # @return [PBXLegacyTarget] the target.
169
+ #
170
+ def self.new_legacy_target(project, name, build_tool_path = '/usr/bin/make', build_arguments_string = '$(ACTION)',
171
+ build_working_directory = nil, pass_build_settings_in_environment = '1')
172
+ target = project.new(PBXLegacyTarget)
173
+ project.targets << target
174
+ target.name = name
175
+ target.build_configuration_list = configuration_list(project)
176
+ target.build_tool_path = build_tool_path
177
+ target.build_arguments_string = build_arguments_string
178
+ target.build_working_directory = build_working_directory
179
+ target.pass_build_settings_in_environment = pass_build_settings_in_environment
180
+ target
181
+ end
182
+
146
183
  # @!group Private Helpers
147
184
 
148
185
  #-----------------------------------------------------------------------#
@@ -52,7 +52,9 @@ module Xcodeproj
52
52
  # Each entry represent a target to build and tells for which action it's needed to be built.
53
53
  #
54
54
  def entries
55
- @xml_element.elements['BuildActionEntries'].get_elements('BuildActionEntry').map do |entry_node|
55
+ entries = @xml_element.elements['BuildActionEntries']
56
+ return nil unless entries
57
+ entries.get_elements('BuildActionEntry').map do |entry_node|
56
58
  BuildAction::Entry.new(entry_node)
57
59
  end
58
60
  end
@@ -101,6 +101,24 @@ module Xcodeproj
101
101
  env_vars
102
102
  end
103
103
 
104
+ # @todo handle 'AdditionalOptions' tag
105
+
106
+ # @return [CommandLineArguments]
107
+ # Returns the CommandLineArguments that will be passed at app launch
108
+ #
109
+ def command_line_arguments
110
+ CommandLineArguments.new(@xml_element.elements[XCScheme::COMMAND_LINE_ARGS_NODE])
111
+ end
112
+
113
+ # @return [CommandLineArguments] arguments
114
+ # Sets the CommandLineArguments that will be passed at app launch
115
+ #
116
+ def command_line_arguments=(arguments)
117
+ @xml_element.delete_element(XCScheme::COMMAND_LINE_ARGS_NODE)
118
+ @xml_element.add_element(arguments.xml_element) if arguments
119
+ arguments
120
+ end
121
+
104
122
  #-------------------------------------------------------------------------#
105
123
 
106
124
  class TestableReference < XMLElementWrapper
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcodeproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-07 00:00:00.000000000 Z
11
+ date: 2017-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: CFPropertyList
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.1
33
+ version: 1.0.2
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '2.0'
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 1.0.1
43
+ version: 1.0.2
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '2.0'
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  version: '0'
160
160
  requirements: []
161
161
  rubyforge_project:
162
- rubygems_version: 2.6.11
162
+ rubygems_version: 2.4.5.1
163
163
  signing_key:
164
164
  specification_version: 3
165
165
  summary: Create and modify Xcode projects from Ruby.