I have a swift binary I am packaging in an electron app. The binary simply connects to AVFoundation and serves as a wrapper to enable recording screen and microphone (GitHub - slashauth/aperture-node: Record the screen on macOS from Node.js forked from GitHub - wulkano/aperture-node: Record the screen on macOS from Node.js). I then bundle this binary into an electron app and distribute it. As such, I attempt to compile and link the swift stdlib to the binary so that I do not require the consumer to have the stdlib installed. This appears to not work with a warning:
warning: Swift compiler no longer supports statically linking the Swift libraries. They're included in the OS by default starting with macOS Mojave 10.14.4 beta 3. For macOS Mojave 10.14.3 and earlier, there's an optional Swift library package that can be downloaded from "More Downloads" for Apple Developers at https://developer.apple.com/download/more/
When distributing the app, I am blocked from running the code. Specifically, when the app starts I receive:
XprotectService: [com.apple.xprotect:xprotect] File /Applications/Debrief.app/Contents/Resources/app.asar.unpacked/node_modules/@getdebrief/aperture/aperture failed on rPathCmd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftAVFoundation.dylib (rpath resolved to: (path not found), bundleURL: /Applications/Debrief.app)
This made me infer that the binary is actually dynamically linked, and using otool
, I found it sure is:
otool -L aperture
aperture:
/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 1292.60.1)
/System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2022.20.117)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1463.2.1)
/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreMediaIO.framework/Versions/A/CoreMediaIO (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1770.255.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/usr/lib/swift/libswiftCoreMIDI.dylib (compatibility version 1.0.0, current version 2.0.0, weak)
/usr/lib/swift/libswiftUniformTypeIdentifiers.dylib (compatibility version 1.0.0, current version 633.0.2, weak)
@rpath/libswiftAVFoundation.dylib (compatibility version 1.0.0, current version 2000.5.4, weak)
@rpath/libswiftAppKit.dylib (compatibility version 1.0.0, current version 103.10.0, weak)
@rpath/libswiftCloudKit.dylib (compatibility version 1.0.0, current version 962.0.0, weak)
@rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 1200.2.41)
@rpath/libswiftCoreAudio.dylib (compatibility version 1.0.0, current version 1.1.0, weak)
@rpath/libswiftCoreData.dylib (compatibility version 1.0.0, current version 3.0.0, weak)
@rpath/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 1.6.0, weak)
@rpath/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 2.0.0)
@rpath/libswiftCoreImage.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
@rpath/libswiftCoreLocation.dylib (compatibility version 1.0.0, current version 5.0.0, weak)
@rpath/libswiftCoreMedia.dylib (compatibility version 1.0.0, current version 1.0.0)
@rpath/libswiftDarwin.dylib (compatibility version 1.0.0, current version 0.0.0, weak)
@rpath/libswiftDispatch.dylib (compatibility version 1.0.0, current version 4.40.2, weak)
@rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 20.0.0)
@rpath/libswiftIOKit.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
@rpath/libswiftMetal.dylib (compatibility version 1.0.0, current version 1.3.1, weak)
@rpath/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
@rpath/libswiftQuartzCore.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
@rpath/libswiftXPC.dylib (compatibility version 1.0.0, current version 1.1.0, weak)
@rpath/libswiftsimd.dylib (compatibility version 1.0.0, current version 1.3.0, weak)
My question is: Does a way exist to bundle the stdlib with the app for distribution? If not, can anyone suggest another path to create a native binary for interacting with AVFoundation, please? Failing that, any other threads you could suggest for me to pull on?