3

I wrote a screensaver in Swift.

Although I had set the macOS Deployment Target to macOS 10.13, it failed to run on an x86_64 Mid 2010 Mac Pro running macOS High Sierra 10.13.6.

Meanwhile, it runs fine on my arm64 2020 MBP M1 with macOS Big Sur 11.5.2, and on an x86_64 2019 MacBook Air with macOS Catalina 10.15.6.

The screensaver installs fine on all machines, but on the machine running High Sierra it says that the screensaver is not compatible.

The error message shown is as follows ("vibe" is the name of the screensaver that I made. So anyone else running across this same problem will see a similar message but with the name of their own screensaver in place of that of course):

You cannot use the vibe screen saver with this version of macOS.

Please contact the vendor to get a newer version of the screen saver.

Screenshot of error message

I am wondering if there is a way to automatically figure out if there are any APIs or other features that my code is using which were not available in macOS 10.13. And also I am wondering if it is usual that you can build for a given macOS Deployment Target and then when you try to run the program on a machine that is within the range that should be supported, the program will not run after all. I had thought that there would be a build time error to build for a macOS Deployment Target if the built program will not run on it.

I am using Xcode 12.5.1 running on my MBP M1, macOS 11.5.2, and as mentioned I am building for macOS Deployment Target set to macOS 10.13. The screensaver runs fine on both Intel with macOS 10.15 and ARM with macOS 11.5. I am using Swift Language Version Swift 5.

Erik N.
  • 99
  • 6
  • What specifically do you mean by "it failed to run"? – Alexander Sep 19 '21 at 23:25
  • @Alexander As mentioned, it says that the screensaver is not compatible. It doesn't say why. And because the machine is set up to run in Norwegian I didn't include the message in my post, since this is an English speaking forum. But to be a bit more specific, this is in System Preferences > Desktop & Screen Saver. Instead of showing a rendered preview it says that it's not compatible. I'm not able to provide a transcript or screenshot right now but can do so tomorrow. I'm going to change the language of the computer to English and include the message. – Erik N. Sep 19 '21 at 23:44
  • 1
    Have you tried poking around Console.app to see if anything intersting was logged? – Alexander Sep 20 '21 at 00:19
  • @Alexander I've added the error message and a screenshot of it now. Will have a look in Console.app to see if I can spot anything. – Erik N. Sep 20 '21 at 01:29
  • 1
    specially fun because it says "contact the vendor to get a newer".. newer means even less compatible to a legacy system. Would be interesting what APIs you are using apart from Quartz. If you could get a compiled version from Xcode11.3 targeting osx10.13 you could in theory at least compare the two builds to get some clue whats up. – Ol Sen Sep 20 '21 at 02:36
  • 1
    @Alexander thank you for the suggestion to poke around in Console.app, I did indeed find some highly relevant information there. Going to post an answer to my own question with what I found. – Erik N. Sep 20 '21 at 02:38
  • 1
    @OlSen RE: "contact the vendor to get a newer". Yeah :P And for a while the wording also made me think that perhaps macOS 10.13 was being confused about the fat binary, since macOS 10.13 was released prior to arm64 versions of macOS existing. And I was thinking maybe it somehow concluded fat binary = old because they used to make it possible to build fat binaries for powerpc + intel. But then I realized that this was probably not the reason, given that I think they have used arm64 + intel fat binaries in conjunction with the iOS Simulator possibly. And furthermore I figured that probably Apple – Erik N. Sep 20 '21 at 03:53
  • 1
    @OlSen (cont. from prev. comment) that probably Apple have made the Mach-O fat binary format be forward compatible in the sense that their operating systems will ignore all other architectures present so that at any point in the future they can make fat binaries that embed binaries for future architectures while allowing older versions of macOS to load the embedded binary for their own architectures without confusion arising. – Erik N. Sep 20 '21 at 03:56

1 Answers1

4

Solution

Install "Swift 5 Runtime Support for Command Line Tools" from https://support.apple.com/kb/dl1998?locale=en_US on the macOS 10.13 machine I wanted to run the screensaver on.

Background, details and alternative solution

Thanks to the comment of @Alexander, where he suggested:

Have you tried poking around Console.app to see if anything intersting was logged?

I was able to figure it out.

In Console.app, in the default view that shows device messages for the computer, I applied a search filter for any occurence of the name of the screensaver and then in System Preferences > Desktop & Screen Saver, I selected my screensaver and clicked "Preview" hoping that this would result in something in the logs. And it did!

Relevant log message:

Error loading /Users/erikn/Library/Screen Savers/vibe.saver/Contents/MacOS/vibe: dlopen(/Users/erikn/Library/Screen Savers/vibe.saver/Contents/MacOS/vibe, 265): Library not loaded: @rpath/libswiftCore.dylib

Referenced from: /Users/erikn/Library/Screen Savers/vibe.saver/Contents/MacOS/vibe

Reason: image not found

With this in hand, I was then able to find a similar root cause and some suggested solutions at dyld: Library not loaded: @rpath/libswiftCore.dylib / Image not found

Which amount to setting "Always Embed Swift Standard Libraries" to YES, and possibly also adding @executable_path/Frameworks to Runpath Search Paths.

This may be one acceptable way of doing it.

However, not knowing the specifics of how this will interact on other systems and in the future I was a bit hesitant.

Fortunately, I then found https://developer.apple.com/forums/thread/687847 which while not directly relevant directed me to look for "Swift 5 Runtime Support for Command Line Tools", as this would provide the missing libswiftCore.dylib for macOS 10.13.

Erik N.
  • 99
  • 6
  • I'm not familiar with the screen saver system, but I'll share a tid-bit that might be useful from when I tried to implement a quick-look generator in Swift (prior to some recent API enhancements that made that readily possible). Quick look generators ran as a plugin to a single process, `quicklookd`. Since it's only one process, only one version of the Swift standard library could be dynamically linked in. That meant that all quick look plug-ins you had installed had to used the exact same Swift version, or they wouldn't work. – Alexander Sep 20 '21 at 12:11
  • ... If screen-savers run in a similar "plugin bundle loaded into a single server/daemon process" kind of way, then they might have the same restriction. – Alexander Sep 20 '21 at 12:11
  • 1
    @Erik N nice answer, this may also tell why i did not experience same troubles when developing a screensaver making use of WKWebkit and the older Webkit via objC running on older systems. – Ol Sen Sep 20 '21 at 15:11