Command line applications crashes with Xcode 10.2

If the command line tools are in your resources folder, you can point "Runpath Search Paths" to @executable_path/../Frameworks/.

I tried this but it didn't work for me. My command line tool resides in the MacOS directory rather than Resources - could this be the reason it's failing for me?

1 Like

I haven’t looked into the Swift runtime side of this in detail, but I do want to address this specific point:

My command line tool resides in the MacOS directory …

You’re doing the right thing here. The Contents/MacOS/ directory is the recommended place for embedded command-line tools, as witnessed by the fact that this is where url(forAuxiliaryExecutable:) looks. Placing such tools in Contents/Resources/ will eventually cause you code signing grief, as explained in the Nested Code section of Technote 2206 macOS Code Signing In Depth.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

That is the better location for your executables. Since the Frameworks directory is one level lower than both MacOS and Resources, the same path should work for either. The issue you're having is likely due to the missing Swift framework, which may be added to your main bundle.

@jrose would the following issue be related to what we are discussing here?

$ swiftlint lint
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
[1] 88598 abort swiftlint lint

Very possibly! You can use env DYLD_PRINT_LIBRARIES=1 swiftlint lint to see which version of libswiftCore.dylib is being loaded.

Thanks @jrose, executed the command, but I am not sure it is of help here (I may not be reading it right / looking for the right thing though). Here is the output:

env DYLD_PRINT_LIBRARIES=1 swiftlint version
dyld: loaded: /usr/local/bin/swiftlint
dyld: loaded: /usr/lib/libobjc.A.dylib
dyld: loaded: /usr/lib/libSystem.B.dylib
dyld: loaded: /usr/lib/libc++.1.dylib
dyld: loaded: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
dyld: loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld: loaded: /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
dyld: loaded: /usr/lib/libicucore.A.dylib
dyld: loaded: /usr/lib/libc++abi.dylib
dyld: loaded: /usr/lib/system/libcache.dylib
dyld: loaded: /usr/lib/system/libcommonCrypto.dylib
dyld: loaded: /usr/lib/system/libcompiler_rt.dylib
dyld: loaded: /usr/lib/system/libcopyfile.dylib
dyld: loaded: /usr/lib/system/libcorecrypto.dylib
dyld: loaded: /usr/lib/system/libdispatch.dylib
dyld: loaded: /usr/lib/system/libdyld.dylib
dyld: loaded: /usr/lib/system/libkeymgr.dylib
dyld: loaded: /usr/lib/system/liblaunch.dylib
dyld: loaded: /usr/lib/system/libmacho.dylib
dyld: loaded: /usr/lib/system/libquarantine.dylib
dyld: loaded: /usr/lib/system/libremovefile.dylib
dyld: loaded: /usr/lib/system/libsystem_asl.dylib
dyld: loaded: /usr/lib/system/libsystem_blocks.dylib
dyld: loaded: /usr/lib/system/libsystem_c.dylib
dyld: loaded: /usr/lib/system/libsystem_configuration.dylib
dyld: loaded: /usr/lib/system/libsystem_coreservices.dylib
dyld: loaded: /usr/lib/system/libsystem_darwin.dylib
dyld: loaded: /usr/lib/system/libsystem_dnssd.dylib
dyld: loaded: /usr/lib/system/libsystem_info.dylib
dyld: loaded: /usr/lib/system/libsystem_m.dylib
dyld: loaded: /usr/lib/system/libsystem_malloc.dylib
dyld: loaded: /usr/lib/system/libsystem_networkextension.dylib
dyld: loaded: /usr/lib/system/libsystem_notify.dylib
dyld: loaded: /usr/lib/system/libsystem_sandbox.dylib
dyld: loaded: /usr/lib/system/libsystem_secinit.dylib
dyld: loaded: /usr/lib/system/libsystem_kernel.dylib
dyld: loaded: /usr/lib/system/libsystem_platform.dylib
dyld: loaded: /usr/lib/system/libsystem_pthread.dylib
dyld: loaded: /usr/lib/system/libsystem_symptoms.dylib
dyld: loaded: /usr/lib/system/libsystem_trace.dylib
dyld: loaded: /usr/lib/system/libunwind.dylib
dyld: loaded: /usr/lib/system/libxpc.dylib
dyld: loaded: /usr/lib/libauto.dylib
dyld: loaded: /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
dyld: loaded: /usr/lib/libarchive.2.dylib
dyld: loaded: /usr/lib/libDiagnosticMessagesClient.dylib
dyld: loaded: /usr/lib/libxml2.2.dylib
dyld: loaded: /usr/lib/libz.1.dylib
dyld: loaded: /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
dyld: loaded: /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
dyld: loaded: /usr/lib/liblangid.dylib
dyld: loaded: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
dyld: loaded: /usr/lib/libCRFSuite.dylib
dyld: loaded: /System/Library/Frameworks/Security.framework/Versions/A/Security
dyld: loaded: /usr/lib/libenergytrace.dylib
dyld: loaded: /usr/lib/libbsm.0.dylib
dyld: loaded: /usr/lib/system/libkxld.dylib
dyld: loaded: /System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression
dyld: loaded: /usr/lib/libOpenScriptingUtil.dylib
dyld: loaded: /usr/lib/libcoretls.dylib
dyld: loaded: /usr/lib/libcoretls_cfhelpers.dylib
dyld: loaded: /usr/lib/libpam.2.dylib
dyld: loaded: /usr/lib/libsqlite3.dylib
dyld: loaded: /usr/lib/libxar.1.dylib
dyld: loaded: /usr/lib/libbz2.1.0.dylib
dyld: loaded: /usr/lib/liblzma.5.dylib
dyld: loaded: /usr/lib/libnetwork.dylib
dyld: loaded: /usr/lib/libapple_nghttp2.dylib
dyld: loaded: /usr/lib/libpcap.A.dylib
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/FSEvents
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList
dyld: loaded: /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
dyld: loaded: /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
dyld: loaded: /System/Library/PrivateFrameworks/login.framework/Versions/A/Frameworks/loginsupport.framework/Versions/A/loginsupport
dyld: loaded: /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
dyld: loaded: /System/Library/PrivateFrameworks/CoreNLP.framework/Versions/A/CoreNLP
dyld: loaded: /System/Library/PrivateFrameworks/MetadataUtilities.framework/Versions/A/MetadataUtilities
dyld: loaded: /usr/lib/libmecabra.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
dyld: loaded: /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
dyld: loaded: /System/Library/Frameworks/ColorSync.framework/Versions/A/ColorSync
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSyncLegacy.framework/Versions/A/ColorSyncLegacy
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
dyld: loaded: /System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/SkyLight
dyld: loaded: /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
dyld: loaded: /usr/lib/libcompression.dylib
dyld: loaded: /System/Library/Frameworks/CoreDisplay.framework/Versions/A/CoreDisplay
dyld: loaded: /System/Library/Frameworks/Metal.framework/Versions/A/Metal
dyld: loaded: /System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/MetalPerformanceShaders
dyld: loaded: /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
dyld: loaded: /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLinearAlgebra.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparseBLAS.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libQuadrature.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBNNS.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparse.dylib
dyld: loaded: /System/Library/PrivateFrameworks/GPUWrangler.framework/Versions/A/GPUWrangler
dyld: loaded: /System/Library/PrivateFrameworks/IOAccelerator.framework/Versions/A/IOAccelerator
dyld: loaded: /System/Library/PrivateFrameworks/IOPresentment.framework/Versions/A/IOPresentment
dyld: loaded: /System/Library/PrivateFrameworks/DSExternalDisplay.framework/Versions/A/DSExternalDisplay
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreFSCache.dylib
dyld: loaded: /System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Versions/A/MPSCore
dyld: loaded: /System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSImage.framework/Versions/A/MPSImage
dyld: loaded: /System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSNeuralNetwork.framework/Versions/A/MPSNeuralNetwork
dyld: loaded: /System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSMatrix.framework/Versions/A/MPSMatrix
dyld: loaded: /System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSRayIntersector.framework/Versions/A/MPSRayIntersector
dyld: loaded: /System/Library/PrivateFrameworks/MetalTools.framework/Versions/A/MetalTools
dyld: loaded: /System/Library/PrivateFrameworks/AggregateDictionary.framework/Versions/A/AggregateDictionary
dyld: loaded: /usr/lib/libMobileGestalt.dylib
dyld: loaded: /System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage
dyld: loaded: /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
dyld: loaded: /System/Library/PrivateFrameworks/GraphVisualizer.framework/Versions/A/GraphVisualizer
dyld: loaded: /System/Library/PrivateFrameworks/FaceCore.framework/Versions/A/FaceCore
dyld: loaded: /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
dyld: loaded: /usr/lib/libFosl_dynamic.dylib
dyld: loaded: /System/Library/PrivateFrameworks/OTSVG.framework/Versions/A/OTSVG
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
dyld: loaded: /System/Library/PrivateFrameworks/AppleJPEG.framework/Versions/A/AppleJPEG
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
dyld: loaded: /usr/lib/libcups.2.dylib
dyld: loaded: /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
dyld: loaded: /System/Library/Frameworks/GSS.framework/Versions/A/GSS
dyld: loaded: /usr/lib/libresolv.9.dylib
dyld: loaded: /usr/lib/libiconv.2.dylib
dyld: loaded: /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
dyld: loaded: /usr/lib/libheimdal-asn1.dylib
dyld: loaded: /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
dyld: loaded: /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth
dyld: loaded: /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
dyld: loaded: /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
dyld: loaded: /System/Library/PrivateFrameworks/APFS.framework/Versions/A/APFS
dyld: loaded: /usr/lib/libutil.dylib
dyld: loaded: /usr/lib/libcharset.1.dylib
dyld: loaded: /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
dyld: loaded: /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
dyld: loaded: /System/Library/PrivateFrameworks/AppleSauce.framework/Versions/A/AppleSauce
dyld: loaded: /System/Library/PrivateFrameworks/AssertionServices.framework/Versions/A/AssertionServices
dyld: loaded: /System/Library/PrivateFrameworks/BaseBoard.framework/Versions/A/BaseBoard
dyld: loaded: /usr/lib/libmecab.1.0.0.dylib
dyld: loaded: /usr/lib/libgermantok.dylib
dyld: loaded: /usr/lib/libThaiTokenizer.dylib
dyld: loaded: /usr/lib/libChineseTokenizer.dylib
dyld: loaded: /System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling
dyld: loaded: /System/Library/PrivateFrameworks/CoreEmoji.framework/Versions/A/CoreEmoji
dyld: loaded: /System/Library/PrivateFrameworks/Lexicon.framework/Versions/A/Lexicon
dyld: loaded: /System/Library/PrivateFrameworks/LinguisticData.framework/Versions/A/LinguisticData
dyld: loaded: /usr/lib/libcmph.dylib
dyld: loaded: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
dyld: loaded: /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
dyld: loaded: /System/Library/PrivateFrameworks/BackgroundTaskManagement.framework/Versions/A/BackgroundTaskManagement
dyld: loaded: /usr/lib/libxslt.1.dylib
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
[1] 45862 abort env DYLD_PRINT_LIBRARIES=1 swiftlint version

Thanks for that @bmodesitt. I added /usr/lib/swift/lib/libswiftSwiftOnoneSupport.dylib to the parent apps Framework directory and all is working now.
I figured better to use the dylib from /usr/lib/swift as its location is not dependent on /Applications/Xcode vs /Applications/Xcode-beta

Huh, I don't see it in the list! My best guess is that this copy of swiftlint is statically linking a version of the Swift 5 standard library, which, yeah, isn't supported on macOS 10.14.4.

1 Like

@jrose from the Makefile of SwiftLint:

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

it would seem that it does, am I mistaken? I do not think SwiftLint is using Swift 5 yet, would this problem or should this problem occur also if it were statically linking the Swift 4.2 standard library?

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.)

2 Likes

Thank you for your reply @jrose, I saw that Swiftlint still had an open PR for Swift 5 so I assumed the version I downloaded had not been linked against the Swift 5 Standard Library (got the swiftlint tool from Homebrew).

Why is this? Seems like this is the crux of the problem. If they would, you could just allow embedding the binaries.

Or why not build an executable format that provides for dynamic linking of libraries embedded in it, with preference given to /usr/lib/swift? I guess that would require updating all the loaders on all the OSes on which Swift runs, huh?

Terms of Service

Privacy Policy

Cookie Policy