SwiftFormat: Command line tool fails to compile/run: dyld not found in "formatCode" build phase, image not found

I have checked out the latest tag 0.40.5. I tried to compile the target SwiftFormat (Command line tools) but it fails. It looks like there is an issue in the formatCode phase of the build. The command “${SRCROOT}/format.sh” fails with: dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /Users/i040023/com.sap.mobile.platform.client.oss.ios.swiftformat/src/CommandLineTool/swiftformat Reason: image not found /Users/i040023/com.sap.mobile.platform.client.oss.ios.swiftformat/src/format.sh: line 3: 4077 Abort trap: 6 CommandLineTool/swiftformat . --cache ignore Command PhaseScriptExecution failed with a nonzero exit code

Xcode is 10.2 os: 10.14.3

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

Per the Swift 5 Release Notes for Xcode 10.2:

Swift command line projects won’t run on macOS 10.14.3 and earlier unless you install the Swift 5 Runtime Support for Command Line Tools package. Without that package, Swift command line projects crash on launch with “dyld: Library not loaded” errors. (46824656)

Sounds like that’s what happened here.

At the very least, if the system requirements of the distributed binaries have changed (e.g. requires 10.14.4 or the Swift 5 Runtime Support for Command Line Tools package), then that should be called out explicitly somewhere where people will see it.

That said, not everyone can just upgrade their OS version whenever a new point release comes out, and as @MaxDesiatov has shown it can take a while for tooling to catch up.

I’ve added a prominent note to the README explaining the workaround. Let me know if there’s anything else I can do.

This is a simple bare-bones .travis.yml that reproduces this:

osx_image: xcode10.2
language: swift
script:
  - brew update
  - brew install swiftformat
  - swiftformat --version

The test repository is available here and the failing build is this one, but all newer builds are failing too.