MaxiHuHe04 / iTunes-Backup-Explorer

A graphical tool that can extract and replace files from encrypted and non-encrypted iOS backups
MIT License
566 stars 52 forks source link

MacOS compatibility changes #3

Open ivucica opened 3 years ago

ivucica commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@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:

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

ccsasuke commented 1 year ago

@danem This works, thanks!

briankrupp commented 1 year ago

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!