It seems that the purpose of the --strict flag in SwiftLint is to display or log linter violations as errors. I'd like to use that functionality but I am still seeing everything that has a .Warning
level of severity displayed in Xcode or logged on the command line as a warning.
I have attempted to add this flag to a script which runs linting on certain project files, and also to linting on the command line.
In our build script I've tried:
file
is a variable in our build script.
On the command line I've tried the same thing, but without a reference to any particular file, and with different file path specification syntax, since I don't believe SRCROOT works correctly there.
The build script displays these violations as warnings and the command on the command line prints "warning........" for each violation.
Has anyone else seen this issue?
Thanks!
The only thing that the --strict
flag does is to change the exit status code. It's like Xcode's "treat warnings as errors" setting.
Warnings are still warnings, but unlike regular SwiftLint operation which exits 0
if only warnings were found, --strict
will make the presence of warnings _or_ errors exit with 1
:
$ echo "let abc:Int = 0" | swiftlint lint --use-stdin
<nopath>:1:5: warning: Colon Violation: Colons should be next to the identifier when specifying a type. (colon)
Done linting! Found 1 violation, 0 serious in 1 file.
$ echo $?
0
$ echo "let abc:Int = 0" | swiftlint lint --use-stdin --strict
<nopath>:1:5: warning: Colon Violation: Colons should be next to the identifier when specifying a type. (colon)
Done linting! Found 1 violation, 0 serious in 1 file.
$ echo $?
1
In your view, what is the best way to display all violations as errors using SwiftLint?
One thing I played around with was modifying the source code to add a 'severity' parameter to the style violation initializer of certain rules (the same way it's being done in the force casting rule implementation) and to pass in .Error to the severity param, which did not work.
If you're building SwiftLint from source, you could hardcode error
on this line of the Xcode reporter.
However, I'd love to know what your motivation for this is, so we can come up with a more generally applicable solution within SwiftLint so you don't have to build from source and maintain this patch.
Of course!
The primary reason is cultural.
People do not take warnings as seriously as they should. Errors, obviously, have to be dealt with immediately. Warnings do not. This isn't because they do not believe in or write high quality code. There are lots of reasons why a project might have a few lingering warnings.
To me, the point of linting is introducing a passive tool that communicates a team's values and improves their code.
Introducing warnings into a project means that a linter becomes not actually a totally passive tool. Its usage then requires some policing by other team members -- not because people are lazy, but because they have to decide how to allocate their time, and sometimes resolving warnings can't be done in a certain time frame. Also, if an app already has a few warnings (see explanation for reasons why below) they can easily forget whether or not they added warnings until they merge a PR and see if the CI tool suggests that they introduced new warnings into the project.
There are lots of reasons why a code base might already have some warnings -- these include needing to integrate 3rd party code which introduces warnings -- sometimes unavoidable on large apps owned by mid sized or large companies -- and the fact that fast moving teams sometimes just need to leave errors in their code temporarily. Moreover, apps that have been in development for many years may have legacy code with warnings that people have not yet found time to fix. That's not the case on the app I work on, but I can absolutely see that happening on other teams. For that reason, having linter violations displayed as warnings does not have the kind of impact you would hope for.
In my view, linter violations are far more likely to be dealt with if SourceKit/the compiler provide errors rather than warnings in the IDE.
If you implement more fix-its in the SwiftLint project I think this point still stands -- I would like to see errors in my project where linter rules are not respected, and suggestions for changes, like what's built into Xcode using SourceKit.
Note: This whole comment is based on a model where the transition to a SwiftLinted project is first only performed on files that have a diff in a developer's current branch, using a build script, and then on the entire project potentially. This helps mitigate the fact that a project that only shows errors, not warnings after being linter, would require potentially tons of changes in order to build.
What do you think about this, JP? I'm really interested in your opinion, and in your reasoning for initially not introducing this functionality.
So why don't you get all that from having --strict
or setting "treat warnings as errors" in your Xcode project? Seems like the only thing that's different would be the color of the Xcode warning/error UI element (from yellow to red).
One thing we could do is have the --strict
flag always set ViolationSeverity
to .Error
. I'm hesitant to do this because:
We could also introduce a 4th reporter (xcode-error
/XcodeErrorReporter
) that just hardcodes error
in its output like what was mentioned earlier.
Keep in mind that the only difference in all this is the color of the Xcode UI element, which I'm not sure has the cultural impact you're looking for.
So why don't you get all that from having --strict or setting "treat warnings as errors" in your Xcode project? Seems like the only thing that's different would be the color of the Xcode warning/error UI element (from yellow to red).
Just to clarify what I was trying to explain before, in a project that has unavoidable warnings that can't, for reasons mentioned above, be resolved immediately, you can't treat all warnings as errors, or you won't be able to compile before they're all resolved. I'm assuming 'treat warnings as errors' prevents compiling with warnings.
We could also introduce a 4th reporter (xcode-error/XcodeErrorReporter) that just hardcodes error in its output like what was mentioned earlier.
This seems like a good idea to me. When speaking with a bunch of people considering linting their Swift projects recently, it seemed that a handful - some Swift developers, some developers working in other languages who have used linters in those languages - were concerned about whether linters will be useful for their teams if they only treat violations as warnings.
Oh, I now understand what you're saying -- strict prevents compilation but does not show errors.
Oh, I now understand what you're saying -- strict prevents compilation but does not show errors.
Rather --strict
returns an exit code of 1
if any warnings _or_ errors were identified, and doesn't affect the rendering of these violations (in Xcode or command line).
... were concerned about whether linters will be useful for their teams if they only treat violations as warnings.
If linting is part of their CI, then if they use --strict
, their builds will fail if they have any warnings. Really, the only thing to gain from having an XcodeErrorReporter
is the color of UI annotations.
Really, the only thing to gain from having an XcodeErrorReporter is the color of UI annotations.
I think that's very useful from a UI standpoint.
1) It feels hacky to me that there are two kinds of 'warnings' that looks exactly the same but act differently -- one kind that can be compiled and one kind that can't.
2) I think every person who comes to the code base I'm working on will essentially need that concept explained to them, rather than it being implied by the color of the linter errors, which relies on their existing knowledge of Xcode. Even if I specify that in a README about the code base, it has a higher chance of error/questions from team members than displaying linter violations in red/as warnings.
That said, I'm really happy this does return an exit code of 1.
You might be right that the entire concept of graded violation severities is unnecessary. That a violation should be binary rather than graded.
My initial motivation for introducing it was to distinguish between something that was unequivocally an issue from something more debatably so (either false positives or matters of personal preference).
That being said, I don't gather usage metrics on SwiftLint so I don't know if this grading is actually useful in practice, or if it just complicates SwiftLint's conceptual model as you say. I'd like to know more about how people use SwiftLint before acting on that though.
We've reduced the number of violation severities before (#114), and I'm not opposed to abolishing it entirely if that's what active SwiftLint users suggest.
@jpsim In my opinion both have their place - an alternative would be to allow consumers of SwiftLint to choose their own violation level for each provided rule?
Yeah, I'd love support for violation levels for all rules, not just parameterized ones.
In my opinion both have there place - an alternative would be to allow consumers of SwiftLint to choose their own violation level for each provided rule?
I agree. It's nice that people can configure it in a way that fits their usage. Maybe a person working on a one-person team likes warnings, and is confident they will take the time to fix them, for instance.
Though personally, I would not want to use SwiftLint that way.
In my opinion both have their place - an alternative would be to allow consumers of SwiftLint to choose their own violation level for each provided rule?
FWIW this can be done today but it's super ugly.
type_body_length:
- 1000000000 # warning, never triggered
- 400 # error
Thanks for sharing your thoughts on this.
FWIW this can be done today but it's super ugly.
Can you do something like this for binary rules like the force cast rule?
No, because it doesn't conform to ParameterizedRule
.
No, because it doesn't conform to ParameterizedRule.
Ah I see - interesting.
How would you feel about us building functionality to allow users to change violation levels on all rules?
How would you feel about us building functionality to allow users to change violation levels on all rules?
I'd welcome that change, but I'd encourage you to propose a design for this first before implementing it because it'd be easy for such a change to introduce avoidable complexity.
Thanks for your thoughts and quick responses, JP.
I'm going to think about this and come back with a few ideas.
@tamarnachmany did you give this any further thought?
I actually just completed my 'v1' integration of SwiftLint! Very excited. It took a little bit of maneuvering because I want to lint gradually. I can now start taking a look at this.
As far as this original issue I raised here, I'm not sure SwiftLint is working exactly as intended at the moment.
When I introduce an error, I get these things:
So the branch will not compile (good) but doesn't return a nonzero exit code (bad) which introduces an associated error ("Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure").
As far as I understand, the --strict flag _should_ be returning a nonzero exit code if violations exist. Am I right in thinking this suggests an issue with Commandant/SwiftLint in this case? I distantly remember this working correctly previously?
A red 'error' where the violation occurs.
This is expected
An error that reads "Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure"
This error "Thread 12: signal SIGABRT"
These look like either bugs in SwiftLint, or an incomplete SwiftLint installation. The last message (SIGABRT) should be accompanied by a backtrace. Could you please share that here?
In any case, I don't think any of this relates to the intended behavior of SwiftLint but rather a bug or misconfiguration, so I'd encourage you to file a new issue describing that so we can keep this thread focused on evaluating different --strict
behavior.
Sure.
Real quick before I repost this as a separate issue, is this what you're looking for?
Is this what you're looking for?
PhaseScriptExecution Lint\ Swift\ Files /Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/Project.build/Debug-iphoneos/Share.build/Script-32B957CD1C24634700560E0C.sh
cd /Users/tamar/project
export ACTION=build
export AD_HOC_CODE_SIGNING_ALLOWED=NO
export ALTERNATE_GROUP=staff
export ALTERNATE_MODE=u+w,go-w,a+rX
export ALTERNATE_OWNER=tamar
export ALWAYS_SEARCH_USER_PATHS=NO
export ALWAYS_USE_SEPARATE_HEADERMAPS=NO
export APPLE_INTERNAL_DEVELOPER_DIR=/AppleInternal/Developer
export APPLE_INTERNAL_DIR=/AppleInternal
export APPLE_INTERNAL_DOCUMENTATION_DIR=/AppleInternal/Documentation
export APPLE_INTERNAL_LIBRARY_DIR=/AppleInternal/Library
export APPLE_INTERNAL_TOOLS=/AppleInternal/Developer/Tools
export APPLICATION_EXTENSION_API_ONLY=YES
export APPLY_RULES_IN_COPY_FILES=NO
export ARCHS=arm64
export ARCHS_STANDARD="armv7 arm64"
export ARCHS_STANDARD_32_64_BIT="armv7 arm64"
export ARCHS_STANDARD_32_BIT=armv7
export ARCHS_STANDARD_64_BIT=arm64
export ARCHS_STANDARD_INCLUDING_64_BIT="armv7 arm64"
export ARCHS_UNIVERSAL_IPHONE_OS="armv7 arm64"
export ASSETCATALOG_COMPILER_APPICON_NAME=ProjectIcon
export AVAILABLE_PLATFORMS="watchos iphonesimulator macosx appletvsimulator watchsimulator appletvos iphoneos"
export BITCODE_GENERATION_MODE=marker
export BUILD_ACTIVE_RESOURCES_ONLY=YES
export BUILD_COMPONENTS="headers build"
export BUILD_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/Project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products
export BUILD_ROOT=/Users/tamar/Library/Developer/Xcode/DerivedData/Project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products
export BUILD_STYLE=
export BUILD_VARIANTS=normal
export BUILT_PRODUCTS_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/Project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos
export BUNDLE_IDENTIFIER=com.Project.Project.Share-With-Project
export CACHE_ROOT=/var/folders/v4/03qmpx656_n9l3_z4j7s8zq80000gn/C/com.apple.DeveloperTools/7.2-7C68/Xcode
export CCHROOT=/var/folders/v4/03qmpx656_n9l3_z4j7s8zq80000gn/C/com.apple.DeveloperTools/7.2-7C68/Xcode
export CHMOD=/bin/chmod
export CHOWN=/usr/sbin/chown
export CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER=NO
export CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND=YES
export CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY=YES
export CLANG_ENABLE_MODULES=YES
export CLANG_ENABLE_OBJC_ARC=YES
export CLANG_MODULES_BUILD_SESSION_FILE=/Users/tamar/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation
export CLANG_WARN_BOOL_CONVERSION=YES
export CLANG_WARN_CONSTANT_CONVERSION=YES
export CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS=YES
export CLANG_WARN_DIRECT_OBJC_ISA_USAGE=YES_ERROR
export CLANG_WARN_EMPTY_BODY=YES
export CLANG_WARN_ENUM_CONVERSION=YES
export CLANG_WARN_INT_CONVERSION=YES
export CLANG_WARN_OBJC_ROOT_CLASS=YES_ERROR
export CLANG_WARN_UNREACHABLE_CODE=YES
export CLANG_WARN__DUPLICATE_METHOD_MATCH=YES
export CLASS_FILE_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/Project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/Project.build/Debug-iphoneos/Share.build/JavaClasses
export CLEAN_PRECOMPS=YES
export CLONE_HEADERS=NO
export CODESIGNING_FOLDER_PATH=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos/Share.appex
export CODE_SIGNING_ALLOWED=YES
export CODE_SIGNING_REQUIRED=YES
export CODE_SIGN_CONTEXT_CLASS=XCiPhoneOSCodeSignContext
export CODE_SIGN_ENTITLEMENTS="Resources/Entitlements/Share With project.entitlements"
export CODE_SIGN_IDENTITY="iPhone Developer"
export COLOR_DIAGNOSTICS=NO
export COMBINE_HIDPI_IMAGES=NO
export COMMAND_MODE=legacy
export COMPOSITE_SDK_DIRS=/var/folders/v4/03qmpx656_n9l3_z4j7s8zq80000gn/C/com.apple.DeveloperTools/7.2-7C68/Xcode/CompositeSDKs
export COMPRESS_PNG_FILES=YES
export CONFIGURATION=Debug
export CONFIGURATION_BUILD_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos
export CONFIGURATION_TEMP_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos
export CONTENTS_FOLDER_PATH=Share.appex
export COPYING_PRESERVES_HFS_DATA=NO
export COPY_HEADERS_RUN_UNIFDEF=NO
export COPY_PHASE_STRIP=NO
export COPY_RESOURCES_FROM_STATIC_FRAMEWORKS=YES
export CORRESPONDING_SIMULATOR_PLATFORM_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform
export CORRESPONDING_SIMULATOR_PLATFORM_NAME=iphonesimulator
export CORRESPONDING_SIMULATOR_SDK_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk
export CORRESPONDING_SIMULATOR_SDK_NAME=iphonesimulator9.2
export CP=/bin/cp
export CREATE_INFOPLIST_SECTION_IN_BINARY=NO
export CURRENT_ARCH=arm64
export CURRENT_PROJECT_VERSION=436
export CURRENT_VARIANT=normal
export DEAD_CODE_STRIPPING=YES
export DEBUGGING_SYMBOLS=YES
export DEBUG_INFORMATION_FORMAT=dwarf
export DEFAULT_COMPILER=com.apple.compilers.llvm.clang.1_0
export DEFAULT_KEXT_INSTALL_PATH=/System/Library/Extensions
export DEFINES_MODULE=YES
export DEPLOYMENT_LOCATION=NO
export DEPLOYMENT_POSTPROCESSING=NO
export DEPLOYMENT_TARGET_CLANG_ENV_NAME=IPHONEOS_DEPLOYMENT_TARGET
export DEPLOYMENT_TARGET_CLANG_FLAG_NAME=miphoneos-version-min
export DEPLOYMENT_TARGET_CLANG_FLAG_PREFIX=-miphoneos-version-min=
export DEPLOYMENT_TARGET_SETTING_NAME=IPHONEOS_DEPLOYMENT_TARGET
export DEPLOYMENT_TARGET_SUGGESTED_VALUES="6.0 6.1 7.0 7.1 8.0 8.1 8.2 8.3 8.4 9.0 9.1 9.2"
export DERIVED_FILES_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/DerivedSources
export DERIVED_FILE_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/DerivedSources
export DERIVED_SOURCES_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/DerivedSources
export DEVELOPER_APPLICATIONS_DIR=/Applications/Xcode.app/Contents/Developer/Applications
export DEVELOPER_BIN_DIR=/Applications/Xcode.app/Contents/Developer/usr/bin
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
export DEVELOPER_FRAMEWORKS_DIR=/Applications/Xcode.app/Contents/Developer/Library/Frameworks
export DEVELOPER_FRAMEWORKS_DIR_QUOTED=/Applications/Xcode.app/Contents/Developer/Library/Frameworks
export DEVELOPER_LIBRARY_DIR=/Applications/Xcode.app/Contents/Developer/Library
export DEVELOPER_SDK_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
export DEVELOPER_TOOLS_DIR=/Applications/Xcode.app/Contents/Developer/Tools
export DEVELOPER_USR_DIR=/Applications/Xcode.app/Contents/Developer/usr
export DEVELOPMENT_LANGUAGE=English
export DISPLAY_NAME=project
export DOCUMENTATION_FOLDER_PATH=Share.appex/English.lproj/Documentation
export DO_HEADER_SCANNING_IN_JAM=NO
export DSTROOT=/tmp/project.dst
export DT_TOOLCHAIN_DIR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
export DWARF_DSYM_FILE_NAME=Share.appex.dSYM
export DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT=NO
export DWARF_DSYM_FOLDER_PATH=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos
export EFFECTIVE_PLATFORM_NAME=-iphoneos
export EMBEDDED_CONTENT_CONTAINS_SWIFT=YES
export EMBEDDED_PROFILE_NAME=embedded.mobileprovision
export EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE=NO
export ENABLE_BITCODE=NO
export ENABLE_HEADER_DEPENDENCIES=YES
export ENABLE_ON_DEMAND_RESOURCES=NO
export ENABLE_STRICT_OBJC_MSGSEND=YES
export ENABLE_TESTABILITY=YES
export ENTITLEMENTS_REQUIRED=YES
export EXCLUDED_INSTALLSRC_SUBDIRECTORY_PATTERNS=".DS_Store .svn .git .hg CVS"
export EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES="*.nib *.lproj *.framework *.gch *.xcode* *.xcassets (*) .DS_Store CVS .svn .git .hg *.pbproj *.pbxproj"
export EXECUTABLES_FOLDER_PATH=Share.appex/Executables
export EXECUTABLE_FOLDER_PATH=Share.appex
export EXECUTABLE_NAME=Share
export EXECUTABLE_PATH=Share.appex/Share
export EXPANDED_CODE_SIGN_IDENTITY=0E55EAE299923C797E0ED97654EA32E3BEF5B22E
export EXPANDED_CODE_SIGN_IDENTITY_NAME="iPhone Developer: Tamar Nachmany (VLWMYFF3BX)"
export EXPANDED_PROVISIONING_PROFILE=e247065b-1342-4976-b6a3-ef2f33425114
export FILE_LIST=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/Objects/LinkFileList
export FIXED_FILES_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/FixedFiles
export FRAMEWORKS_FOLDER_PATH=Share.appex/Frameworks
export FRAMEWORK_FLAG_PREFIX=-framework
export FRAMEWORK_SEARCH_PATHS="/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos \"/Users/tamar/core/project/Pods/GIFEncoder/iOS/Framework\""
export FRAMEWORK_VERSION=A
export FULL_PRODUCT_NAME=Share.appex
export GCC3_VERSION=3.3
export GCC_C_LANGUAGE_STANDARD=gnu99
export GCC_DYNAMIC_NO_PIC=NO
export GCC_INLINES_ARE_PRIVATE_EXTERN=YES
export GCC_NO_COMMON_BLOCKS=YES
export GCC_OPTIMIZATION_LEVEL=0
export GCC_PFE_FILE_C_DIALECTS="c objective-c c++ objective-c++"
export GCC_PRECOMPILE_PREFIX_HEADER=YES
export GCC_PREFIX_HEADER=Resources/Prefix.pch
export GCC_PREPROCESSOR_DEFINITIONS=" DEBUG=1 COCOAPODS=1 COCOAPODS=1 SHARE_EXTENSION=1"
export GCC_SYMBOLS_PRIVATE_EXTERN=NO
export GCC_THUMB_SUPPORT=YES
export GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS=YES
export GCC_TREAT_WARNINGS_AS_ERRORS=NO
export GCC_VERSION=com.apple.compilers.llvm.clang.1_0
export GCC_VERSION_IDENTIFIER=com_apple_compilers_llvm_clang_1_0
export GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS=YES
export GCC_WARN_ABOUT_MISSING_NEWLINE=YES
export GCC_WARN_ABOUT_RETURN_TYPE=YES_ERROR
export GCC_WARN_SHADOW=YES
export GCC_WARN_UNDECLARED_SELECTOR=YES
export GCC_WARN_UNINITIALIZED_AUTOS=YES_AGGRESSIVE
export GCC_WARN_UNUSED_FUNCTION=YES
export GCC_WARN_UNUSED_LABEL=YES
export GCC_WARN_UNUSED_VARIABLE=YES
export GENERATE_MASTER_OBJECT_FILE=NO
export GENERATE_PKGINFO_FILE=NO
export GENERATE_PROFILING_CODE=NO
export GID=20
export GROUP=staff
export HEADERMAP_INCLUDES_FLAT_ENTRIES_FOR_TARGET_BEING_BUILT=YES
export HEADERMAP_INCLUDES_FRAMEWORK_ENTRIES_FOR_ALL_PRODUCT_TYPES=YES
export HEADERMAP_INCLUDES_NONPUBLIC_NONPRIVATE_HEADERS=YES
export HEADERMAP_INCLUDES_PROJECT_HEADERS=YES
export HEADERMAP_USES_FRAMEWORK_PREFIX_ENTRIES=YES
export HEADERMAP_USES_VFS=YES
export HEADER_SEARCH_PATHS="/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos/include /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/usr/include/libxml2 \"/Users/tamar/core/project/Pods/Headers/Public\" \"/Users/tamar/core/project/Pods/Headers/Public/AppsFlyer-SDK\" \"/Users/tamar/core/project/Pods/Headers/Public/Fabric\" \"/Users/tamar/core/project/Pods/Headers/Public/GIFEncoder\" \"/Users/tamar/core/project/Pods/Headers/Public/GoogleAppIndexing\" \"/Users/tamar/core/project/Pods/Headers/Public/HockeySDK\" \"/Users/tamar/core/project/Pods/Headers/Public/Kahuna\" \"/Users/tamar/core/project/Pods/Headers/Public/Reveal-iOS-SDK\" \"/Users/tamar/core/project/Pods/Headers/Public/TwitterCore\" \"/Users/tamar/core/project/Pods/Headers/Public/TwitterKit\""
export HIDE_BITCODE_SYMBOLS=YES
export HOME=/Users/tamar
export ICONV=/usr/bin/iconv
export INFOPLIST_EXPAND_BUILD_SETTINGS=YES
export INFOPLIST_FILE=Resources/Share-Info.plist
export INFOPLIST_OUTPUT_FORMAT=binary
export INFOPLIST_PATH=Share.appex/Info.plist
export INFOPLIST_PREPROCESS=NO
export INFOSTRINGS_PATH=Share.appex/English.lproj/InfoPlist.strings
export INSTALL_DIR=/tmp/project.dst
export INSTALL_GROUP=staff
export INSTALL_MODE_FLAG=u+w,go-w,a+rX
export INSTALL_OWNER=tamar
export INSTALL_ROOT=/tmp/project.dst
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export JAVAC_DEFAULT_FLAGS="-J-Xms64m -J-XX:NewSize=4M -J-Dfile.encoding=UTF8"
export JAVA_APP_STUB=/System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub
export JAVA_ARCHIVE_CLASSES=YES
export JAVA_ARCHIVE_TYPE=JAR
export JAVA_COMPILER=/usr/bin/javac
export JAVA_FOLDER_PATH=Share.appex/Java
export JAVA_FRAMEWORK_RESOURCES_DIRS=Resources
export JAVA_JAR_FLAGS=cv
export JAVA_SOURCE_SUBDIR=.
export JAVA_USE_DEPENDENCIES=YES
export JAVA_ZIP_FLAGS=-urg
export JIKES_DEFAULT_FLAGS="+E +OLDCSO"
export KEEP_PRIVATE_EXTERNS=NO
export LD_DEPENDENCY_INFO_FILE=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/Objects-normal/arm64/Share_dependency_info.dat
export LD_GENERATE_MAP_FILE=NO
export LD_MAP_FILE_PATH=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/Share-LinkMap-normal-arm64.txt
export LD_NO_PIE=NO
export LD_QUOTE_LINKER_ARGUMENTS_FOR_COMPILER_DRIVER=YES
export LD_RUNPATH_SEARCH_PATHS=" '@executable_path/Frameworks' '@loader_path/Frameworks' @executable_path/Frameworks @executable_path/../../Frameworks"
export LEGACY_DEVELOPER_DIR=/Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer
export LEX=lex
export LIBRARY_FLAG_NOSPACE=YES
export LIBRARY_FLAG_PREFIX=-l
export LIBRARY_KEXT_INSTALL_PATH=/Library/Extensions
export LIBRARY_SEARCH_PATHS="/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos "
export LINKER_DISPLAYS_MANGLED_NAMES=NO
export LINK_FILE_LIST_normal_arm64=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/Objects-normal/arm64/Share.LinkFileList
export LINK_WITH_STANDARD_LIBRARIES=YES
export LOCALIZABLE_CONTENT_DIR=
export LOCALIZED_RESOURCES_FOLDER_PATH=Share.appex/English.lproj
export LOCAL_ADMIN_APPS_DIR=/Applications/Utilities
export LOCAL_APPS_DIR=/Applications
export LOCAL_DEVELOPER_DIR=/Library/Developer
export LOCAL_LIBRARY_DIR=/Library
export LOCROOT=
export LOCSYMROOT=
export MACH_O_TYPE=mh_execute
export MAC_OS_X_PRODUCT_BUILD_VERSION=15C50
export MAC_OS_X_VERSION_ACTUAL=101102
export MAC_OS_X_VERSION_MAJOR=101100
export MAC_OS_X_VERSION_MINOR=1102
export MODULE_CACHE_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/ModuleCache
export MTL_ENABLE_DEBUG_INFO=YES
export NATIVE_ARCH=armv7
export NATIVE_ARCH_32_BIT=i386
export NATIVE_ARCH_64_BIT=x86_64
export NATIVE_ARCH_ACTUAL=x86_64
export NO_COMMON=YES
export OBJECT_FILE_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/Objects
export OBJECT_FILE_DIR_normal=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/Objects-normal
export OBJROOT=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates
export ONLY_ACTIVE_ARCH=YES
export OPTIMIZATION_LEVEL=0
export OS=MACOS
export OSAC=/usr/bin/osacompile
export OTHER_CFLAGS=" (stuff i can't share on here)
export OTHER_SWIFT_FLAGS=" \"-D\" \"COCOAPODS\""
export PACKAGE_TYPE=com.apple.package-type.app-extension
export PASCAL_STRINGS=YES
export PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export PATH_PREFIXES_EXCLUDED_FROM_HEADER_DEPENDENCIES="/usr/include /usr/local/include /System/Library/Frameworks /System/Library/PrivateFrameworks /Applications/Xcode.app/Contents/Developer/Headers /Applications/Xcode.app/Contents/Developer/SDKs /Applications/Xcode.app/Contents/Developer/Platforms"
export PBDEVELOPMENTPLIST_PATH=Share.appex/pbdevelopment.plist
export PFE_FILE_C_DIALECTS=objective-c
export PKGINFO_FILE_PATH=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/PkgInfo
export PKGINFO_PATH=Share.appex/PkgInfo
export PLATFORM_DEVELOPER_APPLICATIONS_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Applications
export PLATFORM_DEVELOPER_BIN_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
export PLATFORM_DEVELOPER_LIBRARY_DIR=/Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library
export PLATFORM_DEVELOPER_SDK_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
export PLATFORM_DEVELOPER_TOOLS_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Tools
export PLATFORM_DEVELOPER_USR_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr
export PLATFORM_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
export PLATFORM_DISPLAY_NAME=iOS
export PLATFORM_NAME=iphoneos
export PLATFORM_PREFERRED_ARCH=arm64
export PLATFORM_PRODUCT_BUILD_VERSION=13C75
export PLIST_FILE_OUTPUT_FORMAT=binary
export PLUGINS_FOLDER_PATH=Share.appex/PlugIns
export PODS_FRAMEWORK_BUILD_PATH=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos/Pods-share_extension
export PODS_ROOT=/Users/tamar/core/project/Pods
export PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR=YES
export PRECOMP_DESTINATION_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/PrefixHeaders
export PRESERVE_DEAD_CODE_INITS_AND_TERMS=NO
export PRIVATE_HEADERS_FOLDER_PATH=Share.appex/PrivateHeaders
export PRODUCT_BUNDLE_IDENTIFIER="bundle id"
export PRODUCT_MODULE_NAME=Share
export PRODUCT_NAME=Share
export PRODUCT_SETTINGS_PATH=/Users/tamar/core/project/Resources/Share-Info.plist
export PRODUCT_SPECIFIC_LDFLAGS="-e _NSExtensionMain"
export PRODUCT_TYPE=com.apple.product-type.app-extension
export PROFILING_CODE=NO
export PROJECT=project
export PROJECT_DERIVED_FILE_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/DerivedSources
export PROJECT_DIR=/Users/tamar/core/project
export PROJECT_FILE_PATH=/Users/tamar/core/project/project.xcodeproj
export PROJECT_NAME=project
export PROJECT_TEMP_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build
export PROJECT_TEMP_ROOT=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates
export PUBLIC_HEADERS_FOLDER_PATH=Share.appex/Headers
export RECURSIVE_SEARCH_PATHS_FOLLOW_SYMLINKS=YES
export REMOVE_CVS_FROM_RESOURCES=YES
export REMOVE_GIT_FROM_RESOURCES=YES
export REMOVE_HEADERS_FROM_EMBEDDED_BUNDLES=YES
export REMOVE_HG_FROM_RESOURCES=YES
export REMOVE_SVN_FROM_RESOURCES=YES
export REZ_COLLECTOR_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/ResourceManagerResources
export REZ_OBJECTS_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/ResourceManagerResources/Objects
export REZ_SEARCH_PATHS="/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos "
export SCAN_ALL_SOURCE_FILES_FOR_INCLUDES=NO
export SCRIPTS_FOLDER_PATH=Share.appex/Scripts
export SCRIPT_INPUT_FILE_COUNT=0
export SCRIPT_OUTPUT_FILE_COUNT=0
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk
export SDK_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk
export SDK_DIR_iphoneos9_2=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk
export SDK_NAME=iphoneos9.2
export SDK_NAMES=iphoneos9.2
export SDK_PRODUCT_BUILD_VERSION=13C75
export SDK_VERSION=9.2
export SDK_VERSION_ACTUAL=90200
export SDK_VERSION_MAJOR=90000
export SDK_VERSION_MINOR=200
export SED=/usr/bin/sed
export SEPARATE_STRIP=NO
export SEPARATE_SYMBOL_EDIT=NO
export SET_DIR_MODE_OWNER_GROUP=YES
export SET_FILE_MODE_OWNER_GROUP=NO
export SHALLOW_BUNDLE=YES
export SHARED_DERIVED_FILE_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos/DerivedSources
export SHARED_FRAMEWORKS_FOLDER_PATH=Share.appex/SharedFrameworks
export SHARED_PRECOMPS_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/PrecompiledHeaders
export SHARED_SUPPORT_FOLDER_PATH=Share.appex/SharedSupport
export SKIP_INSTALL=YES
export SOURCE_ROOT=/Users/tamar/core/project
export SRCROOT=/Users/tamar/core/project
export STRINGS_FILE_OUTPUT_ENCODING=binary
export STRIP_BITCODE_FROM_COPIED_FILES=YES
export STRIP_INSTALLED_PRODUCT=YES
export STRIP_STYLE=non-global
export SUPPORTED_DEVICE_FAMILIES=1,2
export SUPPORTED_PLATFORMS="iphonesimulator iphoneos"
export SUPPORTS_TEXT_BASED_API=NO
export SWIFT_OPTIMIZATION_LEVEL=-Onone
export SWIFT_PLATFORM_TARGET_PREFIX=ios
export SYMROOT=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products
export SYSTEM_ADMIN_APPS_DIR=/Applications/Utilities
export SYSTEM_APPS_DIR=/Applications
export SYSTEM_CORE_SERVICES_DIR=/System/Library/CoreServices
export SYSTEM_DEMOS_DIR=/Applications/Extras
export SYSTEM_DEVELOPER_APPS_DIR=/Applications/Xcode.app/Contents/Developer/Applications
export SYSTEM_DEVELOPER_BIN_DIR=/Applications/Xcode.app/Contents/Developer/usr/bin
export SYSTEM_DEVELOPER_DEMOS_DIR="/Applications/Xcode.app/Contents/Developer/Applications/Utilities/Built Examples"
export SYSTEM_DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
export SYSTEM_DEVELOPER_DOC_DIR="/Applications/Xcode.app/Contents/Developer/ADC Reference Library"
export SYSTEM_DEVELOPER_GRAPHICS_TOOLS_DIR="/Applications/Xcode.app/Contents/Developer/Applications/Graphics Tools"
export SYSTEM_DEVELOPER_JAVA_TOOLS_DIR="/Applications/Xcode.app/Contents/Developer/Applications/Java Tools"
export SYSTEM_DEVELOPER_PERFORMANCE_TOOLS_DIR="/Applications/Xcode.app/Contents/Developer/Applications/Performance Tools"
export SYSTEM_DEVELOPER_RELEASENOTES_DIR="/Applications/Xcode.app/Contents/Developer/ADC Reference Library/releasenotes"
export SYSTEM_DEVELOPER_TOOLS=/Applications/Xcode.app/Contents/Developer/Tools
export SYSTEM_DEVELOPER_TOOLS_DOC_DIR="/Applications/Xcode.app/Contents/Developer/ADC Reference Library/documentation/DeveloperTools"
export SYSTEM_DEVELOPER_TOOLS_RELEASENOTES_DIR="/Applications/Xcode.app/Contents/Developer/ADC Reference Library/releasenotes/DeveloperTools"
export SYSTEM_DEVELOPER_USR_DIR=/Applications/Xcode.app/Contents/Developer/usr
export SYSTEM_DEVELOPER_UTILITIES_DIR=/Applications/Xcode.app/Contents/Developer/Applications/Utilities
export SYSTEM_DOCUMENTATION_DIR=/Library/Documentation
export SYSTEM_KEXT_INSTALL_PATH=/System/Library/Extensions
export SYSTEM_LIBRARY_DIR=/System/Library
export TARGETED_DEVICE_FAMILY=1,2
export TARGETNAME=Share
export TARGET_BUILD_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Products/Debug-iphoneos
export TARGET_DEVICE_MODEL=iPhone8,1
export TARGET_DEVICE_OS_VERSION=9.2
export TARGET_NAME=Share
export TARGET_TEMP_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build
export TEMP_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build
export TEMP_FILES_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build
export TEMP_FILE_DIR=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build
export TEMP_ROOT=/Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates
export TOOLCHAINS=com.apple.dt.toolchain.XcodeDefault
export TOOLCHAIN_DIR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
export TREAT_MISSING_BASELINES_AS_TEST_FAILURES=NO
export UID=501
export UNLOCALIZED_RESOURCES_FOLDER_PATH=Share.appex
export UNSTRIPPED_PRODUCT=NO
export USER=tamar
export USER_APPS_DIR=/Users/tamar/Applications
export USER_LIBRARY_DIR=/Users/tamar/Library
export USE_DYNAMIC_NO_PIC=YES
export USE_HEADERMAP=YES
export USE_HEADER_SYMLINKS=NO
export VALIDATE_PRODUCT=NO
export VALID_ARCHS="arm64 armv7 armv7s"
export VERBOSE_PBXCP=NO
export VERSIONING_SYSTEM=apple-generic
export VERSIONPLIST_PATH=Share.appex/version.plist
export VERSION_INFO_BUILDER=tamar
export VERSION_INFO_FILE=Share_vers.c
export VERSION_INFO_STRING="\"@(#)PROGRAM:Share PROJECT:project-436\""
export WRAPPER_EXTENSION=appex
export WRAPPER_NAME=Share.appex
export WRAPPER_SUFFIX=.appex
export WRAP_ASSET_PACKS_IN_SEPARATE_DIRECTORIES=NO
export XCODE_APP_SUPPORT_DIR=/Applications/Xcode.app/Contents/Developer/Library/Xcode
export XCODE_PRODUCT_BUILD_VERSION=7C68
export XCODE_VERSION_ACTUAL=0720
export XCODE_VERSION_MAJOR=0700
export XCODE_VERSION_MINOR=0720
export XPCSERVICES_FOLDER_PATH=Share.appex/XPCServices
export YACC=yacc
export arch=arm64
export variant=normal
/bin/sh -c /Users/tamar/Library/Developer/Xcode/DerivedData/project-dhwfefmrpsepdncezpfhexxoddmo/Build/Intermediates/project.build/Debug-iphoneos/Share.build/Script-32B957CD1C24634700560E0C.sh
Loading configuration from '/Users/tamar/core/project/.swiftlint.yml'
Linting Swift files at path /Users/tamar/core/project/Classes/ClassName.swift
Linting 'ClassName.swift' (1/1)
Done linting! Found 1 violation, 1 serious in 1 file.
/Users/tamar/core/project/Classes/ClassName.swift:86:55: error: Force Cast Violation: Force casts should be avoided. (force_cast)
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
This is being printed because the return status of swiftlint is being ignored by your run script build phase.
For example, if you had
swiftlint
exit 0 # <- ignores the exit status from the swiftlint call above
Can you please paste the output of your build phase? Using the script from the README shouldn't cause this problem.
I don't see the SIGABRT
failure in the command output you posted above. How is that issue triggered? Is a backtrace printed when it occurs?
The build phase doesn't have any output (unless I'm misunderstanding what you mean by output?).
The only exit code I've added gets called if the developer does not have SwiftLint installed locally.
The script boils down to a diff check and if each file has a diff swiftlint lint --strict --config "${SRCROOT}/.swiftlint.yml" --path "$file"
gets called.
The script boils down to a diff check and if each file has a diff swiftlint lint --strict --config "${SRCROOT}/.swiftlint.yml" --path "$file" gets called.
It sure sounds like you're not saving the exit code from each swiftlint invocation to then return with a non-zero code if an error was found.
If you share the _entirety_ of your build phase, without paraphrasing, I can help you refactor it to make the script exit with a non-zero code if any swiftlint invocation did.
The build phase doesn't have any output (unless I'm misunderstanding what you mean by output?)
All build script phases generate _some_ output, usually this is available in Xcode:
It sure sounds like you're not saving the exit code from each swiftlint invocation to then return with a non-zero code if an error was found.
You're right! I'm not. I thought that is a built-in functionality that doesn't need to be handled by a script. Does a script that runs linting have to handle that exit code?
As far as output:
The output I see just reflects the errors I mentioned. This is a screenshot, minus specific class names and stuff -- I don't work on an open source app :-p
I am using the following build script (I'm in the process of modifying it so it does not have the correct version hard coded):
REQUIRED_SWIFTLINT_VERSION="0.5.2"
REQUIRED_SWIFTLINT_DOWNLOAD_URL="https://github.com/realm/SwiftLint/releases/tag/${REQUIRED_SWIFTLINT_VERSION}"
which swiftlint &> /dev/null
NEEDS_SWIFTLINT="$?"
SWIFTLINT_MATCHES="0"
if [ "$NEEDS_SWIFTLINT" == "0" ]; then
CURRENT_SWIFTLINT_VERSION=`swiftlint version`
if [ "$CURRENT_SWIFTLINT_VERSION" == "$REQUIRED_SWIFTLINT_VERSION" ]; then
SWIFTLINT_MATCHES="1"
fi
fi
if [ "$SWIFTLINT_MATCHES" == "0" ]; then
echo -e "error: SwiftLint $REQUIRED_SWIFTLINT_VERSION needs to be installed. Download it here: $REQUIRED_SWIFTLINT_DOWNLOAD_URL\n" 1>&2;
open -g $REQUIRED_SWIFTLINT_DOWNLOAD_URL;
exit 1;
fi
lint () {
find "$1" -name "*.swift" -print0 | while read -d $'\0' file
do
git diff-index --quiet HEAD -- "$file"
if [ $? -ne 0 ]; then
swiftlint lint --strict --config "${SRCROOT}/.swiftlint.yml" --path "$file"
fi
done
}
Does a script that runs linting have to handle that exit code?
Yes, although this is not specific to linting. This is how sh and bash work.
I'm away from my computer now, but it should be trivial to adapt your script to return a code based on the linting results.
TIL!
I think I can take it from here.
@tamarnachmany what's your take-away from this long thread?
Hi.
What do you mean by take-away?
I mean what would you like to see changed in how SwiftLint deals with the --strict
flag based on our discussion here, if anything?
To me it feels like the biggest question to tackle here is whether to support the configuration of violation severities at global scope, rule scope, or both.
At rule scope, we can create a new protocol, say WarningOrErrorRule
, to provide standard conformance to ConfigurableRule
, and allow people to add a flag to their .swiftlint.yml
files to indicate violation severity.
At a global scope, @jpsim 's idea of a WarningsAsErrorsXcodeReporter
, seems most reasonable.
But should we do both?? I'm not sure about that just because the potential ambiguities for end users creating or reading configurations.
To me, doing rule-scope only seems the most practical. It will provide the desired behavior (though potentially more onerous configuration), it fits with what we are already doing with ViolationLevelRule
, and it fits a wider spectrum of uses cases. For instance, I might want to make most things an error, but still allow developers to use TODO
s and FIXME
s in their feature branches before they get merged back in.
I also appreciate the current implementation of --strict
because there is a clear delineation between that and .swiftlint.yml
right now.
I enthusiastically agree with everything you suggested, Scott.
To me, doing rule-scope only seems the most practical. It will provide the desired behavior (though potentially more onerous configuration), it fits with what we are already doing with ViolationLevelRule, and it fits a wider spectrum of uses cases.
&
At rule scope, we can create a new protocol, say WarningOrErrorRule, to provide standard conformance to ConfigurableRule, and allow people to add a flag to their .swiftlint.yml files to indicate violation severity.
I think that's the way to go. And I think a protocol, and perhaps a new section in the .yml file with 'error-level-violations' and 'warning-level-violations' might be a nice structure there. That's without me actually trying to implement this yet. But from my exploration of the library, that seems good.
As far as the --strict flag goes...hm...
In the interim (before changes are potentially made to the way rule violations can be configured and are displayed) I do think more documentation on how to exit a build when style rules are violated would be great, and is probably relevant to many teams using SwiftLint.
Looking at SwiftLint initially it seemed like maybe SwiftLint hooked back into some part of the Swift compilation process/ sent errors to SourceKit somewhere to report violations, rather than just printing them. Maybe a sentence in the readme, or a small sample script in the same way there is a sample .yml in this repo. I'm happy to contribute mine.
@tamarnachmany , with the changes introduced in #391, you should now be able to configure the severity of any rule. Does this get you close enough to satisfy your use case?
:pray: :pray: :pray:
I believe so!
I will follow up with you/on the repo if I see any issues.
I think it's fair time to close this. Let's reopen a new issue if anyone ever wants to revisit this. Thanks for spurring such a thorough conversation, @tamarnachmany!
It is possible to treat all swiftlint warnings as errors by modifying the swiftlint output like this:
#!/bin/bash
# Make the script return a failure code if any of the commands executed in the middle fail (even if they are piped)
# For more info, see: https://stackoverflow.com/questions/821396/aborting-a-shell-script-if-any-command-returns-a-non-zero-value
set -e
set -o pipefail
swiftlint lint --strict | sed 's/warning:/error:/g'
Or in case you are using swiftlint from cocoapods:
${PODS_ROOT}/SwiftLint/swiftlint lint --strict | sed 's/warning:/error:/g'
Don't these suggested commands swallow the exit code from swiftlint
? At least, in my experience, this causes swiftlint
to fail silently.
I'm no bash expert, but here's the script I ended up using:
OUTPUT=$("${PODS_ROOT}"/SwiftLint/swiftlint --strict)
CODE=$?
echo $OUTPUT | sed 's/warning:/error:/g'
exit $CODE
@bjtitus did you use set -e
and set -o pipefail
? Using them will make the script fail even if it is piped.
@acecilia 🤦♂️ Thanks! Turns out I can't read.
Most helpful comment
It is possible to treat all swiftlint warnings as errors by modifying the swiftlint output like this:
Or in case you are using swiftlint from cocoapods:
${PODS_ROOT}/SwiftLint/swiftlint lint --strict | sed 's/warning:/error:/g'