You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
pd-manual-preview/x6-a.htm

250 lines
9.1 KiB

<!DOCTYPE html>
<HTML lang="en">
<HEAD>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<TITLE>Pd Manual 6</TITLE>
<meta http-equiv="Content-Type" content="text/html">
<link rel="stylesheet" type="text/css" href="pdmanual.css" media="screen">
<link rel="icon" type="image/png" href="favicon.ico">
</HEAD>
<BODY>
<div class="butt">
</div>
<div id=corpus>
<p><a class=green href="x6.htm#more-mac" >back to ch6</a> <a href="index.htm#s6"> back to table of contents </a></p>
<h3 id="s6.4.1">6.4.1 macOS resources</h3>
<p>Directory pure-data/mac contains support files for building a Pure Data macOS application
bundle and supplementary build scripts for compiling Pd on Macintosh systems, as
it is built for the &lsquo;vanilla&rsquo; releases on msp.ucsd.edu.</p>
<h3 id="Pd.macOS.app">Pd macOS app</h3>
<p>In a nutshell, a monolithic macOS &ldquo;application&rdquo; is simply a directory structure
treated as a single object by the OS. Inside this bundle are the compiled
binaries, resource files, and contextual information. You can look inside any
application by either navigating inside it from the commandline or by
right-clicking on it in Finder and choosing &ldquo;Show Package Contents.&rdquo;</p>
<p>The basic layout is:</p>
<pre>Pd-0.47-1.app/Contents
Info.plist &lt;- contextual info: version string, get info string, etc
/Frameworks &lt;- embedded Tcl/Tk frameworks (optional)
/MacOS/Pd &lt;- renamed Wish bundle launcher
/Resources
/bin &lt;- pd binaries
/doc &lt;- built in docs &amp; help files
/extra &lt;- core externals
/font &lt;- included fonts
/po &lt;- text translation files
/src &lt;- Pd source header files
/tcl &lt;- Pd GUI scripts</pre>
<p>The Pure Data GUI utilizes the Tk windowing shell aka &ldquo;Wish&rdquo; at runtime.
Creating a Pure Data .app involves using a precompiled Wish.app as a wrapper
by copying the Pd binaries and resources inside of it.</p>
<h3 id="App.Bundle.Helpers">App Bundle Helpers</h3>
<ul>
<li>osx-app.sh: creates a Pd .app bundle for macOS using a Tk Wish.app wrapper</li>
<li>tcltk-wish.sh: downloads and builds a Tcl/Tk Wish.app for macOS</li>
</ul>
<p>These scripts complement the autotools build system described in INSTALL.txt and
are meant to be run after Pd is configured and built. The following usage, for
example, downloads and builds a 32 bit Tk 8.6.6 Wish.app which is used to create
a macOS Pd-0.47-1.app:</p>
<pre>mac/tcltk-wish.sh --arch i386 8.6.6
mac/osx-app.sh --wish Wish-8.6.6.app 0.47-1
</pre>
<p>Both osx-app.sh &amp; tcltck-wish.sh have extensive help output using the &ndash;help
commandline option:</p>
<pre>mac/osx-app.sh --help
mac/tcltk-wish.sh --help
</pre>
<p>The osx-app.sh script automates building the Pd .app bundle and is used in the
&ldquo;make app&rdquo; makefile target. This default action can be invoked manually after
Pd is built:</p>
<pre>mac/osx-app.sh 0.47-1
</pre>
<p>This builds a &ldquo;Pd-0.47-1.app&rdquo; using the included Wish. If you omit the version
argument, a &ldquo;Pd.app&rdquo; is built. The version argument is only used as a suffix to
the file name and contextual version info is pulled from configure script
output.</p>
<p>A pre-built universal (32/64 bit) Tk 8.6.10 Wish with patches applied is
included with the Pd source distribution and works across the majority of macOS
versions up to 10.15. This is the default Wish.app when using osx-app.sh. If you
want to use a different Wish.app (a newer version, a custom build, a system
version), you can specify the donor via commandline options, for example:</p>
<pre># build Pd-0.47-1.app using Tk 8.6 installed to the system
mac/osx-app.sh --system-tk 8.6 0.47-1
</pre>
<p>If you want Pd to use a newer version of Tcl/Tk, but do not want to install to
it to your system, you can build Tcl/Tk as embedded frameworks inside of the Pd
.app bundle. This has the advantage of portability to other systems.</p>
<p>The tcltk-wish.sh script automates building a Wish.app with embedded Tcl/Tk,
either from the release distributions or from a git clone:</p>
<pre># build Wish-8.6.6.app with embedded Tcl/Tk 8.6.6
mac/tcltk-wish.sh 8.6.6
# build Wish-master-git.app from the latest Tcl/Tk master branch from git
mac/tcltk-wish.sh --git master-git
</pre>
<p>You can also specify which architectures to build (32 bit, 64 bit, or both):</p>
<pre># build 32 bit Wish-8.6.6.app with embedded Tcl/Tk 8.6.6
mac/tcltk-wish.sh --arch i386 8.6.6
# build universal (32 &amp; 64 bit)
mac/tcltk-wish.sh --universal 8.6.6
</pre>
<p>Once your custom Wish.app is built, you can use it as the .app source for
osx-app.sh with the -w/&ndash;wish option:</p>
<pre># build Pd with a custom Tcl/Tk 8.6.6 Wish
mac/osx-app.sh -w Wish-8.6.6.app
</pre>
<p>Downloading and building Tcl/Tk takes some time. If you are doing lots of builds
of Pd and/or are experimenting with different versions of Tcl/Tk, building the
embedded Wish.apps you need with tcltk-wish.sh can save you some time as they
can be reused when (re)making the Pd .app bundle.</p>
<p>Usually, it&rsquo;s best to use stable releases of Tcl/Tk. However, there are times
when building from the current development version is useful. For instance,
if there is a bug in the Tcl/Tk sources and the generated Wish.app crashes on
your system, you can then see if there is a fix for this in the Tcl/Tk
development version on GitHub. If so, then you can test by using the
tcltk-wish.sh &ndash;git commandline option. Oftentimes, these kinds of issues will
appear with a newer version of macOS before they have been fixed by the open
source community.</p>
<p>Additionally, Pd uses an older version of Tcl/Tk for backwards compatibility on
macOS. As such, small bugfixes from newer versions may need to be backported for
the Pd GUI. Currently, this is handled in the tcltk-wish.sh script by applying
custom patches to either the Tcl and/or Tk source trees. To skip applying
patches, use the tcltk-wish.sh &ndash;no-patches commandline option. See
mac/patches/README.txt for more info.</p>
<h3 id="Supplementary.Build.Scripts">Supplementary Build Scripts</h3>
<ul>
<li>build-macosx: builds a 32 bit Pd .app bundle using src/makefile.mac</li>
<li>build-mac64: builds a 64 bit Pd .app bundle using src/makefile.mac</li>
</ul>
<p>These scripts automate building Pd with the fallback makefiles in the src
directory.</p>
<p>To build a 32 bit Pd, copy this &ldquo;mac&rdquo; directory somewhere like ~/mac. Also copy
a source tarball there, such as pd-0.47-1.src.tar.gz. Then cd to ~/mac and type:</p>
<pre>./build-macosx 0.47-1
</pre>
<p>If all goes well, you&rsquo;ll soon see a new app appear named Pd-0.47-1.app.</p>
<p>If you want to build a 64 bit Pd, perform the same steps and use the build-mac64
script:</p>
<pre>./build-mac64 0.47-1
</pre>
<p>Note: The &ldquo;wish-shell.tgz&rdquo; is an archive of this app I found on my mac:
/System/Library/Frameworks/Tk.framework/Versions/8.4/Resources/Wish Shell.app</p>
<p>A smarter version of the scripts ought to be able to find that file
automatically on your system so I wouldn&rsquo;t have to include it here.</p>
<h3 id="Preferences">Preferences</h3>
<p>The Pure Data preferences are saved in the macOS &ldquo;defaults&rdquo; preference system
using the following domains:</p>
<ul>
<li>org.puredata.pd: core settings (audio devices, search paths, etc)</li>
<li>org.puredata.pd.pd-gui: GUI settings (recent files, last opened location, etc)</li>
</ul>
<p>The files themselves live in your user home folder and use the .plist extension:</p>
<pre>~/Library/Preferences/org.puredata.pd.plist
~/Library/Preferences/org.puredata.pd.pd-gui.plist
</pre>
<p>These files use the Apple Property List XML format and shouldn&rsquo;t be edited
directly. You can look inside, edit, and/or delete these using the &ldquo;defaults&rdquo;
commandline utility in Terminal:</p>
<pre># print the contents of the core settings
defaults read org.puredata.pd
# delete the current GUI settings
defaults delete org.puredata.pd.pd-gui
# set the startup flag in the core settings
defaults write org.puredata.pd -array-add flags '-lib Gem'
</pre>
<p>Some important per-application settings required by the GUI include:</p>
<ul>
<li>NSRecentDocuments: string array, list of recently opened files</li>
<li>NSQuitAlwaysKeepsWindows: false, disables default 10.7+ window state saving</li>
<li>ApplePressAndHoldEnabled: false, disables character compose popup,
enables key repeat for all keys</li>
</ul>
<p>These are set in tcl/pd_guiprefs.tcl.</p>
<h3 id="Code.Signing">Code Signing</h3>
<p>As of Pd 0.51, the mac/osx-app.sh script performs &ldquo;ad-hoc code signing&rdquo; in order
to set entitlements to open un-validated dynamic libraries on macOS 10.15+. This
is required due to the new security settings. Note: ad-hoc signing doesn&rsquo;t
actually sign the .app bundle with an account certificate, so the unidentified
developer warning is still shown when the downloaded .app is run for the first
time.</p>
</br>
<p><a class=green href="x6.htm#more-mac" >back to ch6</a> <a href="index.htm#s6"> back to table of contents </a></p>
</br>
</br>
</br>
</div>
</BODY>
</HTML>