Open main menu

Difference between revisions of "Compiling ScummVM/iPhone"

Removes information now contained in the new docs, and adds a link to the new docs.
(Add some instructions to build with Xcode)
(Removes information now contained in the new docs, and adds a link to the new docs.)
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page explains how to compile your own version of [[ScummVM]] using the [[iPhone]] or [[[iOS7]] backend.
This page explains how to compile your own version of [[ScummVM]] for [[iOS]] based devices (iPhone/iPad). See also [[Compiling ScummVM/macOS]].  


= Using XCode =
== Using Xcode ==


You can compile ScummVM with the official tools from Apple and get it to work on your non-jailbroken iPhone or iPad.
You can compile ScummVM with the official tools from Apple. For more information, see the [https://docs.scummvm.org/en/latest/other_platforms/ios.html iOS page] in the [https://docs.scummvm.org/ user documentation].  


== Requirements ==
== Using the command line ==
You will need:
For jailbroken devices, it is also possible to compile the project from command line. You'll need a working toolchain, and some tools, like '''ldid''', to fake the code signature.
* a macOS computer
* Xcode (you can get it for free from the Mac App Store)
* A developer account. You can create one for free using your Apple ID (the same one used for iCloud or the Mac App Store) on the [https://developer.apple.com/membercenter/ Apple Developer Member Center].
* iOS libraries used by ScummVM. There is a link to a convenient package below in the build instruction.


Note: with a free developer account iOS App that you build will only be valid for 7 days and you will thus need to recompile and reinstall them each week.
Here is a script to download, and compile all the required tools. This script has been wrote for Debian 8.2, and should be run as root.
<syntaxhighlight lang="bash">
#!/bin/bash


== Creating the Xcode project ==
if [ $UID -ne 0 ]; then
Clone the ScummVM repository from GitHub to get the source code:
echo "This script should be run by the root user"
<source lang="bash">
exit 1
git clone https://github.com/scummvm/scummvm.git
fi
</source>


Generate the create_project tool:
# Install the Clang compiler
<source lang="bash">
apt-get install -y clang-3.4 libclang-3.4-dev llvm-3.4 libtool bison flex automake subversion git pkg-config wget libssl-dev uuid-dev libxml2-dev || exit 1
cd scummvm/devtools/create_project/xcode
xcodebuild
</source>


Create a build directory, extract the [https://www.scummvm.org/frs/build/scummvm-ios7-libs.zip iOS libraries package] and generate the Xcode project
# Add LLVM to the linker library path
<source lang="bash">
echo /usr/lib/llvm-3.4/lib > /etc/ld.so.conf.d/libllvm-3.4.conf
cd ../../../..
ldconfig
mkdir build
cd build
</source>


Download the [https://www.scummvm.org/frs/build/scummvm-ios7-libs.zip iOS libraries package] and extract them in the build directory:
# Add symlinks for the LLVM headers
<source lang="bash">
ln -s /usr/lib/llvm-3.4/bin/llvm-config /usr/bin/llvm-config || exit 1
unzip ~/Downloads/ScummVM-iOS-libraries.zip
ln -s /usr/include/llvm-3.4/llvm /usr/include/llvm || exit 1
</source>
ln -s /usr/include/llvm-c-3.4/llvm-c /usr/include/llvm-c || exit 1
ln -s /usr/bin/clang-3.4 /usr/bin/clang || exit 1
ln -s /usr/bin/clang++-3.4 /usr/bin/clang++ || exit 1


Generate Xcode project and open it:
# Build the linker
<source lang="bash">
svn checkout http://ios-toolchain-based-on-clang-for-linux.googlecode.com/svn/trunk/cctools-porting || exit 1
../scummvm/devtools/create_project/xcode/build/Release/create_project ../scummvm --xcode --enable-fluidsynth --disable-bink --disable-mt32emu --disable-nasm --disable-opengl --disable-theora --disable-taskbar --disable-libcurl --disable-sdlnet
cd cctools-porting
open scummvm.xcodeproj
sed -i'' 's/proz -k=20  --no-curses/wget/g' cctools-ld64.sh
</source>
./cctools-ld64.sh || exit 1


== Compile and Deploy ==
cd cctools-855-ld64-236.3
In Xcode you need to configure the scummvm project:
./autogen.sh || exit 1
* Connect your iPhone or iPad to your Mac.
./configure --prefix=/usr/local --target=arm-apple-darwin11 || exit 1
* Select your iOS device (iPhone or iPad) at the top of the window (in the title bar).
make || exit 1
* In the project ''General'' settings you need to specify a unique ''Bundle Identifier'' (for example ''org.yourname.scummvm'').
make install || exit 1
* You need to configure the ``Signing`` settings. Add an account by using your Apple ID if needed and then select it.
cd ../..


Then click on the Play button in the top left of the window to start the build. The App will be automatically installed on your device at the end of the build.
# Install ios-tools
wget https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iphonesdk-utils-2.0.tar.gz || exit 1
tar xzf iphonesdk-utils-2.0.tar.gz
cd iphonesdk-utils-2.0
patch -p0 <<_EOF
*** genLocalization2/getLocalizedStringFromFile.cpp    2015-04-02 04:45:39.309837816 +0530
--- genLocalization2/getLocalizedStringFromFile.cpp    2015-04-02 04:45:11.525700021 +0530
***************
*** 113,115 ****
      clang::HeaderSearch headerSearch(headerSearchOptions,
-                                      fileManager,
                                      *pDiagnosticsEngine,
--- 113,115 ----
      clang::HeaderSearch headerSearch(headerSearchOptions,
+                                      sourceManager,
                                      *pDiagnosticsEngine,
***************
*** 129,134 ****
                  false);
-    clang::HeaderSearch headerSearch(fileManager,
                                      *pDiagnosticsEngine,
                                      languageOptions,
-                                      pTargetInfo);
      ApplyHeaderSearchOptions(headerSearch, headerSearchOptions, languageOptions, pTargetInfo->getTriple());
--- 129,134 ----
                  false);
+    clang::HeaderSearch headerSearch(fileManager);/*,
                                      *pDiagnosticsEngine,
                                      languageOptions,
+                                      pTargetInfo);*/
      ApplyHeaderSearchOptions(headerSearch, headerSearchOptions, languageOptio
_EOF


./autogen.sh || exit 1
CC=clang CXX=clang++ ./configure --prefix=/usr/local || exit 1
make || exit 1
make install || exit 1


'''TODO:''' Add a bit more details.
# Install the iOS SDK 8.1
mkdir -p /usr/share/ios-sdk
cd /usr/share/ios-sdk
wget http://iphone.howett.net/sdks/dl/iPhoneOS8.1.sdk.tbz2 || exit 1
tar xjf iPhoneOS8.1.sdk.tbz2
rm iPhoneOS8.1.sdk.tbz2
</syntaxhighlight>


Now, in order to compile ScummVM, execute the following commands:
<syntaxhighlight lang="bash">
export SDKROOT=/usr/share/ios-sdk/iPhoneOS8.1.sdk
export CC=ios-clang
export CXX=ios-clang++
./configure --host=ios7 --disable-mt32emu --enable-release
make ios7bundle
</syntaxhighlight>


There are some outdated instructions on [http://blog.pmlabs-apps.com/scummvm-on-ios-without-jailbreak/ this blog] that may still be useful as it is illustrated and has more details.
At the end of the compilation, you'll find a '''ScummVM.app''' application: copy it over SSH, and reboot your device.
 


= Cross-Compilation =
= Cross-Compilation =
Line 89: Line 130:


* For ''iphone'' use:
* For ''iphone'' use:
<source lang="bash">
<syntaxhighlight lang="bash">
export TARGET=arm-apple-darwin9
export TARGET=arm-apple-darwin9
</source>
</syntaxhighlight>


* For ''ios7'' use:
* For ''ios7'' use:
<source lang="bash">
<syntaxhighlight lang="bash">
export TARGET=arm-apple-darwin11
export TARGET=arm-apple-darwin11
</source>
</syntaxhighlight>


==== Setting up the Environment ====
==== Setting up the Environment ====


<source lang="bash">
<syntaxhighlight lang="bash">
export PATH="$IOS_TOOLCHAIN_BASE/bin:$IOS_TOOLCHAIN_BASE/$TARGET/bin:$IOS_TOOLCHAIN_BASE/$TARGET/usr/bin:$PATH"
export PATH="$IOS_TOOLCHAIN_BASE/bin:$IOS_TOOLCHAIN_BASE/$TARGET/bin:$IOS_TOOLCHAIN_BASE/$TARGET/usr/bin:$PATH"
export CPPFLAGS="-isystem $IOS_TOOLCHAIN_BASE/$TARGET/usr/include"
export CPPFLAGS="-isystem $IOS_TOOLCHAIN_BASE/$TARGET/usr/include"
export LDFLAGS="-L$IOS_TOOLCHAIN_BASE/$TARGET/usr/lib"
export LDFLAGS="-L$IOS_TOOLCHAIN_BASE/$TARGET/usr/lib"
</source>
</syntaxhighlight>
Where ''IOS_TOOLCHAIN_BASE'' contains the directory where you installed the toolchain. And ''TRAGET'' has been setup from the previous step.
Where ''IOS_TOOLCHAIN_BASE'' contains the directory where you installed the toolchain. And ''TRAGET'' has been setup from the previous step.


Line 115: Line 156:
First, navigate to a path where you want your build files to be located (this can be the ScummVM root directory but does not have to be).
First, navigate to a path where you want your build files to be located (this can be the ScummVM root directory but does not have to be).
Then run the following:
Then run the following:
<source lang="bash">
<syntaxhighlight lang="bash">
./path/to/scummvm/configure --host=ios7 --with-staticlib-prefix=$IOS_TOOLCHAIN_BASE/$TARGET/usr
./path/to/scummvm/configure --host=ios7 --with-staticlib-prefix=$IOS_TOOLCHAIN_BASE/$TARGET/usr
</source>
</syntaxhighlight>
Replace ''ios7'' with ''iphone'' if you want to build the older version of our iOS backend.
Replace ''ios7'' with ''iphone'' if you want to build the older version of our iOS backend.


Line 123: Line 164:


You can compile ScummVM with running make:
You can compile ScummVM with running make:
<source lang="bash">
<syntaxhighlight lang="bash">
make iphone
make iphone
</source>
</syntaxhighlight>
If you simply want to test whether changes you made compile but do not plan to use the binary for deployment you can also simply run ''make''.
If you simply want to test whether changes you made compile but do not plan to use the binary for deployment you can also simply run ''make''.


Please note that if you want to deploy ScummVM on your iOS device you will need to generate a bundle file. For this run either:
Please note that if you want to deploy ScummVM on your iOS device you will need to generate a bundle file. For this run either:
<source lang="bash">
<syntaxhighlight lang="bash">
make ios7bundle
make ios7bundle
</source>
</syntaxhighlight>
for the ''ios7'' backend. Or
for the ''ios7'' backend. Or
<source lang="bash">
<syntaxhighlight lang="bash">
make iphonebundle
make iphonebundle
</source>
</syntaxhighlight>
for the ''iphone'' backend.
for the ''iphone'' backend.


Then simply upload the whole ScummVM.app directory to your device under the /Applications folder, and you're done!
Then simply upload the whole ScummVM.app directory to your device under the /Applications folder, and you're done!
442

edits