openbakery / gradle-xcodePlugin

gradle plugin for building Xcode Projects for iOS, watchOS, macOS or tvOS
Apache License 2.0
457 stars 127 forks source link

xcodebuild.additionalParameters type? #379

Closed phatblat closed 2 years ago

phatblat commented 6 years ago

In order to work around oclint/oclint#462 in all our iOS builds, I attempted to set the additionalParameters value to an array containing a single string "COMPILER_INDEX_STORE_ENABLE=NO". However, this causes the xcodebuild task to fail.

Execution failed for task ':xcodebuild'.
> Command failed to run (exit code 134): '/Applications/Xcode-9.2.app/Contents/Developer/usr/bin/xcodebuild -scheme iOSApp-Debug -workspace iOSApp.xcworkspace -configuration Debug CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO [COMPILER_INDEX_STORE_ENABLE=NO,  ]-derivedDataPath /Users/phatblat/dev/gradle/test-iOSApp/build/derivedData DSTROOT=/Users/phatblat/dev/gradle/test-iOSApp/build/dst OBJROOT=/Users/phatblat/dev/gradle/test-iOSApp/build/obj SYMROOT=/Users/phatblat/dev/gradle/test-iOSApp/build/sym SHARED_PRECOMPS_DIR=/Users/phatblat/dev/gradle/test-iOSApp/build/shared'
  Tail of output:
  2018-02-07 18:00:20.290 xcodebuild[81148:1399253] [MT] DVTAssertions: ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-13763/DVTFoundation/MacroExpansion/DVTMacroDefinitionTable.mm:902
  Details:  macroName should be a non-empty string, but it's an empty string
  Object:   <DVTMacroDefinitionTable: 0x7fd552f117e0>
  Method:   -setValue:forMacroName:conditionSet:
  Thread:   <NSThread: 0x7fd552c17e80>{number = 1, name = main}
  Hints:

  Backtrace:
    0   -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation)
    1   _DVTAssertionHandler (in DVTFoundation)
    2   _DVTAssertionFailureHandler (in DVTFoundation)
    3   -[DVTMacroDefinitionTable setValue:forMacroName:conditionSet:] (in DVTFoundation)
    4   -[DVTMacroDefinitionTable setLiteralValue:forMacroName:conditionSet:] (in DVTFoundation)
    5   -[DVTMacroDefinitionTable setObject:forKeyedSubscript:] (in DVTFoundation)
    6   -[Xcode3CommandLineBuildTool _resolveInputOptionsWithTimingSection:] (in Xcode3Core)
    7   -[Xcode3CommandLineBuildTool run] (in Xcode3Core)
    8  0x000000010b73b2af (in xcodebuild)
    9   start (in libdyld.dylib)

The problem is that there are extra brackets around the custom build setting in the resulting command.

xcodebuild -scheme iOSApp-Debug -workspace iOSApp.xcworkspace -configuration Debug CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO [COMPILER_INDEX_STORE_ENABLE=NO, ]-derivedDataPath ...

However, setting additionalParameters to just a string instead of an array of string works fine.

Is this a defect or is the documentation incorrect? I'll try setting multiple build settings to see whether that also breaks.

phatblat commented 6 years ago

OK, this appears to be a Groovy thing. Both setting additionalParameters to a single string or a list literal (not array) in the xcodebuild DSL extension work.

Where I was going wrong was creating an Array<String> in kotlin like so:

xcodeExtension.additionalParameters = arrayOf("COMPILER_INDEX_STORE_ENABLE=NO")

I've changed our plugin to instead create a List<String> and now it's working.

xcodeExtension.additionalParameters = listOf("COMPILER_INDEX_STORE_ENABLE=NO")

Can the docs be updated to instead say "list of parameters"?