Search code examples
swiftxcodedocc

Running Xcode DocC documentation via Apache locally on macOS


Xcode 13's DocC documentation archives can be hosted using a custom Apache .htaccess file as described in Distributing Documentation to External Developers and Host and automate your DocC documentation - WWDC21.

What are the steps to get that set up for the SlothCreator example project on a macOS / a M1 Mac so you can look at the documentation in the browser?


Solution

    • Get the SlothCreator example project and build the documentation archive in Xcode or the command line as described in Distributing Documentation to External Developers

    • Install httpd via Homebrew:

      brew install httpd
      
    • Copy SlothCreator.doccarchive to /opt/homebrew/var/www/ (paths are for M1 Macs)

    • Edit /opt/homebrew/etc/httpd/httpd.conf:

      • Allow AllowOverride All for the DocumentRoot Directory

      • Enable LoadModule rewrite_module

    • Edit /opt/homebrew/var/www/.htaccess and use the example configuration as provided by Apple in Distributing Documentation to External Developers

    • Restart Apache: sudo apachectl restart

    • You should now be able to open http://localhost:8080/documentation/slothcreator/ and http://localhost:8080/tutorials/slothcreator/

    Enjoy!