realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.66k stars 2.22k forks source link

Xcode 10.2: swiftlint aborts in macOS 10.14.4 (libswiftCore.dylib) #2695

Closed Panajev closed 5 years ago

Panajev commented 5 years ago

New Issue Checklist

Describe the bug

Swiftlint crashes after being launched on macos 10.14.4.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
[1]    88598 abort      swiftlint lint
$ swiftlint version
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
[1]    90167 abort      swiftlint version

Environment

disabled_rules: # rule identifiers to exclude from running
  - colon
  - control_statement
  - identifier_name
  - unused_optional_binding
  - notification_center_detachment
  - opening_brace
opt_in_rules: # some rules are only opt-in
  - empty_count
  - closure_spacing
  - fatal_error_message
  # Find all the available rules by running:
  # swiftlint rules
included: # paths to include during linting. `--path` is ignored if present.
  - NativeRoutingModule/NativeRoutingModule
excluded: # paths to ignore during linting. Takes precedence over `included`.
  - Carthage
  - Pods
  - XML
  - NativeRoutingModule/Pods
  - NativeRoutingModule/NativeRoutingModuleTests

# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning # implicitly
force_try:
  severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 195
# they can set both implicitly with an array
type_body_length:
  - 350 # warning
  - 450 # error
function_body_length:
  - 80 # warning
  - 140 # error 
# or they can set both explicitly
file_length:
  warning: 1250
  error: 2000
cyclomatic_complexity:
  - 16
# naming rules can set warnings/errors for min_length and max_length
# additionally they can set excluded names
type_name:
  min_length: 3 # only warning
  max_length: # warning and error
    warning: 50
    error: 60
  excluded: iPhone # excluded via string
identifier_name:
  min_length: # only min_length
    error: 4 # only error
  excluded: # excluded via string array
    - id
    - URL
    - url
    - GlobalAPIKey
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji)
mdima commented 5 years ago

Here is the same. The issue started right after the update to 10.14.4.

Panajev commented 5 years ago

Wonder if it related to this thread too: https://forums.swift.org/t/command-line-applications-crashes-with-xcode-10-2/22192/24

Panajev commented 5 years ago

It would seem that SwiftLint is statically linking the Swift Standard Library which is not supported any longer in macOS 10.14.4 (looking at the Makefile):

[...]
SWIFT_BUILD_FLAGS=--configuration release
UNAME=(shell uname) ifeq ((UNAME), Darwin)
SWIFT_BUILD_FLAGS+= -Xswiftc -static-stdlib
endif
[...]

https://forums.swift.org/t/command-line-applications-crashes-with-xcode-10-2/22192/28?u=panajev

As you can read there, I asked if it could happen with the Swift 4 standard library being statically linked in swiftlint (seeing the Swift5 branch I thought we had yet to build the swiftlink package, I got it from homebrew @mdima ), but I got this reply:

No, it can't happen with Swift 4.2. :-/ That error message specifically comes from the Swift 5 standard library detecting an unsafe environment. (Note that this is about the compiler and stdlib version, not about the language version provided to -swift-version.)

Panajev commented 5 years ago

Also, the project does not compile with Xcode 10.2, I am trying to remove the "-Xswiftc -static-stdlib" flag... Edit: it does compile this way... and it runs :D.

norio-nomura commented 5 years ago

Could you please post result of otool -L $(which swiftlint)? My results with homebrew installation are following:

$ brew uninstall swiftlint
Uninstalling /usr/local/Cellar/swiftlint/0.31.0... (6 files, 16.6MB)
$ brew install swiftlint
==> Downloading https://homebrew.bintray.com/bottles/swiftlint-0.31.0.mojave.bottle.tar.gz
Already downloaded: /Users/norio/Library/Caches/Homebrew/downloads/27d0f98ed0ea3c1592aecbaa7fd410c14b6245b636ca397250e7800ba77d6982--swiftlint-0.31.0.mojave.bottle.tar.gz
==> Pouring swiftlint-0.31.0.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/swiftlint/0.31.0: 6 files, 16.6MB
brew install swiftlint  3.70s user 1.98s system 83% cpu 6.809 total
$ otool -L $(which swiftlint)
/usr/local/bin/swiftlint:
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1560.12.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1560.12.0)
    /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1247.4.1)
    /usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 62.1.0)
$ swiftlint version
0.31.0
$ sw_vers -productVersion
10.14.4
norio-nomura commented 5 years ago

FYI, workaround for using -Xswiftc -static-stdlib are already opened: https://github.com/realm/SwiftLint/pull/2682

Panajev commented 5 years ago

hello @norio-nomura uninstalling and re-installing swiftlint fixed the issue. This is the result of otool post install:

$ swiftlint version
0.31.0
$ otool -L $(which swiftlint)
/usr/local/bin/swiftlint:
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1560.12.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1560.12.0)
    /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1247.4.1)
    /usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 62.1.0)