Module: Xcode::Configuration::SpaceDelimitedString

Extended by:
SpaceDelimitedString
Included in:
SpaceDelimitedString
Defined in:
lib/xcode/configurations/space_delimited_string_property.rb

Overview

Within the a build settings for a configuration there are a number of settings that are stored a space-delimited strings. This helper module provides the opening and saving of these values.

When opened the value returns is going to be an Array.

Examples:

common build settings that are space delimited


Supported Platforms      : SUPPORTED_PLATFORMS
User Header Search Paths : USER_HEADER_SEARCH_PATHS
Other Test Flags         : OTHER_TEST_FLAGS

setting and getting supported platforms


debug_config project.target('SomeTarget').config('Debug')
debug_config.supported_platforms  # => []
debug_config.supported_platforms = "PLATFORM A"
debug_config.supported_platforms  # => [ "PLATFORM A" ]

Instance Method Summary collapse

Instance Method Details

#append(original, value) ⇒ Object

Space Delimited Strings are not unlike arrays and those we assume that the inputs are going to be two arrays that will be joined and then ensured that only the unique values are saved.

Parameters:

  • original (Nil, String)

    the original value stored within the field

  • value (Nil, String, Array)

    the new values that will coerced into an array and joined with the original values.



58
59
60
# File 'lib/xcode/configurations/space_delimited_string_property.rb', line 58

def append(original,value)
  save( ( open(original) + Array(value)).uniq )
end

#open(value) ⇒ Array<String>

While the space delimited string can and is often stored in that way, it appears as though Xcode is now possibly storing these values in a format that the parser is returning as an Array. So if the raw value is an array, simply return that raw value instead of attempting to convert it.

Parameters:

  • value (Nil, String)

    stored within the build settings

Returns:

  • (Array<String>)

    a list of the strings that are within this string



37
38
39
# File 'lib/xcode/configurations/space_delimited_string_property.rb', line 37

def open(value)
  value.is_a?(Array) ? value : value.to_s.split(" ")
end

#save(value) ⇒ String

Returns the space-delimited string.

Parameters:

  • value (Array, String)

    to be converted into the correct format

Returns:

  • (String)

    the space-delimited string



45
46
47
# File 'lib/xcode/configurations/space_delimited_string_property.rb', line 45

def save(value)
  Array(value).join(" ")
end