Open Shabinder opened 3 years ago
Thanks for offering to help! I've got no idea what's going on there, but there's also still some code missing to make this work on macOS anyway and I'll probably have to figure out a way to cross compile to macOS to work on and debug it. Can't really say when I'll have time to do that though.
I originally mentioned macOS in the readme, because I used redhook, which supposedly also works on macOS. I later removed that dependency, because it can only produce dylibs (not cdylibs), which are very large (~8 MB in this case) and should apparently only be linked with other Rust binaries.
maybe this repo can help, but unfortunately it based on previous version
I have found that adding
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
to your ./cargo/config
successfully compiles the project. But on macOS it creates a .dylib instead of a .so file . Also
make install doesn't work because BSD install and GNU install doesn't have the same flags.
Hey @shoccho . Have you tried using the .dylib like this?
DYLD_INSERT_LIBRARIES=spotify-adblock.dylib /Applications/Spotify.app/Contents/MacOS/Spotify
Also, if it works, may I ask you to please share your compiled dylib with me? 😬
Hey @shoccho . Have you tried using the .dylib like this?
DYLD_INSERT_LIBRARIES=spotify-adblock.dylib /Applications/Spotify.app/Contents/MacOS/Spotify
Also, if it works, may I ask you to please share your compiled dylib with me? 😬
Hey @alcmoraes - I've tried this solution and it did not work. We need a .so
lib. It wont work without that.
Hey @shoccho . Have you tried using the .dylib like this?
DYLD_INSERT_LIBRARIES=spotify-adblock.dylib /Applications/Spotify.app/Contents/MacOS/Spotify
Also, if it works, may I ask you to please share your compiled dylib with me? 😬
Hey @alcmoraes - I've tried this solution and it did not work. We need a
.so
lib. It wont work without that.
Likewise, there doesn't seem to be a great substitute for installing, but creating the .dylib file seems to be okay with a tweak? I didn't manage to get the build to compile with @shoccho solution exactly, but manually running this command did (almost the same thing, specifically referring to release and not target made it work?):
spotify-adblock % cargo rustc --release -- -C link-arg=-undefined -C link-arg=dynamic_lookup
(Somehow I also end up with a .d file which... I think means I've messed up some code somewhere.)
I genuinely do not have anywhere near the coding understanding required to try and allow 'sudo make install' to work or get a way around it, and as stated earlier, GNU and BSD conflict in certain commands. Best I could do was basically strip the makefile of its soul to remove errors when testing the command but that's not really helpful. Any other way to insert or run the .dylib file didn't lead to anything
Also, if it works, may I ask you to please share your compiled dylib with me?
I don't have access to any mac right now so can't test anything further or give you the dylib file. I tried inserting the dylib file but it didn't work. I really don't have enough experience in macOs to figure out what went wrong.
I genuinely do not have anywhere near the coding understanding required to try and allow 'sudo make install' to work or get a way around it, and as stated earlier, GNU and BSD conflict in certain commands. Best I could do was basically strip the makefile of its soul to remove errors when testing the command but that's not really helpful. Any other way to insert or run the .dylib file didn't lead to anything
I am clueless here too. in this case make install just copies the file to some directories so I manually copied the files. didn't work. tried injecting dylib still didn't work. maybe for security reasons ? I tried to "code sign" by following this blog ( I actually don't know wtf I tried to do ) maybe someone else can figure it out.
As I already said, this won't work anyway without some code changes. We essentially need a macro like this. I've been trying to write this second macro and abstract away the differences between how the overriding works on Linux and macOS, so we don't need to duplicate any of the other code, but haven't succeeded yet.
Spotify for macOS loads symbols from Chromium Embedded Framework
with a call to dlopen
first and then subsequent calls to dlsym
using that same handle. This means it is impossible to redirect url_request_create
using DYLD_INSERT_LIBRARIES
. I guess one option would be to create a "fake" Chromium Embedded Framework
that exposes all the symbols and loads the real one under the hood.
Also, to even enable the use of DYLD_INSERT_LIBRARIES
Spotify must be re-signed with the entitlement com.apple.security.cs.allow-dyld-environment-variables
. The loader ignores the variable otherwise.
Update: This is the final thing. I have only tested this on Apple Silicon though.
I've been following this for a while as an alternative to my own project. I just wanted to link it here for anyone who is looking for something that is confirmed to work on MacOS x86.
Hey, I would like to help you to make this project of yours work on MacOS too. I can help you with Testing and Error Reporting.
I tried and got the following error: