Skip to content

II. b] Computer setup [Mac OS X]

Vresod edited this page Sep 29, 2019 · 6 revisions

Notes

The setup described on this page does not reflect the latest Windows setup, but is reasonably close.

~ is the unix way of writing your home folder. When you see ~/Documents, it means the Documents folder in your home folder. When you type ls ~/ and press enter in a console window, you'll see that it will list the folders inside of your home folder.

Install devkitpro

Install devkitpro and aemstro on your own. devkitpro download comes as a perl-based installer for the mac. You'll need the on named devkitARMupdate.pl Once download, you can run this by opening up a terminal window, typing sudo perl and dragging the .pl file on the terminal window. Then press enter. It will ask you to type your password. Type it and press enter (it will not show that you're typing). This will install the ARM bits of devkitpro into your home folder.

Prepare project folder

Make sure xcode is updated to the latest version (currently 6.2) by updating it via the app store. then decide where you want your project folder to live. I put my 3ds dev folder in Documents in my home folder so my setup looks like this: ~/Documents/3ds/testproject Inside of there make sure to at least have a source, and data folder. Then create an empty file called main.cpp or main.c, depending on which language you want to use, and save it inside of your newly created source folder.

Then download a copy of the makefile, I grabbed mine from the ctru github you can click raw and copy paste the text into a file called makefile but make sure it doesn't have a file extension like .txt (right click the file and pick get info. Change the filename and extension box if you need to). Save the makefile next to the source and data folders.

Create Xcode Project

Next up we will need to make an xcode project. Go ahead and create one. When the choose a template window comes up, go into OS X > Other > External Build System and click Next. Then name your project. the name doesn't matter much so I called mine 'a'. It will ask you where to create the project. navigate to your 3ds project folder (in my case that would be ~/Documents/3ds/testproject) and click create.

Next we will need to add the source code to the project, since our blank one doesn't know how to do anything. In the sidebar, right click the project and choose add files to <yourprojectname>. You will not be able to see your code files in the window that pops up. That's alright. Go up one folder (you can press cmd+up arrow to do this) and click your source folder, leave everything set to the defaults and continue. You will now see your source files in xcode, but you will not be able to compile anything yet.

Click the project in the sidebar and you should see a bunch of settings. Under the Info tab, set Directory to ../ Next, click the Build settings tab, and then click the + just left of the search box. pick Add User-defined setting. Create two of them. Name the first DEVKITPRO, and the second DEVKITARM. to find the values to put there, first open op a terminal window and type echo $DEVKITPRO. You can just copy paste the text it will print. then set DEVKITARM to $(DEVKITPRO)/devkitARM.

Finally, we need to change the paths Xcode uses to write compilation files to. In Xcode Preferences, go to the Locations tab, and click Advanced... on the Derived Data section. Then click Custom, and set it to Relative to Workspace.

Optional: Citra setup

Grab a copy of citra that will run your 3dsx files from the citra website. For convenience, I made a folder called citra inside of my 3ds folder that we set up earlier so that we can reference citra easily and update it to newer builds in the future simply by replacing the citra binaries. The resulting structure is as follows: ~/Documents/3ds/citra/ with the citra and citra-qt files inside of it.

Missing libpng

When I ran citra for the first time, I got some error about libpng16. Due to having tried to build citra myself in the past, I had the Brew package manager installed (but macports should work just as well) and used that to install libpng by opening up a console window and typing brew install libpng. Citra worked just fine after that.

schemes/targets

To enable xcode to clean/build/build and run, we are going to make 3 targets. It's not perfect as you still need to switch between targets if you want a specific action, but if you only use build or build and run then it's a pretty good setup.

Click the button at the top of Xcode next to the one that says My Mac and has a little target icon. Next, click manage schemes. You should see one named after your project. I renamed mine to Build. Close the panel, and click your project file in the file pane on the left. Switch to the Build Settings tab and click the Build action. We are going to add another user defined setting like we did with the DEVKITARM and DEVKITPRO ones. Name it CITRABIN. I set it's path to where I put the citra executable. So Mine is ~/Documents/3ds/citra/citra.

Switch over to the Info tab. Just to make sure, verify that the settings for Build are:

  • Build Tool: /usr/bin/make
  • Arguments: $(ACTION)
  • Directory: ../
  • Pass build settings in environment: Checked

Now Right-click your target in the pane on the left, and choose Duplicate. Change the Parameters value to clean. Rename it to Clean by clicking it on the name once.

Duplicate the first Target again, rename it BuildAndEmulate and change Arguments to run In order for the compiler to be able to pick up on file rename changes, we will need to run the clean action before the build action. To do this, we switch over to the Build Phases tab and click the Build target. Expand target Dependencies and click +, then pick Clean. In order for Build and Run/Emulate to work, we need to make sure to build before we run (build and emulate only runs the 3dsx in citra). To do this, we click the BuildAndEmulate target, and add Build to it's Target Dependencies. Note: you could make your own build that doesn't clean, or your own emulate that doesn't build here, if you wanted to. We are done with the target/scheme/actions (confusing, I know) now.

Makefile adjustments

For our new build actions to work, we will need to make some changes to our makefile, so open it up in a text/code editor. Find a section that has $(BUILD): and clean:, and paste the following code just before the #--- with the else below it.

run:	
    @$(CITRABIN) $(TARGET).3dsx

You can now switch between build and Build and Emulate using the button next to My Mac to switch the target, and automatically run Citra when you build the BuildAndEmulate target.