CodySchrank / gSwitch

macOS menu bar app that allows control over the gpu on dual gpu macbooks
MIT License
894 stars 47 forks source link

dyld: Symbol not found: __T0SbMa #50

Closed ryandesign closed 4 years ago

ryandesign commented 4 years ago

gSwitch just updated itself from 1.9.5 to 1.9.6 and now it doesn't launch anymore. If I launch it from the Terminal we see what the problem is:

$ /Applications/gSwitch.app/Contents/MacOS/gSwitch
dyld: Symbol not found: __T0SbMa
  Referenced from: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftDarwin.dylib
  Expected in: /Applications/gSwitch.app/Contents/MacOS/../Frameworks/libswiftCore.dylib
 in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftDarwin.dylib
Abort trap: 6

I am running macOS High Sierra 10.13.6 with Xcode 9.4.1.

It seems like gSwitch should be self-contained and should not be referencing anything inside the Xcode app bundle.

CodySchrank commented 4 years ago

The auto update feature is handled by Sparkle. It could be a bug with it.

ryandesign commented 4 years ago

Well the same happens if I download the zip from the GitHub releases tab.

CodySchrank commented 4 years ago

I updated all the packages to the new versions in the new release that just came out. I have never seen an error like this but I'm guessing its because you have an older version of xcode installed and its trying to reference the swift library but since yours is older it is breaking somewhere.

CodySchrank commented 4 years ago

Can you try this version? It includes the standard swift libraries in the app.

gSwitch.zip

ryandesign commented 4 years ago

Hmm, it still says:

$ ~/Downloads/gSwitch.app/Contents/MacOS/gSwitch
dyld: Symbol not found: __T0SbMa
  Referenced from: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftDarwin.dylib
  Expected in: /Users/rschmidt/Downloads/gSwitch.app/Contents/MacOS/../Frameworks/libswiftCore.dylib
 in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftDarwin.dylib
Abort trap: 6
CodySchrank commented 4 years ago

I would recommend updating your xcode and macos to more recent versions.

ryandesign commented 4 years ago

I'm not going to do that at this time, and I don't think that's a satisfactory resolution to this issue.

CodySchrank commented 4 years ago

You're welcome to fork the project yourself. If you make a PR and it tests fine then I will merge.

ryandesign commented 4 years ago

I believe this Apple developer forum thread describes the problem and the solution:

It’s very likely that you have rpath problems

It looks like the problem is in the copy of SwiftyBeaver.framework in gSwitch.app 1.9.6:

$ otool -l gSwitch.app/Contents/Frameworks/SwiftyBeaver.framework/Versions/A/SwiftyBeaver | grep -B 1 -A 2 LC_RPATH
Load command 18
          cmd LC_RPATH
      cmdsize 32
         path /usr/lib/swift (offset 12)
--
--
Load command 19
          cmd LC_RPATH
      cmdsize 112
         path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx (offset 12)

If I fix that rpath with:

install_name_tool -rpath /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx @executable_path/../Frameworks gSwitch.app/Contents/Frameworks/SwiftyBeaver.framework/Versions/A/SwiftyBeaver

then it launches and works correctly, but it shouldn't need to be fixed manually; there should be a way to build it correctly in the first place following the instructions in that thread.

For comparison, the copy of SwiftyBeaver.framework in gSwitch.app 1.9.5 had these rpaths:

$ otool -l /Applications/gSwitch.app/Contents/Frameworks/SwiftyBeaver.framework/Versions/A/SwiftyBeaver | grep -B 1 -A 2 LC_RPATH
Load command 22
          cmd LC_RPATH
      cmdsize 32
         path /usr/lib/swift (offset 12)
--
--
Load command 23
          cmd LC_RPATH
      cmdsize 40
         path @executable_path/Frameworks (offset 12)
--
--
Load command 24
          cmd LC_RPATH
      cmdsize 40
         path @loader_path/Frameworks (offset 12)
CodySchrank commented 4 years ago

@ryandesign That makes sense. I updated swiftbeaver from 1.7 to 1.9 in the latest release.

I rebuilt the swiftybeaver framework with that line removed.

Can you test this version? gSwitch.zip

ryandesign commented 4 years ago

That version does seem to work for me, thanks!

CodySchrank commented 4 years ago

Nice! So you were right, that 1 line was the issue. Hopefully swiftybeaver can update their framework. I'll include this fix in the next version of gswitch.