Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS compatibility changes #3

Open
ivucica opened this issue Sep 26, 2021 · 7 comments
Open

MacOS compatibility changes #3

ivucica opened this issue Sep 26, 2021 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@ivucica
Copy link

ivucica commented Sep 26, 2021

Hi,

As someone that's not comfortable with Java, after a bit of effort, I managed to run iTunes Backup Explorer on OS X.

While I won't grab the time to put effort into a coherent PR, here's some things (a mixture of instructions for Mac OS users with some small patches):

  1. I had Java 8 installed; I believe it was some sort of "system" Java. Not sure if it was the old Apple-provided build. I needed to bump Java to something newer. As I have Homebrew installed, I used:

    brew install java
    

    This installed OpenJDK 17.

    Per instructions printed by Homebrew, I exposed this to Apple's wrappers like so:

    sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
    

    I'm not sure if I had to export JAVA_HOME=$(/usr/libexec/java_home -v17).

    I had Maven installed from before. It was a Homebrew version (brew install maven).

  2. At this point I could build iTunes-Backup-Explorer using mvn compile.

    java -jar target/itunes-backup-explorer-1.0-SNAPSHOT.jar did not work, but mvn javafx:run did.

  3. JavaFX 13 has bugs on MacOS Catalina+. https://bugs.openjdk.java.net/browse/JDK-8234916

    image

    I've switched javafx-controls and javafx-fxml to version 15 in pom.xml

    This fixes the UI and now it renders correctly.

  4. I had to run this from Terminal.app or iTerm.app which has been first allowlisted in System Preferences's Security & Privacy pane for "Full Disk Access" -- otherwise I could not ls ~/Library/Application Support/MobileSync/Backup, and neither could it be accessed by iTunes-Backup-Explorer.

    By allowlisting the terminal app, java process inherits these permissions.

    There is likely an API to request full disk access, but I have not done serious Cocoa work in years, and definitely not in Java.

  5. Unfortunately, the code also hardcodes the path to MobileSync/Backup to System.getenv("APPDATA"), "Apple Computer\\MobileSync\\Backup".

    This is easy to resolve with System.getenv("HOME"), "Library/Application Support/MobileSync/Backup".

    Even though that's technically incorrect: one should use +[NSFileManager URLForDirectory:inDomains:] to find the paths to NSApplicationSupportDirectory in NSUserDomainMask or NSAllDomainsMask -- accepting there can be more than one such directory. Now, how to do that in Java? I don't really know.

    Of course, this is very much a Mac-specific code change, meaning it should be isolated from other supported OSes, so in lieu of spending time figuring that out, I'm just writing this issue and going back to recovering my Safari tabs :-)

@MaxiHuHe04 MaxiHuHe04 self-assigned this Apr 18, 2022
@MaxiHuHe04 MaxiHuHe04 added the bug Something isn't working label Apr 18, 2022
MaxiHuHe04 added a commit that referenced this issue Apr 18, 2022
@MaxiHuHe04
Copy link
Owner

MaxiHuHe04 commented Apr 18, 2022

Hey @ivucica!
I'm sorry it took so long. Thank you for your explanations. In case you are still interested:
I updated JavaFX and added the macOS backup path. You can now set custom paths using the preferences, too.
Finally, I published a release that you can download here: https://github.com/MaxiHuHe04/iTunes-Backup-Explorer/releases/latest. The jar should also work on macOS, but I didn't have a chance to test it yet. If you want to try it and it doesn't work, please let me know.

@claudiosv
Copy link

If anyone else is looking how to get this to run on aarch64 and is encountering

java.lang.UnsatisfiedLinkError: Can't load library: /Users/user/.openjfx/cache/18+12/libprism_sw.dylib

or

Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found

The problem is OpenJDK. To get it to work, I uninstalled OpenJDK, installed Oracle JDK 19 aarch64 and set JAVA_HOME, changed dependencies in the pom.xml from 18 to the latest builds of JavaFX packages 20-ea+7 and remove the platform tag/duplicates (probably not necessary). I then compiled this project mvn clean; mvn compile and ran it mvn exec:exec. It's important that everything is run natively aarch64 and not under Rosetta. Took about 3 hours to figure this out 😄 Once you're done you can uninstall evil Oracle JDK and go back to OpenJDK.

@ciberpiano
Copy link

@claudiosv. Thanks for the guide. For those of us, not so knowledgeable on Java, programming or compiling, would you care to detail further your instructions?

@ccsasuke
Copy link

If anyone else is looking how to get this to run on aarch64 and is encountering

java.lang.UnsatisfiedLinkError: Can't load library: /Users/user/.openjfx/cache/18+12/libprism_sw.dylib

or

Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found

The problem is OpenJDK. To get it to work, I uninstalled OpenJDK, installed Oracle JDK 19 aarch64 and set JAVA_HOME, changed dependencies in the pom.xml from 18 to the latest builds of JavaFX packages 20-ea+7 and remove the platform tag/duplicates (probably not necessary). I then compiled this project mvn clean; mvn compile and ran it mvn exec:exec. It's important that everything is run natively aarch64 and not under Rosetta. Took about 3 hours to figure this out 😄 Once you're done you can uninstall evil Oracle JDK and go back to OpenJDK.

Thanks for the guide. How to get the JavaFX package version (20-ea+7 doesn't seem to work with the latest JDK 19 downloaded from Oracle.)

@danem
Copy link

danem commented Feb 23, 2023

@ccsasuke

I'm not a java developer, so I have no clue if these steps are strictly necessary, but what I did to get it working is as follows:

  • Delete all of my maven cache (eg: rm -rf ~/.m2/repository)
  • Edit the pom.xml file, removing the javafx-graphics entries for the other platforms, and specifying mac-aarch64 for all of the javafx entries.
  • Run mvn clean; mvn compile
  • Finally run mvn exec:exec

This is all in addition to what the previous commenters suggested.

@ccsasuke
Copy link

@danem This works, thanks!

@briankrupp
Copy link

If anyone else is looking how to get this to run on aarch64 and is encountering

java.lang.UnsatisfiedLinkError: Can't load library: /Users/user/.openjfx/cache/18+12/libprism_sw.dylib

or

Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found

The problem is OpenJDK. To get it to work, I uninstalled OpenJDK, installed Oracle JDK 19 aarch64 and set JAVA_HOME, changed dependencies in the pom.xml from 18 to the latest builds of JavaFX packages 20-ea+7 and remove the platform tag/duplicates (probably not necessary). I then compiled this project mvn clean; mvn compile and ran it mvn exec:exec. It's important that everything is run natively aarch64 and not under Rosetta. Took about 3 hours to figure this out 😄 Once you're done you can uninstall evil Oracle JDK and go back to OpenJDK.

I did not have to go through all of these steps, but changing the JDK definitely fixed the issue. Thank you sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants