zip unzip issue on MacOS

Hi All,

I renew my licence of Xojo and I have one big issue on Mac.

I made a new compilation of my app KnotsBag with the last release of Xojo 2018 R3. Itworks fine with Mac OS 10.13. I zip the app and unzipp : it’s still ok.
BUT if I upload the zip on my server (webSite) and download and unzipp it, it doesn’t work anymore !!! When I run the app I have the message “An exception of class OutOfBoundsException was not handled. The application must shut down.”

The same thing appends with another cloud, and with a .dmg file instead of a. zip.

I found a (bad) solution to run the app using the Terminal app : "open Applications/myApp.app/Contents/MacOS/myApp
But my app quit when I quit the terminal

Do you have an idea of what 's wrong ?

I can’t distribute my app anymore…

Thanks in advance for your help !

Graud Bousquet (http://www.hypatiasoft.fr)

yet if you run the exact same app on the exact same computer, but without having it come from a zip file… then it works?

Hi Dave,

Yes it works fine before the zip and after the zip/unzipp on the computer that made the app with Xojo.
And it works fine too on other computers if I copy the zip with a USB key or an external hard drive.
BUT it doesn’t work anymore if I upload/ download using a server (???)

Can the zip operation modify a file ?

Here is the link to download and test :

http://www.hypatiasoft.fr/Folder_KnotsBag/Downloads/KnotsBag_2_1_2_Mac_32bit.zip

It works only if you go into the file KnotsBag.app/Contents/MacOS/ and click on KnotsBag !

This looks like a packaging issue. You can find more information if you search for “translocation”
tl;dr - you can’t store your preferences next to the app like that.

The computer that made the app has files or folders that are not part of the app, (or created by the app when it runs).

You may have made assumptions about the locations of files which are ‘relative to the app’.
Add some checks for file.exists before you use files

Why does it works on others computers if I copy my zip file using a USB Key ?
It seems that all the needed files are in the zip, no ? Which kind of file could be missing ?
I always did like that until Xojo 2014 and never had issues.
has something changed?

Thanks for your help Tim and Jeff !

Perhaps a newbie question , but Tim what do you mean by "if you search for “translocation”
tl;dr ". You mean in XOJO ?

Translocation - MACOS puts your app into a temporary location. It is run in a kind of sandbox.
Any files you believe are ‘next to the app’ are no longer where you think they are.
The prefs file cannot be opened.
You should create it in Applicationdata when the app starts, if it does not exist.
You can only assume that files in the Resources folder are available.

Thanks , I see. But why the "preferences " folder is it found using KnotsBag.app/Contents/MacOS/ and click on KnotsBag ?

Jeff, by “You should create it in Applicationdata when the app starts, if it does not exist.” you mean to something to do in XOJO ?
(I haven’t used Xojo since release 2014, sorry if my questions don’t fly very high :wink:

I understand that my app runs from another place (a temporary location) and at this place there is no “preferences” folder next to it.
But why does it work when I copy my folder (app + preferences folder) using a USB key on any computer ? (with or without zip/unzip) I should have the same issue, no ?
Why does this issue occur only by uploading /downloading with a server ?

“You should create it in Applicationdata when the app starts, if it does not exist.” you mean create a “preferences” folder in Library/Application Support/ ?

It’s because of Apple’s SIP security levels. If you download it, SIP considers it suspicious until you fix it. If you copy it from a local location, SIP gives it a pass.

Thanks Tim … :frowning: How other developers do ? How can we distribute apps for users ?
I mean, there is no way out excepting paying to be on the AppStore ?

After you download and unzip the app, you should then use Finder to drag and drop the .app to another location - that will clear the quarantine. Or, if the app is where it needs to be, you can use “xattr” in a Terminal to clear it as well like this:

sudo xattr -r -d com.apple.quarantine TheApplication.app

Also, properly signing and notarizing the app will alleviate this. Refer to the thread about hardening and notarization.

Thanks Tim. I will try this tomorrow (it’s late in France ;-)) I will learn how to sign and notarize the app properly reading the thread.
Thanks again.

[quote=413795:@GraudBOUSQUET]Thanks Tim … :frowning: How other developers do ? How can we distribute apps for users ?
I mean, there is no way out excepting paying to be on the AppStore ?[/quote]
Code signed DMG files or Installer Packages are the Apple sanctioned method of distributing software (There is such a thing a code signed ZIP file, but Apple have reserved it for their own use). App Wrapper can create “Installer Packages” for you when you wrap the application or it can work with the excellent DMG Canvas to automate signed DMG creation.

p.s. App Wrapper 3.9 Betas now support Hardened code signing and Notarization.

When delivering as a zip file, the app can test if it’s running translocated, and then ask the user to move the app another location (using the Finder).

Here are some projects I made that test this and also can move themselves to the Applications folder (in your case, you’d have to also move the other files next to the app, though):

http://files.tempel.org/RB/Translocation_Handling.zip – shows how to detect and remove Translocation mode.
http://files.tempel.org/RB/MoveMe.zip – this moves the app to the Apps folder.

Note that you can remove the Translocation flags from the app only after you’ve moved the app, so you’d first have to wait for the user (or the “MoveMe” code) to move the app to another place, and only then you can remove the translocation mode from the app.

Can you test this with “Hardened Runtime” enabled, is it still possible.

Sorry, have not done anything related to that, and have not the patience to try now or anytime soon. Someone else could, though :slight_smile: