Difference between revisions of "Building On Mac"

From Audacity Wiki
Jump to: navigation, search
(Instructions in mac/build.txt)
(Variations: moving old ednote to the Talk page)
Line 100: Line 100:
{{note|1=These instructions for variations on building aren't in mac/build.txt in the Git repo.}}
{{note|1=These instructions for variations on building aren't in mac/build.txt in the Git repo.}}
{{ednote|1=This is obsolete patching information.  Maintaining it as we may add focus rings etc back.
===Using wxWidgets from wxWidgets===
Rather than downloading our patched wxWidgets, you can download 3.0.2 and patch it yourself
  Apply the following fixes to wxWidgets:
  cd wxWidgets-3.0.2
  patch -p0 -i <path to Audacity source>/mac/wxMac_additions/wxMac-3.0.2-fixes.patch .
  patch -p0 -i <path to Audacity source>/mac/wxMac_additions/eventloops.patch .
  patch -p0 -i <path to Audacity source>/mac/wxMac_additions/pinch-spread.patch .
  patch -p0 -i <path to Audacity source>/mac/wxMac_additions/focusrings.patch .
  patch -p0 -i <path to Audacity source>/mac/wxMac_additions/wxMac-3.0.2-wxaccessible.patch .
  patch -p0 -i <path to Audacity source>/mac/wxMac_additions/tooldock-quit.patch .
  patch -p0 -i <path to Audacity source>/mac/wxMac_additions/fullscreen.patch .
The patches and their reasons can be found [https://github.com/audacity/wxWidgets/commits/audacity-fixes here], and there is more description about them [[For_Upstream_wxWidgets|here]] in the wiki.
===Defaulting to Portable Settings===
===Defaulting to Portable Settings===
Line 137: Line 114:
These steps should of course be done before signing.
These steps should of course be done before signing.
== Official Full Releases==
== Official Full Releases==

Revision as of 10:37, 9 February 2020

ToDo-2 Add
  • Instructions for building modules
These are instructions for building on Mac

The build family of pages:

Instructions in mac/build.txt

These instructions for building on mac are in mac/build.txt in the Git repo.
Instructions for building on macOS.

Building on macOS has been made much simpler with the Audacity 2.4.0 release. Still,
read this document throughly before starting.

1) Get and install the Xcode version that is for your macOS version. 

	MacOS	              	Xcode Version
	Catalina - 10.15	   11.3
	Mojave - 10.14		   10.3
	High Sierra - 10.13	   9.4.1
	Sierra - 10.12		   9.2
	El Capitan - 10.11	   8.2.1
	Yosemite - 10.10	   7.2.1

2) Clone wxWidgets 3.1.1

   git clone --recurse-submodules https://github.com/audacity/wxWidgets.git

   Ensure that you clone with the "--recurse-submodules" option, and do not
   just download the Zip package, otherwise there will be required components

   Don't be tempted to use Widgets already installed by a package manager such 
   as Homebrew because this will cause problems.

   We have applied some Audacity specific patches to wxWidgets to better 
   support VoiceOver, so please use the audacity-fixes-3.1.1 branch.  It's
   the default branch on our GitHub copy.

   git checkout audacity-fixes-3.1.1

3) Change directory to the folder wxWidgets was cloned to then build/install 

   sudo <path to Audacity source>/mac/scripts/build_wxwidgets

Check that this worked by looking for <path to wxWidgets>/bld_release_x86_64 
containing library .o files.  There should also be 3 other directories for
other combinations of debug/release i386/x86_64.  If this step did not work,
then later steps to build Audacity won't either.

If building wxWidgets worked, you should now be able to build Audacity 
using either the Xcode application or the Xcodebuild command line tool. 

4) Change directory to <path to Audacity source>/mac
* Optionally, if you have built before, clean the Debug build with:

  xcodebuild clean

* Or clean up other versions using some variant of:

  xcodebuild clean -configuration Release64

	'Release64' is for the 64 bit build. 'Release' is for the 32 bit build.
	'Debug64' is for 64 bit debug build, 'Debug' is for 32 bit debug build.
5) Build Audacity and create DMG and ZIP bundles in 
  /private/tmp by typing the following in the terminal:

  xcodebuild -configuration Release64 install


  - If you get errors about 'plist' at this stage, probably you skipped the step 
    of cleaning first.  

  - If you use the Xcode application, don't make any changes to Audacity.xcodeproj
    recommended by Xcode.  

  - Instructions on optional signing of DMGs, Showing languages other than English,
    and other useful information can be found on our wiki at: 

Optional Extras

Bulb icon FFmpeg and LAME

For these, see Building Extras on Mac


These instructions for variations on building aren't in mac/build.txt in the Git repo.

Defaulting to Portable Settings

 1. Within audacity.app/Contents add the directories:
    Portable Settings
    Portable Settings/AutoSave

 2. Set permissions on these two directories to 777
    chmod 777 "Portable Settings"
    chmod 777 "Portable Settings/AutoSave"

These steps should of course be done before signing.

Official Full Releases

Official Audacity full releases:

  • Have a GitIdent, visible in the about box build information, that says what branch was used in building.
  • Include a copy of the manual.
  • Include other languages.
  • Have a de-cluttered .dmg (the folders in it are dragged outside the visible area)
  • Are signed with a signing key.

Updating GitIdent

 The Audacity "About" box can contain a link to the git commit at which 
 Audacity was built. To create this, run this batch script in /mac/scripts/
 If you do this, you are responsible for making sure the ident is correct
 in future builds.  The script overwrites RevisionIdent.h in the src directory.
 If you make further changes to your local copy after this step, or merge a
 more recent version from git, this file, and hence the ident in the build, 
 stays the same, and so would be misleading.
 To reset RevisionIdent.h you could do:
   git reset --hard origin/master

Fetching The Manual

We have instructions for fetching the manual on another page.

Include mod-script-pipe

Build this within the Xcode project ON THE SAME DAY as you built audacity. You can click on the .so in the IDE to find out where Xcode put it (it will have some weird long temporary path).

Just before code signing, add it in to the Audacity bundle, into a subdirectory called 'modules'.

Include Languages

Warning icon Beware! Audacity needs a clean and then a recompile if it is to include languages.

For some reason yet to be investigated, incremental compiles will not include the language files in audacity.app.
(Check by looking inside the app and looking in 'Resources')

If you need Audacity to show languages other than English, install the gettext
suite of tools (to get the msgfmt command).  The source can be downloaded from:


Untar it:

   tar xf gettext-latest.tar.gz

And install:

   cd gexttext-latest
   sudo make install

Then clean and recompile.
Incremental compiles will NOT include the language files.

Decluttering the dmg

 1. Open the dmg

 2. Drag the right border wider.

 3. Drag all folders that should not be visible into that area.

 4. Drag right border narrower again.

Signing the DMG

 1) Comment out the last line of mac/scripts/build_dist.sh so that it reads
   #rm -rf ${DMG} TMP.dmg
   This will prevent deletion of TMP.dmg

 2) Delete any previous /private/tmp/TMP.dmg and /private/tmp/Audacity.dst
    (otherwise, the rebuilt plug-ins folder will contain an unnecessary duplicate
    of itself).

    Then clean and build Audacity normally.
 3) Navigate to /private/tmp/ and type 
    hdiutil resize -size 200m TMP.dmg
    This step is needed as codesigning takes some temporary space, more than is 
    available in the dmg.
 4) mount the dmg
    hdiutil mount TMP.dmg

 4a) Not part of the signing, but a good idea to de-clutter the dmg
    per instructions in the section above.
 5) Codesign the app (deep to make sure everything important is signed)
    codesign --deep -s <identity> -v "/Volumes/Audacity 2.2.0/Audacity.app"

    If you see errors like this, no matter what size you used in step (3):

        can't allocate code signature data for: /Volumes/Audacity 2.2.0/Audacity.app/Contents/MacOS/Audacity
        (for architecture i386) because larger updated load commands do not fit (the program must be relinked
        using a larger -headerpad value)

    Then in the XCode project, add -headerpad_max_install_names to Other Linker flags (OTHER_LDFLAGS)
    for Release configuration of the Audacity target, and go back to step (2).
 6) Check it is signed to gatekeeper's satisfaction:
    spctl -a -v "/Volumes/Audacity 2.2.0/Audacity.app"
 7) unmount the dmg

    hdiutil eject "/Volumes/Audacity 2.2.0"
 8) Make a compressed dmg
    hdiutil convert TMP.dmg -format UDZO -imagekey zlib-level=9 -o "Newname.dmg"
 9) codesign that
    codesign -s <identity> -v Newname.dmg

To test the signing, upload the dmg to dropbox and then download it again. Then double-click to install and drag across to /Applications. When you launch Audacity, you now get a warning about having downloaded from the internet, rather than being prevented from running...