Talk:Building On Mac

From Audacity Wiki
Revision as of 03:42, 11 December 2016 by Galeandrews (talk | contribs) (Put Xcode 8.1 requirements in an ednote)
Jump to: navigation, search

Current instructions in Build.txt

At this time, the newest SDK version that Audacity can build with is 10.6. 
To build Audacity using Xcode 5.1 or newer, you need to extract the 10.6 SDK
from an earlier version of Xcode.

In the instructions below, Xcode 4.3.3 (for the 10.6 SDK) and Xcode 5.1.1 will
be used.  Xcode 6.1.1, 6.3, 6.4.1, and 7.1 have also been verified to work. 
Xcode 7.2 and later require a custom build setting to accept the 10.6 SDK, or 
to edit src\MemoryX.h in the Audacity code. See this topic:
http://forum.audacityteam.org/viewtopic.php?p=303835#p303835 .

1) Download Xcode 5.1.1 or greater and install it to /Applications.
2) Download Xcode 4.3.3 (it includes the 10.6 and 10.7 SDK's despite 
   the downloads page says it only has the 10.7 SDK).
3) Open the DMG in Finder.
4) Right-click the "Xcode.app" bundle and select "Show Package Contents".
5) Navigate down the directories to get to:

   Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ .

6) Copy the MacOSX10.6.sdk folder to:

   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

   Xcode is now ready.

7) Download wxWidgets 3.0.2 fron the wxWidgets project: 
   http://sourceforge.net/projects/wxwindows/files/3.0.2/wxWidgets-3.0.2.tar.bz2 .

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

8) Once the download is complete, untar it (your browser may do this itelf):

   tar xf wxWidgets-3.0.2.tar.bz2 .

9) 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 .

10) And finally build/install wxWidgets:

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

You should now be able to build Audacity using either the Xcode application or 
the Xcodebuild command line tool. 

* Using xcodebuild, build Audacity and create DMG and ZIP bundles in 
  /private/tmp by typing the following in the terminal:

  xcodebuild -configuration Release install   

* If you use the Xcode application, don't make any changes to 
  Audacity.xcodeproj recommended by Xcode. In particular, be sure to leave the
  Base SDK configuration set to 10.6 as it is now. 

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:

   ftp://ftp.gnu.org/gnu/gettext/gettext-latest.tar.gz

Untar it:

   tar xf gettext-latest.tar.gz

And install:

   cd gexttext-latest
   ./configure
   sudo make install


Proposed New Text

Gale 11Dec16:" Just adding here that Xcode 8.1 requires minimum of OS X 10.11.5.
At this time, the newest SDK version that Audacity can build with is 10.6. 
To build Audacity using Xcode 5.1 or newer, you need to extract the 10.6 SDK
from an earlier version of Xcode.

In the instructions below, Xcode 4.3.3 (for the 10.6 SDK) and Xcode 8.1 will
be used.  Fuller instructions that cover 
   * Using other xcodes
   * Optional signing of DMGs
   * Applying wxWidgets patches one by one
can be found on our wiki at http://wiki.audacityteam.org/wiki/Building_On_Mac

1) Download Xcode 8.1 and install it to /Applications.
2) Download Xcode 4.3.3 (it includes the 10.6 and 10.7 SDK's despite 
   the downloads page says it only has the 10.7 SDK).
3) Open the DMG in Finder.
4) Right-click the "Xcode.app" bundle and select "Show Package Contents".
5) Navigate down the directories to get to:

   Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ .

6) Copy the MacOSX10.6.sdk folder to:

   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

7) Change the MinimumSDKVersion key value in 
   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist 
   to 10.6

   Xcode is now ready.

8) Download audacity patched wxWidgets 3.0.2 zip from the audacity copy of the 
   wxWidgets project: 
      https://github.com/audacity/wxWidgets/tree/audacity-fixes

   it's the green "clone or download" button on the right.

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

9) Once the download is complete, unzip it:

   unzip wxWidgets-audacity-fixes.zip

10) And finally build/install wxWidgets:

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

You should now be able to build Audacity using either the Xcode application or 
the Xcodebuild command line tool. 

* Using xcodebuild, build Audacity and create DMG and ZIP bundles in 
  /private/tmp by typing the following in the terminal:

  xcodebuild -configuration Release install   

* If you use the Xcode application, don't make any changes to 
  Audacity.xcodeproj recommended by Xcode. In particular, be sure to leave the
  Base SDK configuration set to 10.6 as it is now. 

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:

   ftp://ftp.gnu.org/gnu/gettext/gettext-latest.tar.gz

Untar it:

   tar xf gettext-latest.tar.gz

And install:

   cd gexttext-latest
   ./configure
   sudo make install


Proposed more Detailed Wiki Instructions

Using wxWidgets from wxWidgets

Rather than downloading 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 .

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) 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

5) Codesign the app (deep to make sure everything important is signed)
    
   codesign --deep -s <identity> -v "/Volumes/Audacity 2.1.3/Audacity/Audacity.app"

6) Check it is signed to gatekeeper's satisfaction:

   spctl -a -v "/Volumes/Audacity 2.1.3/Audacity/Audacity.app"

7) unmount the dmg

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 apps. When you go to run, you now get a warning about having downloaded form the internet, rather than being prevented from running...