fix(ios): fixed Swift compilation conditions and flags #14352
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction:
These warnings have caused confusion for several times, particularly as false positive errors ([1], [2], [3], [4], [5]):
The values of the Swift compiler variable
SWIFT_ACTIVE_COMPILATION_CONDITIONSare copied fromGCC_PREPROCESSOR_DEFINITIONSiniphone/iphone/Titanium.xcodeproj/project.pbxproj.But
SWIFT_ACTIVE_COMPILATION_CONDITIONSdoesn'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.
DEPLOYTYPEflag was no longer used at all; instead,TI_APPLICATION_DEPLOYTYPEis available.__LOG__ID__flag is not needed because it has exactly the same value asTI_APPLICATION_GUID; instead, introduction of a conditional flagLOGTOFILEis sufficient.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:
splittedtransferred non-key-value flags ofGCC_PREPROCESSOR_DEFINITIONSfor use with SwiftintotoSWIFT_ACTIVE_COMPILATION_CONDITIONS(conditional compilation flags)andOTHER_SWIFT_FLAGS(key-value pairs)swiftCondsto clearly distinguish fromgccDefs(this also prevents similar programming mistakes in the future) and a new config variableSWIFT_CONDITIONSinproject.xcconfigTI_APPLICATION_DEPLOYTYPEintoTI_APPLICATION_DEPLOY_TYPEto consistently take camel case into account (comp. withdeployType)__APP_DEPLOY_TYPE__(=buildType) into__BUILD_TYPE__to avoid confusion with__DEPLOY_TYPE__(=deployType)