Transgui: M1 macOS build?

Created on 21 Nov 2020  ·  34Comments  ·  Source: transmission-remote-gui/transgui

Apple m1 lines Macs are out, is there a easy way to build a m1 native app?

Operating system: macOS Big Sur 11.0.1 (20B29)

Most helpful comment

well what do you know, it works! I figured out the duplicate object member error was totally unrelated to my braindead fix in restranslator.pas, it was actually this same issue popping up again: https://github.com/transmission-remote-gui/transgui/issues/1325 and all I had to do was use the 1329 patch provided there! After fixing that, it seems to work fine! Tested by connected to my debian linux server running transmission-daemon 3.00. It's even proxied through nginx to give it SSL and that's working fine, no issues.
Screen Shot 2021-01-28 at 11 37 07 AM
Screen Shot 2021-01-28 at 11 37 48 AM
Tried everything I could think of and it all seems to be working, doesn't crash or anything either. All is well, so someone on the official end of things can basically provide a real build of this with the instructions I've provided here and minimal effort.
Screen Shot 2021-01-28 at 11 39 06 AM
(ignore all the errored torrents, that is a completely unrelated zfs issue that just happened. fml. )

If anyone else wants to try out this arm64 build I made, feel free, but the usual caveats that I provide zero support for this build, make no promises it won't set your dog on fire, etc. use at your own risk! transgui-macosx-arm64.zip

All 34 comments

@Willian-Zhang I don't think we have resource to work on it yet, we'll need some help to do that.

XCode 12 has cross-compiling, so you can build for ARM on an x86 Mac.
I'd be happy to test builds with my M1 Mac Mini.

@thebitstick Thanks! Contributions are very welcome and needed here!

And my axe! If there are clear enough setup guides I'd be happy to offer my resources, both machine and time wise

I've managed to rebuild a couple apps like ffmpeg, mpv, and iina for arm64 before any official builds were released so I'd be more than willing to give this a go and do a little how-to writeup. This and Dropbox are the only x86 apps left that I use on a daily basis.

I am completely inexperienced in such things, but if you need another tester and have a dmg or something I can surely also test it on my M1.

Yeah I've got an M1 MBA myself, hence the motivation to do these pre-release arm64 builds. I won't be able to really put my head into it until later today but anything I find out will be posted here.

I am completely inexperienced in such things, but if you need another tester and have a dmg or something I can surely also test it on my M1.

I don't know how to compile a project... But I have a Mac Mini M1 now and I really miss Transmission Remote GUI :)
If I can help, I'll do !

Well the old Transmission Remote GUI works fine on my M1 with Rosetta; just since it only respects dark mode half, it does not look nice.

Well the old Transmission Remote GUI works fine on my M1 with Rosetta; just since it only respects dark mode half, it does not look nice.

How do you do ? Here, I can't launch it. It's "PowerPC/32bits", so it can't be launched

Are you using 5.18? That is 64 bit I think? Also Homebrew _might_ work https://formulae.brew.sh/cask/transmission-remote-gui

Are you using 5.18? That is 64 bit I think? Also Homebrew _might_ work https://formulae.brew.sh/cask/transmission-remote-gui

Yes, I've downloaded latest release (5.18). It doesn't launch. When I use iMobie M1 App Checker, it says that this release can't be launch on a M1.

For the homebrew... I'm to newbie to understand how to do :(

@zepretender You might be encountering issues with the app not being signed. Go to your Applications folder, right-click on the app, and select Open. You'll only have to do this once.

Screen Shot 2021-01-19 at 6 01 46 AM
Okay, after a bunch of fiddling I have managed to successfully build transgui for aarch64. Hooray!

I even get it to launch, and it respects dark mode! Neat!
Screen Shot 2021-01-19 at 6 33 51 AM

But when I try to connect to a transmission rpc interface I get this error:
Screen Shot 2021-01-19 at 6 35 24 AM

I'm assuming this is because I wasn't supposed to edit line 787 of restranslator.pas which was giving me the compilation error:

transgui/restranslator.pas(787,24) Error: (3284) Operator is not overloaded: "Class Of TReader" and "Boolean"

so I blindly broke the if statement into two and it seemed to be happy with that, but clearly that is is not the correct solution.

begin
if Sender is TReader and Assigned(TReader(Sender).Owner) then
{if Assigned(TReader(Sender).Owner) then}
OwnerName := TReader(Sender).Owner.GetNamePath;

this is literally my first time even looking at pascal code so I'm not quite sure what the issue is really. Assigned() is just supposed to check if there's a pointer for the given object, and return a boolean. I have a feeling this is one of those incredibly unhelpful compiler errors that is actually being caused by something else entirely, but at this point I'm stumped. Any ideas?

Oh and I almost forgot, for anyone else who wants to join me in the mudpit, here's what I've had to do to get to this point:

1) Build FPC from latest git source
2) Build Lazarus from trunk
3) Install openssl with homebrew
4) Add to .fpc.cfg:
-Fl/opt/homebrew/Cellar/[email protected]/1.1.1i/lib
5) Edit transgui/synapse/source/lib/ssl_openssl_lib.pas:

@@ -113,8 +113,8 @@ const
         var
           {$IFNDEF MSWINDOWS}
             {$IFDEF DARWIN}
        -    DLLSSLName: string = 'libssl.dylib';
        -    DLLUtilName: string = 'libcrypto.dylib';
        +    DLLSSLName: string = 'libssl.1.1.dylib';
        +    DLLUtilName: string = 'libcrypto.1.1.dylib';
             {$ELSE}
              {$IFDEF OS2}
               {$IFDEF OS2GCC}

6) Edit setup/macosx/create_app_new.sh:

                -lazdir="${1:-/Developer/lazarus/}"
        +lazdir="${1:-<your laz_trunk dir>}

         if [ -z "${CI-}" ]; then
           ./install_deps.sh
        @@ -24,11 +24,11 @@ fi
         mkdir -p ../../Release/
         sed -i.bak "s/'Version %s'/'Version %s Build $build'#13#10'Compiled by: $fpc_ver, Lazarus v$lazarus_ver'/" ../../about.lfm

        -lazbuild -B ../../transgui.lpi --lazarusdir=/Developer/lazarus/ --compiler=/usr/local/bin/fpc --cpu=x86_64 --widgetset=cocoa
        +lazbuild -B ../../transgui.lpi --lazarusdir=<your laz_trunk dir> --compiler=/usr/local/bin/fpc --cpu=aarch64 --widgetset=cocoa

         # Building Intel version
        -make -j"$(sysctl -n hw.ncpu)" -C ../.. clean CPU_TARGET=x86_64 "$lazdir"
        -make -j"$(sysctl -n hw.ncpu)" -C ../.. CPU_TARGET=x86_64 "$lazdir"
        +make -j"$(sysctl -n hw.ncpu)" -C ../.. clean CPU_TARGET=aarch64 "$lazdir"
        +make -j"$(sysctl -n hw.ncpu)" -C ../.. CPU_TARGET=aarch64 "$lazdir" 

7) Edit restranslator.pas

@@ -784,8 +784,9 @@ var ResourceName: AnsiString; OwnerName: AnsiString; begin - if Sender is TReader and Assigned(TReader(Sender).Owner) then - OwnerName := TReader(Sender).Owner.GetNamePath; + if Sender is TReader {and Assigned(TReader(Sender).Owner)} then + if Assigned(TReader(Sender).Owner) then + OwnerName := TReader(Sender).Owner.GetNamePath;

8) cd setup/macosx
9) bash create_app_new.sh
10) _*jeff goldblum voice* Step 10? There is no step 10!_

well what do you know, it works! I figured out the duplicate object member error was totally unrelated to my braindead fix in restranslator.pas, it was actually this same issue popping up again: https://github.com/transmission-remote-gui/transgui/issues/1325 and all I had to do was use the 1329 patch provided there! After fixing that, it seems to work fine! Tested by connected to my debian linux server running transmission-daemon 3.00. It's even proxied through nginx to give it SSL and that's working fine, no issues.
Screen Shot 2021-01-28 at 11 37 07 AM
Screen Shot 2021-01-28 at 11 37 48 AM
Tried everything I could think of and it all seems to be working, doesn't crash or anything either. All is well, so someone on the official end of things can basically provide a real build of this with the instructions I've provided here and minimal effort.
Screen Shot 2021-01-28 at 11 39 06 AM
(ignore all the errored torrents, that is a completely unrelated zfs issue that just happened. fml. )

If anyone else wants to try out this arm64 build I made, feel free, but the usual caveats that I provide zero support for this build, make no promises it won't set your dog on fire, etc. use at your own risk! transgui-macosx-arm64.zip

Thanks, this already looks quite great! (looking forward to finally being able to read marked lines in Dark mode).
On my machine, sadly, your provided app can not be launched (the application is damaged and not be started is the error message)

Thanks, this already looks quite great! (looking forward to finally being able to read marked lines in Dark mode).
On my machine, sadly, your provided app can not be launched (the application is damaged and not be started is the error message)

Huh, I definitely signed it with my dev account so anyone should be able to run it. What happens when you try to run "Transmission Remote GUI.app/Contents/MacOS/transgui" directly? Sorry I'm kind of new to this and don't know what I'm doing at all, I'm just a blind man feeling his way in the dark here.

No, sorry, I know what an unsigned application looks like and how to start it. I mean the app is broken like in: I can not open the container to access the binary you refer to.

No, sorry, I know what an unsigned application looks like and how to start it. I mean the app is broken like in: I can not open the container to access the binary you refer to.

That's bizarre, it definitely had the proper structure when I zipped it, and I tried downloading the zip on another machine and it unzipped fine. Either way I signed the entire .app bundle and re-uploaded the zip, so try downloading it again.

I still got a “signed by untrusted developer”, but that's easy and is only the first start, so that works! Nice! Finally a proper dark mode and a native app. Thanks!

I still got a “signed by untrusted developer”, but that's easy and is only the first start, so that works! Nice! Finally a proper dark mode and a native app. Thanks!

Awesome, I guess that zip got messed up somehow when I uploaded it or something, weird. Glad it's working for others now, if I did all that work and nobody else could benefit it'd break my poor little nerd heart. Hooray!

Works perfectly, thanks for working on this @shermanikk!

Tested @shermanikk's build and it runs great.
Great job!

Great work @shermanikk - but I oddly get an error "Unable to load OpenSSL library files: libssl.1.1.dylib and libcrypto.1.1.dylib" after giving the app permissions. It sort of runs still but cannot connect to my Transmission Daemon running over SSL

Great work @shermanikk - but I oddly get an error "Unable to load OpenSSL library files: libssl.1.1.dylib and libcrypto.1.1.dylib" after giving the app permissions. It sort of runs still but cannot connect to my Transmission Daemon running over SSL

Oh I guess they didn't get built-in, still new at this. All you need to do is install openssl with homebrew in /opt/homebrew. That's the location I used when building it so I'm assuming it will be looking for them there.

Great work @shermanikk - but I oddly get an error "Unable to load OpenSSL library files: libssl.1.1.dylib and libcrypto.1.1.dylib" after giving the app permissions. It sort of runs still but cannot connect to my Transmission Daemon running over SSL

Oh I guess they didn't get built-in, still new at this. All you need to do is install openssl with homebrew in /opt/homebrew. That's the location I used when building it so I'm assuming it will be looking for them there.

Thank you for your fantastic work! I also encounter the openssl issue too... I tried to compile the code from scratch but now is blocked while linking transgui... The ld complains about

(9015) Linking ./transgui
ld: warning: building for macOS 10.5 is deprecated
ld: warning: passed two min versions (10.5, 11.0.0) for platform macOS. Using 11.0.0.
ld: library not found for -lc
An error occurred while linking
Error: (9013) Error while linking
Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted

Any ideas? I used the official fpc 3.2.2 for M1 and compiled Lazarus myself. Other configurations are following your instructions.

Oh I guess they didn't get built-in, still new at this. All you need to do is install openssl with homebrew in /opt/homebrew. That's the location I used when building it so I'm assuming it will be looking for them there.

Which version were you using? Mine cannot be found. This is my install of OpenSSL via brew.

~ ❯❯❯ brew info openssl
[email protected]: stable 1.1.1k (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/opt/homebrew/Cellar/[email protected]/1.1.1k (8,071 files, 18MB)
  Poured from bottle on 2021-03-29 at 19:37:47
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/[email protected]
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/[email protected]/certs

and run
  /opt/homebrew/opt/[email protected]/bin/c_rehash

[email protected] is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"

==> Analytics
install: 748,044 (30 days), 2,616,398 (90 days), 8,792,644 (365 days)
install-on-request: 55,366 (30 days), 240,031 (90 days), 1,126,038 (365 days)
build-error: 0 (30 days)

Oh I guess they didn't get built-in, still new at this. All you need to do is install openssl with homebrew in /opt/homebrew. That's the location I used when building it so I'm assuming it will be looking for them there.

Which version were you using? Mine cannot be found. This is my install of OpenSSL via brew.

~ ❯❯❯ brew info openssl
[email protected]: stable 1.1.1k (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/opt/homebrew/Cellar/[email protected]/1.1.1k (8,071 files, 18MB)
  Poured from bottle on 2021-03-29 at 19:37:47
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/[email protected]
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/[email protected]/certs

and run
  /opt/homebrew/opt/[email protected]/bin/c_rehash

[email protected] is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"

==> Analytics
install: 748,044 (30 days), 2,616,398 (90 days), 8,792,644 (365 days)
install-on-request: 55,366 (30 days), 240,031 (90 days), 1,126,038 (365 days)
build-error: 0 (30 days)

Seems like same to yours. (except the brew source)

$ brew info openssl
[email protected]: stable 1.1.1k (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/opt/homebrew/Cellar/[email protected]/1.1.1k (8,071 files, 18MB)
  Poured from bottle on 2021-05-21 at 14:34:05
From: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git/Formula/[email protected]
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/[email protected]/certs

and run
  /opt/homebrew/opt/[email protected]/bin/c_rehash

[email protected] is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"

==> Analytics
install: 748,044 (30 days), 2,616,398 (90 days), 8,792,644 (365 days)
install-on-request: 55,366 (30 days), 240,031 (90 days), 1,126,038 (365 days)
build-error: 0 (30 days)

Oh I guess they didn't get built-in, still new at this. All you need to do is install openssl with homebrew in /opt/homebrew. That's the location I used when building it so I'm assuming it will be looking for them there.

Which version were you using? Mine cannot be found. This is my install of OpenSSL via brew.

~ ❯❯❯ brew info openssl
[email protected]: stable 1.1.1k (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/opt/homebrew/Cellar/[email protected]/1.1.1k (8,071 files, 18MB)
  Poured from bottle on 2021-03-29 at 19:37:47
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/[email protected]
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/[email protected]/certs

and run
  /opt/homebrew/opt/[email protected]/bin/c_rehash

[email protected] is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"

==> Analytics
install: 748,044 (30 days), 2,616,398 (90 days), 8,792,644 (365 days)
install-on-request: 55,366 (30 days), 240,031 (90 days), 1,126,038 (365 days)
build-error: 0 (30 days)

Seems like same to yours. (except the brew source)

$ brew info openssl
[email protected]: stable 1.1.1k (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/opt/homebrew/Cellar/[email protected]/1.1.1k (8,071 files, 18MB)
  Poured from bottle on 2021-05-21 at 14:34:05
From: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git/Formula/[email protected]
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/[email protected]/certs

and run
  /opt/homebrew/opt/[email protected]/bin/c_rehash

[email protected] is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"

==> Analytics
install: 748,044 (30 days), 2,616,398 (90 days), 8,792,644 (365 days)
install-on-request: 55,366 (30 days), 240,031 (90 days), 1,126,038 (365 days)
build-error: 0 (30 days)

I'm totally new to pascal as well so if anyone can help me with this too, I'd be super grateful. You'll notice in my original comment I did something stupid: I pointed directly to version 1.1.1i of the openssl libs in my .fpc.cfg file. So when homebrew updated openssl, this obviously broke. What I don't understand is I have tried every fucking way possible of recompiling starting from SCRATCH with not even fpc installed and no matter what every version of transgui I manage to build always looks for openssl in that directory. It's like my .fpc.cfg file means nothing anymore.

As a temporary workaround making a symlink of the current version to 1.1.1i in /opt/homebrew/Cellar/[email protected]/ does work for me, so try that. It's not fixing the core issue though which I am totally stumped by.

Okay, figured out something at least. I can include the dylibs with the .app directory so you don't even have to have homebrew install OpenSSL! All I needed to do was copy libcrypto.1.1.dylib and libssl.1.1.dylib into the Contents/MacOS/ directory inside the .app bundle, then run "install_name_tool -add_rpath @executable_path/. transgui" inside the same directory. I've uploaded this self-contained version, so if someone could try it on their own machine without OpenSSL installed to make sure it works for them that'd be great: https://shermanikk.net/stuff/transgui-macosx-arm64.zip

https://shermanikk.net/stuff/transgui-macosx-arm64.zip

I tried opening through the right-click menu but it wouldn't budge.

image

https://shermanikk.net/stuff/transgui-macosx-arm64.zip

I tried opening through the right-click menu but it wouldn't budge.

image

alright now I'm stumped. if I download it through the link here via HTTPS, I get the same error as you. however, if I transfer it from my hosting via FTP using FileZilla to my Desktop folder and unzip it there, it works fine. I also compared md5 hashes between both zip files and they're identical. also, if I transfer via FTP to my Downloads folder, I also get this error. downloading via HTTPS to the Desktop doesn't work as well.

It's got to be some annoying bug with code signing verification, but at the moment I'm at a loss how to fix it.

edit: okay found a bit of a trick, run "sudo xattr -cr Transmission\ Remote\ GUI.app" and that should clear the stupid damaged flag. doing that worked in all the cases I tried. still don't know what's triggering it in the first place, but I'm just a blind man feeling in the dark here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LYCX2015 picture LYCX2015  ·  11Comments

hekm77 picture hekm77  ·  13Comments

elisimpson picture elisimpson  ·  11Comments

Dustie picture Dustie  ·  11Comments

noeRls picture noeRls  ·  5Comments