diff --git a/Distribution/MacOSX.hs b/Distribution/MacOSX.hs
--- a/Distribution/MacOSX.hs
+++ b/Distribution/MacOSX.hs
@@ -1,22 +1,23 @@
 {-# LANGUAGE OverloadedStrings #-}
-{- | Cabal support for creating Mac OSX application bundles.
+  {- | Cabal support for creating Mac OSX application bundles.
 
-GUI applications on Mac OSX should be run as application /bundles/;
-these wrap an executable in a particular directory structure which can
-also carry resources such as icons, program metadata, images, other
-binaries, and copies of shared libraries.
+  GUI applications on Mac OSX should be run as application /bundles/;
+  these wrap an executable in a particular directory structure which can
+  also carry resources such as icons, program metadata, images, other
+  binaries, and copies of shared libraries.
 
-This module provides a Cabal post-build hook for creating such
-application bundles, and controlling their contents.
+  This module provides a Cabal post-build hook for creating such
+  application bundles, and controlling their contents.
 
-For more information about OSX application bundles, look for the
-/Bundle Programming Guide/ on the /Apple Developer Connection/
-website, <http://developer.apple.com/>.
+  For more information about OSX application bundles, look for the
+  /Bundle Programming Guide/ on the /Apple Developer Connection/
+  website, <http://developer.apple.com/>.
 
--}
+  -}
 
 module Distribution.MacOSX (
-  appBundleBuildHook, appBundleInstallHook,
+  appBundleBuildHook,
+  appBundleInstallHook,
   makeAppBundle,
   MacApp(..),
   ChaseDeps(..),
@@ -26,15 +27,14 @@
 
 import Control.Exception
 import Prelude hiding ( catch )
-import Control.Monad (forM_, when, filterM)
+import Control.Monad (forM_, when)
 import Data.List ( isPrefixOf )
 import Data.Text ( Text )
 import System.Cmd (system)
 import System.Exit
 import System.FilePath
 import System.Info (os)
-import System.Directory (copyFile, createDirectoryIfMissing, doesDirectoryExist,
-                         getHomeDirectory)
+import System.Directory (copyFile, createDirectoryIfMissing, getHomeDirectory)
 import qualified Data.Text as T
 import qualified Data.Text.IO as T
 
@@ -49,6 +49,7 @@
 import Distribution.Simple.Utils (installDirectoryContents, installExecutableFile)
 import Distribution.Verbosity (normal)
 
+import Distribution.MacOSX.Internal
 import Distribution.MacOSX.AppBuildInfo
 import Distribution.MacOSX.Common
 import Distribution.MacOSX.Dependencies
@@ -229,37 +230,6 @@
          copyFile icPath $
                   appPath </> "Contents/Resources" </> takeFileName icPath
     Nothing -> return ()
-
--- | Perform various magical OS X incantations for turning the app
--- directory into a bundle proper.
-osxIncantations ::
-  FilePath -- ^ Path to application bundle root.
-  -> MacApp -> IO ()
-osxIncantations appPath app =
-  do dtools <- developerTools
-     let rez     = dtools </> "Rez"
-         setFile = dtools </> "SetFile"
-     putStrLn "Running Rez, etc."
-     ExitSuccess <- system $ rez ++ " Carbon.r -o " ++
-       appPath </> pathInApp app (appName app)
-     writeFile (appPath </> "PkgInfo") "APPL????"
-     -- Tell Finder about the icon.
-     ExitSuccess <- system $ setFile ++ " -a C " ++ appPath </> "Contents"
-     return ()
-
--- | Path to the developer tools directory, if one exists
-developerTools :: IO FilePath
-developerTools =
-   do ds <- filterM doesDirectoryExist cands
-      case ds of
-        [] -> do putStrLn $ "Can't find the developer tools directory. Have you installed the Developer tools?\n"
-                            ++ "I tried looking for:\n" ++ unlines (map ("* " ++) cands)
-                 exitWith (ExitFailure 1)
-        (d:_) -> return d
-  where
-    cands = [ "/Applications/XCode.app/Contents/Developer/Tools"
-            , "/Developer/Tools"
-            ]
 
 -- | Default plist template, based on that in macosx-app from wx (but
 -- with version stuff removed).
diff --git a/Distribution/MacOSX/Internal.hs b/Distribution/MacOSX/Internal.hs
new file mode 100644
--- /dev/null
+++ b/Distribution/MacOSX/Internal.hs
@@ -0,0 +1,72 @@
+{-# LANGUAGE OverloadedStrings #-}
+{- | Cabal support for creating Mac OSX application bundles.
+
+GUI applications on Mac OSX should be run as application /bundles/;
+these wrap an executable in a particular directory structure which can
+also carry resources such as icons, program metadata, images, other
+binaries, and copies of shared libraries.
+
+This module provides a Cabal post-build hook for creating such
+application bundles, and controlling their contents.
+
+For more information about OSX application bundles, look for the
+/Bundle Programming Guide/ on the /Apple Developer Connection/
+website, <http://developer.apple.com/>.
+
+-}
+
+module Distribution.MacOSX.Internal (
+  osxIncantations
+) where
+
+import Control.Exception
+import Prelude hiding ( catch )
+import System.Cmd ( system )
+import System.Exit
+import System.FilePath
+import Control.Monad (filterM)
+import System.Directory (doesDirectoryExist)
+
+import Distribution.MacOSX.Common
+
+-- | Perform various magical OS X incantations for turning the app
+-- directory into a bundle proper.
+osxIncantations ::
+  FilePath -- ^ Path to application bundle root.
+  -> MacApp -> IO ()
+osxIncantations appPath app =
+  do dtools <- developerTools
+
+     let rezExec = dtools </> "Rez Carbon.r -o " ++ appPath </> pathInApp app (appName app)
+     runCommand rezExec
+
+     writeFile (appPath </> "PkgInfo") "APPL????"
+
+     -- Tell Finder about the icon.
+     let setFileExec = dtools </> "SetFile -a C " ++ appPath </> "Contents"
+     runCommand setFileExec
+
+     return ()
+
+runCommand :: String -> IO ()
+runCommand commandExec =
+  do putStrLn $ "Running: " ++ commandExec
+     exitValue <- system commandExec
+     case exitValue of
+        ExitSuccess -> return ()
+        _ -> putStrLn $ "Warning - Could not run the command \""
+                        ++ commandExec ++ "\". Please check your local `XCode` configuration."
+
+-- | Path to the developer tools directory, if one exists
+developerTools :: IO FilePath
+developerTools =
+   do ds <- filterM doesDirectoryExist cands
+      case ds of
+        [] -> do putStrLn $ "Can't find the developer tools directory. Have you installed the Developer tools?\n"
+                            ++ "I tried looking for:\n" ++ unlines (map ("* " ++) cands)
+                 exitWith (ExitFailure 1)
+        (d:_) -> return d
+  where
+    cands = [ "/Applications/XCode.app/Contents/Developer/Tools"
+            , "/Developer/Tools"
+            ]
diff --git a/cabal-macosx.cabal b/cabal-macosx.cabal
--- a/cabal-macosx.cabal
+++ b/cabal-macosx.cabal
@@ -1,5 +1,5 @@
 Name:                   cabal-macosx
-Version:                0.2.3.1
+Version:                0.2.3.2
 Stability:              Alpha
 Synopsis:               Cabal support for creating Mac OSX application bundles.
 Description:
@@ -24,25 +24,48 @@
 Maintainer:             Daniele Francesconi <dfrancesconi12@gmail.com>
 Homepage:               http://github.com/danfran/cabal-macosx
 Build-Type:             Simple
-Cabal-Version:          >=1.6
+Cabal-Version:          >=1.8
 
 Source-Repository head
     Type:         git
     Location:     http://github.com/danfran/cabal-macosx
 
 Library
-  Build-Depends:   base >= 4 && < 5, Cabal >= 1.6, directory
-               ,   fgl >= 5.4.2.2 && < 5.6
-               ,   filepath, parsec, process, text
-  Exposed-modules: Distribution.MacOSX
-  Other-modules:   Distribution.MacOSX.Common,
-                   Distribution.MacOSX.AppBuildInfo,
-                   Distribution.MacOSX.Dependencies,
-                   Distribution.MacOSX.DG
-  ghc-options:     -fwarn-tabs -Wall
+  Build-Depends:    base >= 4 && < 5
+                    , Cabal >= 1.6, directory
+                    , fgl >= 5.4.2.2 && < 5.6
+                    , filepath
+                    , parsec
+                    , process
+                    , text
+  Exposed-modules:  Distribution.MacOSX,
+                    Distribution.MacOSX.Internal,
+                    Distribution.MacOSX.Common
+  Other-modules:    Distribution.MacOSX.AppBuildInfo,
+                    Distribution.MacOSX.Dependencies,
+                    Distribution.MacOSX.DG
+  ghc-options:      -fwarn-tabs -Wall
 
 Executable macosx-app
-  Main-is:         macosx-app.hs
-  Build-Depends:   base >= 4 && < 5, Cabal >= 1.6, directory
-               ,   fgl >= 5.4.2.2 && < 5.6
-               ,   filepath, parsec, process, text
+  Main-is:          macosx-app.hs
+  Build-Depends:    base >= 4 && < 5
+                    , Cabal >= 1.6
+                    , directory
+                    , fgl >= 5.4.2.2 && < 5.6
+                    , filepath
+                    , parsec
+                    , process
+                    , text
+
+test-suite tests
+  ghc-options:      -Wall
+  hs-source-dirs:   tests
+  Main-is:          Main.hs
+  Type:             exitcode-stdio-1.0
+  Other-modules:    Distribution.MacOSX.Internal.Tests
+  Build-depends:    base >= 4 && < 4.9
+                    , HUnit >= 1.2 && < 1.4
+                    , cabal-macosx
+                    , test-framework == 0.8.*
+                    , test-framework-hunit == 0.3.*
+                    , temporary
diff --git a/tests/Distribution/MacOSX/Internal/Tests.hs b/tests/Distribution/MacOSX/Internal/Tests.hs
new file mode 100644
--- /dev/null
+++ b/tests/Distribution/MacOSX/Internal/Tests.hs
@@ -0,0 +1,28 @@
+module Distribution.MacOSX.Internal.Tests where
+
+import Test.HUnit (Assertion, assertEqual)
+import Test.Framework (Test, mutuallyExclusive, testGroup)
+import Test.Framework.Providers.HUnit (testCase)
+import Distribution.MacOSX.Internal (osxIncantations)
+import Distribution.MacOSX.Common
+import System.IO.Temp (withSystemTempDirectory)
+import Control.Exception
+
+macosxInternalTests :: Test
+macosxInternalTests = testGroup "Distribution.MacOSX.Internal"
+    [ mutuallyExclusive $ testGroup "MacOSX Internal"
+        [ testOsxIncantations
+        ]
+    ]
+
+testOsxIncantations :: Test
+testOsxIncantations = testCase "should not throw any exception even if Xcode's Carbon Tools fail to run" testCarbonTools
+  where
+    testCarbonTools :: Assertion
+    testCarbonTools = do
+        let macApp = MacApp "DummyApp" Nothing Nothing [] [] DoNotChase
+
+        withSystemTempDirectory "DummyAppPath" $ \tmpDir
+            -> osxIncantations tmpDir macApp
+
+        return ()
diff --git a/tests/Main.hs b/tests/Main.hs
new file mode 100644
--- /dev/null
+++ b/tests/Main.hs
@@ -0,0 +1,9 @@
+module Main (main) where
+
+import Test.Framework (defaultMain)
+import Distribution.MacOSX.Internal.Tests (macosxInternalTests)
+
+main :: IO ()
+main = defaultMain
+  [ macosxInternalTests
+  ]
