diff --git a/packages/darwin_app/embed-MacOSX-dependencies.sh b/packages/darwin_app/embed-MacOSX-dependencies.sh
index 8a146d318035c8b1b5572b9932d6ff3192a78b94..7109c97349b8c75d031c742e1c0879caf99c63bf 100755
--- a/packages/darwin_app/embed-MacOSX-dependencies.sh
+++ b/packages/darwin_app/embed-MacOSX-dependencies.sh
@@ -52,6 +52,8 @@ for pd_darwin in `find $PD_APP_CONTENTS -name '*.pd_darwin'`; do
 done
 
 # check for .so plugins used by libquicktime and others
+rm -rf $PD_APP_PLUGINS/libquicktime
+test -d ${optlocal}/libquicktime/lib/libquicktime && cp -r ${optlocal}/libquicktime/lib/libquicktime $PD_APP_PLUGINS || true
 for so in $PD_APP_PLUGINS/*/*.so; do
 	LIBS=`otool -L $so | sed -n 's|.*'"${optlocal}"'/\(.*\.dylib\).*|\1|p'`
 	if [ "x$LIBS" != "x" ]; then
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index 0fb8cc06556a53053ba314b961296393bee3221e..8b2abb0dbc395e40e44fc44bb7ebeee34eab2f53 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -389,6 +389,17 @@ int sys_main(int argc, char **argv)
 #ifndef MSW
     if (!noprefs)
         sys_rcfile();                           /* parse the startup file */
+#endif
+#ifdef __APPLE__
+    // Initialize libquicktime for Gem, so that it finds its plugins.
+    char *plugins = strdup(argv[0]), *t = strstr(plugins, "/Contents");
+    if (t) {
+      strncpy(t, "/Contents/Plugins/libquicktime", strlen(t));
+      fprintf(stderr, "LIBQUICKTIME_PLUGIN_DIR = %s\n", plugins);
+      // We don't override an existing value here, since the user may have
+      // already set up her own libquicktime plugin collection.
+      setenv("LIBQUICKTIME_PLUGIN_DIR", plugins, 0);
+    }
 #endif
     if (sys_argparse(argc-1, argv+1))           /* parse cmd line */
         return (1);