Max Standalone in the Mac App Store (2018)


    Oct 20 2018 | 6:38 pm

    Max Standalone in the Mac App Store (2018)

    I have successfully submitted my app to the Mac App Store. Yes it is possible! There seems to be a lack of updated information on this topic, so I have created this guide in hopes of helping out the community. It is important to note that this process will vary for every app, based on which externals/frameworks/extensions are present. You WILL get error messages the first time you submit your build to App Store.

    PART 1 | APPLE DEVELOPER PROGRAM

    STEP 1: Enroll in Apple Developer Program https://developer.apple.com cost $100 per year
    STEP 2: Create Certificates https://developer.apple.com/account/mac/certificate/ Create certificates - Mac App Distribution - Mac Installer Distribution TUTORIAL VIDEO
    STEP 3: Create App ID (aka Bundle Identifier) https://developer.apple.com/account/mac/identifier/bundle Apple recommends “reverse domain notation" example = com.website.appname
    STEP 4: App Store Connect https://appstoreconnect.apple.com/ Create a profile in App Store Connect for your application. This is where you edit how your app’s display page will look within the App store.

    PART 2 | STANDALONE PREPARATION

    STEP 1: Edit main patcher inspector View > Inspector Window Update inspector - Disable Workspace [X] - Open in Presentation [X] STEP 2: [standalone] object create a [standalone] object in your patch - open [standalone] inspector - update "Bundle Identifier" to match your Apple App ID (com.website.appname) - update "Preferences File Name" - Can't Close Toplevel Patchers [ ] - Disable Loadbang Defeating [X] - Status Window Visible at Startup [ ]
    STEP 3: Reducing File Size with [standalone] To reduce file size, you may uncheck CEF Support, Gen Support, and Include C74 Resources. However, these can be essential for certain functions (ie. Gen Support is needed if your app uses [gen~], CEF Support is needed if your app uses [jweb]).
    When in doubt, try your standalone with and without. My app worked fine with all of these unchecked. And the file size dropped from 315MB to 65MB. (More info HERE)
    STEP 4: Enable Quit on Window Close Paste this into your main patcher window. This will make your application quit (⌘+Q) automatically when the main window is closed.
    STEP 5: Build Standalone Application File > Build Collective / Application… - File Format : Application - Save to Desktop
    STEP 6: Create Custom Icon Use Image2Icon - export ICNS file - name your .icns file "APPLICATION.icns" (APPLICATION = your app's name) - replace existing .icns file @ /Contents/Resources/Max.icns/ (Max.icns --> APPLICATION.icns)

    PART 3 | EDITING FILES

    At this point, I removed the following files. They caused issues with submission, and my app worked fine without these files. (this is one thing, i’d love to figure out for an updated guide)
    /Contents/Frameworks/libmozjs.dylib/
    /Contents/Resources/MaxPlugInScanner/ (only needed if your app uses the vst~ object)
    STEP 1: Update main Info.plist Update Info.plist to reflect your app’s info. Show Package Contents > Contents > Info.plist
    Update existing rows: - Get Info string - Icon file - Bundle identifier - CFBundleLongVersionString - Bundle versions string, short - Bundle version
    Add new rows: - Application Category - Minimum system version
    (More info HERE)
    STEP 2: Add bundle identifier to every Info.plist Yes. Every file that contains a Info.plist, must be updated. However, all that is necessary is to add your Bundle Identifier. Simply, search info.plist in your application’s folder, and copy-paste the Bundle Identifier row from your main Info.plist file.
    *For (MSPReWireDevice.bundle) - replace the existing Bundle Identifier, rather than adding a new one*
    STEP 3: Edit .mxo files that contain (~) or (_) Any .mxo file that contains one of these characters in its name, needs to be edited.
    for each .mxo file : Show Package Contents > Info.plist Remove (_) or (~) from Executable string Remove (_) or (~) from CFBundleLongVersionString
    You must also rename the .exe file within each .mxo to reflect the name change.
    *HOWEVER, do not remove (_) or (~) from the actual .mxo file name*

    PART 4 | SANDBOXING

    STEP 1: Create Entitlements File Open Xcode - File > New > File > MacOS > Property List - name “entitlements.plist" - save to Desktop
    STEP 2: Add Sandboxing Row To create strings -hover over “Root” -press the (+) to add rows -create sandboxing row
    EXAMPLE
    Key : com.apple.security.app-sandbox
    Type : Bootlean
    Value : YES
    STEP 3: Add Entitlement Keys Entitlements tell Apple which files/features your app has permission to access on the user’s computer. For example, if your app uses bluetooth, you must add the string “com.apple.security.device.bluetooth”.
    EXAMPLE
    Key : com.apple.security.device.bluetooth
    Type : Bootlean
    Value : YES
    List of all entitlements HERE Example entitlements.plist file can be found HERE
    STEP 4: Add Usage Descriptions Certain entitlements also require a usage description. This is basically a note that the user will see when the app asks for permission to access any "sensitive user or device data" such as the microphone, camera, or bluetooth. Be sure to review the list of entitlements that require a usage description. **These go in your main Info.plist (NOT entitlements.plist)**
    EXAMPLE
    Key : NSMicrophoneUsageDescription
    Type : String
    Value : Used for pitch analysis and audio recordings
    List of all usage descriptions HERE

    PART 5 | Code Signing

    Specifics will vary based on the frameworks/extensions/externals used in your application.
    STEP 1: Codesign every .framework file
    EXAMPLE codesign -f -s "3rd Party Mac Developer Application: Company Name (XXXXXXXXXX)" ~/Desktop/APPLICATION.app/Contents/Frameworks/MaxAudioAPI.framework/versions/A --deep
    STEP 2: Codesign every .mxo file
    EXAMPLE codesign -f -s "3rd Party Mac Developer Application: Company Name (XXXXXXXXXX)" ~/Desktop/APPLICATION.app/Contents/Resources/C74/externals/mididrivers/coremidi.mxo --deep
    STEP 3: Codesign App (w/ entitlements)
    codesign -f -v -s "3rd Party Mac Developer Application: Company Name (XXXXXXXXXX)" --entitlements ~/Desktop/entitlements.plist ~/Desktop/APPLICATION.app
    STEP 4: Verify Signatures & Entitlements
    verify .app signature codesign -v ~/Desktop/APPLICATION.app
    verify .exe signature codesign -v ~/Desktop/APPLICATION.app/Contents/MacOS/APPLICATION/
    verify app entitlements codesign -d --entitlements - ~/Desktop/APPLICATION.app/
    Resource Fork Use if you receive an error message about a “resource fork" while signing. I needed to run this command, I believe it had something to do with the Max.icns file.
    xattr -lr ~/Desktop/APPLICATION.app xattr -cr ~/Desktop/APPLICATION.app

    PART 6 | Upload to App Store

    STEP 1: Build & Sign Installer Package
    productbuild --component ~/Desktop/APPLICATION.app /Applications --sign "3rd Party Mac Developer Installer: Company Name (XXXXXXXXXX)" --product ~/Desktop/APPLICATION.app/Contents/Info.plist APPLICATION.pkg
    this creates a .pkg file in your user folder /Macintosh HD/Users/username/
    Step 2: Upload .pkg to Application Loader - Open Xcode - Xcode > Open Developer Tool > Application Loader - Upload your .pkg file
    Step 3: Review Errors -> Resubmit After submitting your app package, you WILL receive errors. Let the trial and error begin!

    Please comment below if you have any questions about the process!


    • Oct 20 2018 | 11:42 pm
      Thanks, this is fantastic. You should be on the C74 payroll. bookmarked
    • Oct 21 2018 | 3:08 pm
      This is a great resource! Thanks Josh for posting it. You said that /Contents/Frameworks/libmozjs.dylib/ caused submission issues, can I assume that your standalone didn't have any javascript ?
      I have a standalone that I would like to have in the App Store but it uses a lot of javascript and I think it would require libmozjs.dylib . Has anyone successfully submitted a standalone that uses javascript to the Mac App Store ? If so any tips ?
    • Oct 21 2018 | 4:19 pm
      Well done Josh! As one of the co-authors of the original "Your Max Standalone on the Mac App Store" document that you link to above, I've been meaning to update it as SO much has changed since we originally wrote it - but you beat me to it! Very nice and comprehensive as well, great work!
      If I may though, a few corrections and suggestions though (including one for @chris_dech re: Javascript):
      Part 2, Step 1: Should definitely include info about unchecking CEF Support, Gen Support, and Include C74 Resources if they are not needed. CEF Support in particular adds a huge size to your application, and Including the C74 Resources adds a ton of work in the subsequent steps that could be minimized by not including them.
      Part 2, Step 3: Although your approach works (naming the app icon as "Max.icns"), it's a bit abnormal to have a Mac application whose bundled icon file is not named "APPNAME.icns", where APPNAME equals your app name. So best to name it appropriately, and then when building your standalone app within Max, use the appicon command in the build script.
      Part 3 I've been successful in getting the libmozjs.dylib library included by simply codesigning it in the subsequent steps. This was as recently as early this year (2018) - not sure if you tried that or whether something's changed with Apple (which is always possible!). Here's the example command I used for that recent app:
      codesign -f -s "3rd Party Mac Developer Application: Daniel Nigrin" /Users/dnigrin/Desktop/My-App.app/Contents/Frameworks/libmozjs185.dylib --entitlements /Users/dnigrin/Desktop/My-App.entitlements
      Also in general - I can't emphasize enough the importance (to minimize subsequent headaches) the removal of files you don't need from the application bundle. For example, in a later section (Part 5, Step 3), you show the need to codesign the MaxPluginScanner executable. Well, if your app doesn't use plugins (i.e. the vst~ object), you can safely remove that file and not worry about codesigning it. Same goes for lots and lots of other files - in particular are the many .mxo files within /Contents/Resources/C74/extensions/
      Part 5, Step 3: In my experience you don't need to codesign the actual entitlements.plist - that file never gets sent to Apple either.
      Part 6, Step 2: In the past I've had trouble uploading to Apple using the "built in" Application Loader. Perhaps this has been fixed now, but I found that I needed to download and use the older standalone Application Loader v3.0, available directly from Apple.
      If I spot any other things I'll be sure to mention them - and again, thanks! In addition, I've started to research the things that will be necessary for app Notarization, which will ultimately be required (optional in Mojave 10.14) even for apps outside of the App Store.... See thread I started: https://cycling74.com/forums/apple-notarizing-for-mojave-10-14-and-beyond
    • Oct 21 2018 | 8:34 pm
      Dan,
      Thanks for the feedback ( and for your original tutorial! ) I have updated the post to reflect your suggestions.
      Here is the problem I ran into with libmozjs185.dylib
      ERROR ITMS-90240: "Unsupported Architectures. Your executable contained the following disallowed architectures: '[i386 (.../Contents/Frameworks/libmozjs185.dylib)]'. New apps submitted to the Mac App Store must support 64-bit starting January 2018, and Mac app updates and existing apps must support 64-bit starting June 2018."
    • Oct 21 2018 | 8:43 pm
      Thanks Josh, and ah crap, that explains re: Javascript lib. The app that I recently submitted was an update, and it was roughly around Feb 2018 or so....
      Damn, that's important. Will now have to see if there's any way to update that library....
    • Oct 21 2018 | 8:55 pm
      Just a couple small but important details from the edits you made to your original post:
      * You wrote "To reduce file size, you may uncheck CEF Support, Gen Support, and Include C74 Resources" - but this is only true if those things aren't needed in your App! So obviously if you're using gen you'll need the Gen Support, and if you're using jweb (and maybe other objects, not sure?) you'll need CEF support.
      * You changed the part about the .icns file, but you omitted adding the appicon line within the standalone build script in Max. You don't *have* to do that, but then you do need to make a change manually in the Info.plist file, to specify the correct filename for the Icon entry...
    • Oct 22 2018 | 4:36 pm
      can you use lipo or ditto to strip i386 code from libmozjs?
    • Oct 22 2018 | 4:44 pm
      That's a good suggestion - definitely worth a try. I don't have anything to submit now but maybe someone else could take it up? I'm guessing the syntax would be:
      lipo libmozjs185.dylib -remove i386 -output libmozjs185-new.dylib
      ??
    • Oct 22 2018 | 9:39 pm
      For anyone using iCloud drive, don’t try and codesign or package build on your Desktop or in your Documents folder - you will almost certainly end up with ’Finder detritus’ issues, which will cause your package upload to fail...
    • Oct 30 2018 | 12:59 am
      Regarding libmozjs185.dylib
      lipo command works. I can't comment on whether or not this affects javascript functionality within the standalone...but it does allow the app package to be approved for submission.
      example of the command I used
      lipo /Users/username/Desktop/APPLICATION.app/Contents/Frameworks/libmozjs185.dylib -remove i386 -output /Users/username/Desktop/APPLICATION.app/Contents/Frameworks/libmozjs185.dylib
    • Oct 30 2018 | 2:36 pm
      Good to know, thanks for reporting!