Codesigned Max standalone will not save presets to disk

    MaxMSPadvancedbugs/issuesresolved

    Andrew Milne
    Apr 19 2023 | 9:31 am
    I can build a standalone of XronoMorph – https://www.dynamictonality.com/xronomorph.htm – and it works perfectly on my Macbook Pro. However, when I codesign the app and attempt to save a preset, the preset json file (in XronoMorph.app/Contents/Resources does not get written to). Does anyone have any suggestions as to the cause or any possible solutions?

    • Source Audio's icon
      Source Audio
      Apr 19 2023 | 11:41 am
      If your app is located in /Applications folder, and you have not disabled apple gatekeeper, or given your app full disk access rights, then it can not write into app resources.
      you could instead write into documents folder or in your app's preferences folder, that should be allowed.
      Share
    • Andrew Milne's icon
      Andrew Milne's icon
      Andrew Milne
      Apr 19 2023 | 12:28 pm
      I may be wrong, but I think I have given the app disk access rights. But moving the app to Downloads, Desktop, Documents, or Applications makes no difference – changes won't write to the presets json in the Resources folder. So I am a bit confused as to why this is happening.
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Apr 19 2023 | 1:15 pm
      It is not moving the app, but write destination for json file. By the way, are you using absolute path ? not just write presets.json, but write /Appications/MyApp.app/Conents/Resources/presets.json
    • Andrew Milne's icon
      Andrew Milne's icon
      Andrew Milne
      Apr 19 2023 | 2:31 pm
      The preset json is first read in and then the writeagain message is used to save any changes. The read message specifies only the name of the preset file with no path at all. This seems to work fine for the standalone, but writing breaks when the app is codesigned. Tomorrow, I will try specifying a relative path (I prefer relative to absolute so the user can put the app wherever they like) and see if that makes any difference although it's not clear to me why it would.
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Apr 19 2023 | 3:11 pm
      one would expect that writeagain works, but it did not work for me since quite few max versions, so I gave it up, and use absolute path. Your preset file is in same location as mxf file, you can send path message to thispatcher on load
    • Andrew Milne's icon
      Andrew Milne's icon
      Andrew Milne
      Apr 20 2023 | 8:20 am
      Using absolute paths solved the problem – presets are now saving in the codesigned version of the standalone. Thank you for your advice! One thing to note is that sending "path" to [thispatcher] does not seem to work for standalones. But the path can be obtained by sending a sendapppath message to Max, as in this adapted version:
      It's a slightly annoying design because it does not work for the patch running in Max. I wonder if there is any way to get a single solution for patches, standalones, and codesigned standalones?
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Apr 20 2023 | 9:41 am
      path to thispatcher will give you both - path to main patcher while editing, and path to mxf in standalone. but if that for some reason does not work for you,
    • Andrew Milne's icon
      Andrew Milne's icon
      Andrew Milne
      Apr 20 2023 | 10:08 am
      Ah, that's neat! I wasn't aware of the getruntime message. Thank you.
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Apr 21 2023 | 7:00 am
      Could you post what path does path message to thispatcher output for you in signed standalone ? You mentioned that it does not work properly. It interests me because I don't use systems > High Sierra, and also don't sign standalones...
    • Andrew Milne's icon
      Andrew Milne's icon
      Andrew Milne
      Apr 22 2023 | 1:03 am
      I am on macOS Ventura 13.3.1 with Max 8.5.4. Sending "path" to [thispatcher] works as expected in a patch but, in a standalone (whether or not codesigned), the output is only a forward slash: /
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Apr 22 2023 | 9:27 am
      Thanks for the infos. I tested today max 8.5.3 standalone on High Sierra, path to this patcher displays correctly absolute path to resources folder. If you insert conformpath max absolute ?
    • Andrew Milne's icon
      Andrew Milne's icon
      Andrew Milne
      Apr 23 2023 | 8:27 am
      Odd, but it seems that adding [deferlow] to delay the [loadbang] sending "path" to [this patcher] gets this method to work for a not-codesigned standalone (I have not yet tested a codesigned version). Patch attached.
      Test.maxpat
      maxpat 4.30 KB
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Apr 23 2023 | 12:39 pm
      you can safely add one or few seconds of delay to get the path.
      ... messages have the argument not to restore contents ... spares closebang object
    • Andrew Milne's icon
      Andrew Milne's icon
      Andrew Milne
      Apr 24 2023 | 12:20 am
      Thank you for your help in solving this non-obvious problem.