fix(ios): fixed Swift compilation conditions and flags
Introduction:
These warnings have caused confusion for several times, particularly as false positive errors ([1], [2], [3], [4], [5]):
warning: Conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'DEPLOYTYPE=development') ...
warning: Conditional compilation flags do not have values in Swift; they are either present or absent (rather than '__LOG__ID__=******') ...
warning: Conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'DEBUG=1') ...
warning: Conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'LAUNCHSCREEN_STORYBOARD=1') ...
warning: Conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'DEFAULT_BGCOLOR_RED=1') ...
warning: Conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'DEFAULT_BGCOLOR_GREEN=1') ...
warning: Conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'DEFAULT_BGCOLOR_BLUE=1') ...
warning: Conditional compilation flags do not have values in Swift; they are either present or absent (rather than 'DISABLE_TI_LOG_SERVER=1') ...
The values of the Swift compiler variable SWIFT_ACTIVE_COMPILATION_CONDITIONS are copied from GCC_PREPROCESSOR_DEFINITIONS in iphone/iphone/Titanium.xcodeproj/project.pbxproj.
But SWIFT_ACTIVE_COMPILATION_CONDITIONS doesn't allow key-value pairs,
only a list of conditional compilation flags like in TI_SYMBOL_MACROS – that is why the above warnings are raised.
[!NOTE] My initial naive solution did not work because the Swift compiler does not support key-value compiler flags at all!
But do we even need key-value compiler flags? Of course, it's a simple "traditional" way – easy to maintain. But I don't think so in this case. So far, they have only been used in
main.m. And in my opinion, compiler optimizations will make the minimal performance advantage for these few values obsolete.
- The
DEPLOYTYPEflag was no longer used at all; instead,TI_APPLICATION_DEPLOYTYPEis available.- The
__LOG__ID__flag is not needed because it has exactly the same value asTI_APPLICATION_GUID; instead, introduction of a conditional flagLOGTOFILEis sufficient.- Only the following flags remain:
TI_LOG_SERVER_PORTandDEFAULT_BGCOLOR_RED/..._GREEN/..._BLUE. These four can easily be replaced as templated values inwriteMain()too, analogous to App-ID/GUID/etc.
Description:
- ~~splitted~~ transferred non-key-value flags of
GCC_PREPROCESSOR_DEFINITIONSfor use with Swift ~~into~~ toSWIFT_ACTIVE_COMPILATION_CONDITIONS(conditional compilation flags)- ~~and
OTHER_SWIFT_FLAGS(key-value pairs)~~
- therefore, added new array
swiftCondsto clearly distinguish fromgccDefs(this also prevents similar programming mistakes in the future) and a new config variableSWIFT_CONDITIONSinproject.xcconfig - replaced all current key-value compiler flags (see Note above)
- additionally made some "chore":
- changed
TI_APPLICATION_DEPLOYTYPEintoTI_APPLICATION_DEPLOY_TYPEto consistently take camel case into account (comp. withdeployType) - changed templated value
__APP_DEPLOY_TYPE__(=buildType) into__BUILD_TYPE__to avoid confusion with__DEPLOY_TYPE__(=deployType)
- changed
All alerts resolved. Learn more about Socket for GitHub.
This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.
Changes from initial draft:
- ~~replaced undocumented
SWIFT_COMPILER_FLAGSwithOTHER_SWIFT_FLAGS^1~~ - use of JS arrow functions
New changes:
- rework: replaced key-value compiler flags overall