Skip to content

SHORTTUTORIAL: Mac Modding HowTo

Roxx Ploxx edited this page Jun 10, 2020 · 8 revisions

Macs can modify XML readily but are severely limited in modding RimWorld because there is not a development environment that supports .Net 3.5 (MonoDev/Xamarin Studio dropped support). That should not limit you. I don't claim to know the best way to do this, but here is what I do. Looking for help if you know it.

Before you start...

  • Here's how to manually install mods.
  • RimWorld Steam Installation Directories:
    • Save Files: ~/Library/Application Support/RimWorld/Saves
    • Manually Installed Mods Directory : ~/Library/Application Support/Steam/steamapps/common/RimWorld/RimWorldMac.app/Mods
    • Steam Workshop Mod Storage: ~/Library/Application Support/Steam/steamapps/workshop/content/294100
      • Note: I think this is a standard location. At runtime, steam loads mods from this directory.
    • Message, Error and Warning Logs: ~/Library/Logs/Unity/Player.log

How I Mod on a Mac

  • Create a directory (referred to as $ModHome), structured to hold all your code and notes for your new Mod.
/$ModHome
  |--- Makefile
  |--- /MyModName - a directory that follows the [default mod structure](http://rimworldwiki.com/wiki/Modding)
  |--- /MyOtherModName- etc.
  |--- /Images - my working directory for textures (Gimp, Photoshop, etc)
  |--- /RimWorldSrc - Where I placed my disassembled RimWorld code
  \--- /Releases - Where I archive releases that I put into Github
  • Note that I add a Hidden directory to my MyModName folder to store things like planning documents and raw image files. These won't be copied by the makefile below as part of the local module folder.
  • Get running: Microsoft Visual Studio and ILSpy by
    • Virtualize Windows 10 with
      • Microsoft Visual Studio on Windows 10 with VirtualBox.
        • Wasn't hard to set up and Visual Studio is free now.
      • In Windows 10, decompile the source code so you can read it: use ILSpy
      • In Mac OS, Share the $ModHome directory via the VirtualBox 'Shared Folders' configuration. It shows up as drive e: for me in Windows 10.
    • Now you can natively develop on a Mac
      • Download Visual Studio for Mac
      • Decompile the RimWorld src: use ILSpy - NOTE: I never could get ILSpy to work on a Mac. I virtualized it on Windows and did a decompile.
  • In Mac OS, set up the Makefile to automate tasks:
RIMWORLDAPPHOME=$(HOME)/Library/Application\ Support/Steam/steamapps/common/RimWorld/RimWorldMac.app
MODSDIR=$(RIMWORLDAPPHOME)/Mods
ASSEMBLYDLL=$(RIMWORLDAPPHOME)/Contents/Resources/Data/Managed/Assembly-CSharp.dll

LOGFILE=$(HOME)/code/RimWorldMods/output_log.txt
LASTLOGFILE=$(HOME)/code/RimWorldMods/output_log.last.txt

MODS=<MyModName> <MyModName2> <etc> 

.Phony : install

all:
    @echo " make 'checks', 'install', 'release' or 'run'"
    @echo

checks : 
    @echo "making $@..."
    $(shell find ./ -type f -name "*.xml" -print0 | xargs -0 xmllint --noout)
    @echo "   ...done"

install: checks $(MODS)

release: install
    @echo "making $@..."
    @zip -r ./$(MODNAME).zip "$(MODSDIR)/$(MODNAME)"
    @echo "   ...done"

run : FORCE
    @-mv $(LOGFILE) $(LASTLOGFILE) > /dev/null
    @echo "Logging to $(LOGFILE)..."
    @nohup $(RIMWORLDAPPHOME)/Contents/MacOS/RimWorldMac -quicktest -logfile $(LOGFILE)

$(MODS) : FORCE
    @echo "installing $@ Mod..."
    @make Assemblies/[email protected]
    @rm -Rf $(MODSDIR)/$@
    @mkdir $(MODSDIR)/$@
    @rsync -a $@ $(MODSDIR) \
        --exclude _old \
        --exclude $@/Source/$@/obj \
        --exclude $@/Source/$@/bin \
        --exclude $@/Source/$@/Properties \
        --exclude $@/Assemblies \
        --exclude $@/Hidden
    @mkdir $(MODSDIR)/$@/Assemblies
    @cp $@/Assemblies/[email protected] $(MODSDIR)/$@/Assemblies/.
    @echo "  created mod at: $(MODSDIR)"
    @echo "...done $@"

# Copy assemblies from Compile dir to Mod's Assemblies folder
Assemblies/%.dll :
    @echo "  copy '$(*F).dll' to Assemblies folder..."
    @cp ./$(*F)/Source/$(*F)/obj/Debug/$(*F).dll ./$(*F)/Assemblies/$(*F).dll
    @echo "  ...done, '$(*F).dll' in Assemblies"
  • When editing source code using whatever editor (Mac or Windows 10), recompile in Visual Studio (mac/win)
    • The files are shared across OSes so no reason to copy/paste anything.
  • To make a package, after changing XML or recompiling code, run the make command: make install
    • Be sure to watch the output as this runs an XML format checker to catch simple parse errors.
    • Now it is installed in the Mods directory of RimWorld.
  • Reload the Mod:
    • Restart RimWorld or 'make run' for a quick start.
    • Or, close the running game, click 'Mods' and reorder two mods that have an order that doesn't matter. It will reload all mods for you and save restarting the game. Might not work in all cases, but it's faster.
  • To reload a save game faster, create a save game that only generates 5% of the world and the smallest map possible (select advanced options when selecting a place to start your colony on the world map).