Skip to content

Instantly share code, notes, and snippets.

@akramhussein
Last active October 13, 2023 20:24
Show Gist options
  • Save akramhussein/4ef9b416e1494deaaf1b74968504e434 to your computer and use it in GitHub Desktop.
Save akramhussein/4ef9b416e1494deaaf1b74968504e434 to your computer and use it in GitHub Desktop.
Installing SPM12 on Apple Silicon (macOS)

Instructions

These instructions are for installing and running SPM12 (standalone) on macOS with Apple Silicon.

Installation

SPM12

  1. Download SPM12 (standalone) here

  2. After downloading, unzip spm12_r7771_macOS64_R2023b.zip

  3. Copy the folder spm12 to Applications as you would a normal application.

Matlab Runtime 2023b

  1. Download Matlab Runtime R2023b for macOS (macA64) here

  2. After downloading, Open the .dmg file and double-click InstallForMacOSAppleSilicon and follow the instructions

  3. After the installation is completed, you will be asked to download Java 8 (see above)

Java 8

  1. Download Java Runtime 8 (Amazon Corretto) here

  2. After downloading, double-click amazon-corretto-8.382.05.1-macosx-aarch64.pkg and follow the instructions to install.

Running SPM12

  1. Open Terminal.app by going to /System/Applications/Utilities/Terminal.app or using Spotlight to search for it (⌘ + spacebar)

  2. Paste the following command and press enter xcattr -cr /Applications/spm12

  3. Paste the following command and press enter cd /Applications/spm12/spm12.app && run_spm12.sh /Applications/MATLAB/MATLAB_Compiler_Runtime/v713/

  4. You will likely be told the application is not verified and may need to go to System Settings > Privacy & Security then scroll down and see if it's asking you to Open Anyway. See here and read "If you want to open an app that hasn’t been notarized or is from an unidentified developer" for more details of why this is required

Extra: Simplify running SPM12

By default your are expected to run SPM12 by opening the Terminal.app on macOS and running a command with an argument that points to the Matlab Runtime. To simplify this, you can prepare a script that can be double-clicked to automate this.

The script is a copy of the run_spm12 script that adds a few lines to hardcode the path to Matlab Runtime and then you grant permissions to be able to execute it.

Steps

  1. Click Download ZIP in top right of this website.

  2. Copy the file run_spm12.command into the same folder as spm12 (i.e. /Applications/spm12)

  3. Open Terminal.app by going to /System/Applications/Utilities/Terminal.app or using Spotlight to search for it (⌘ + spacebar)

  4. Paste the following command and press enter: chmod a+x /Applications/spm12/run_spm12.command

  5. Close Terminal

  6. You can now double-click on run_spm12.command to start SPM12.

  7. You will likely be told the application is not verified and may need to go to System Settings > Privacy & Security then scroll down and see if it's asking you to Open Anyway. See here and read "If you want to open an app that hasn’t been notarized or is from an unidentified developer" for more details of why this is required

  8. On first run it may take a while to start

#!/bin/sh
# script for execution of deployed applications
#
# Sets up the MATLAB Runtime environment for the current $ARCH and executes
# the specified command.
#
exe_name=$0
exe_dir=`dirname "$0"`
# hardcode the path to Matlan Runtime
MCRROOT="/Applications/MATLAB/MATLAB_Runtime/R2023b/"
echo ---
DYLD_LIBRARY_PATH=.:${MCRROOT}/runtime/maca64 ;
DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:${MCRROOT}/bin/maca64 ;
DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:${MCRROOT}/sys/os/maca64;
export DYLD_LIBRARY_PATH;
echo DYLD_LIBRARY_PATH is ${DYLD_LIBRARY_PATH};
shift 1
args=
while [ $# -gt 0 ]; do
token=$1
args="${args} \"${token}\""
shift
done
eval "\"${exe_dir}/spm12.app/Contents/MacOS/spm12\"" $args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment