Are you familiar with iOS development environment and interested to learn more while helping the project?
How to build the iOS app:
You will need
A developer program enrollment
You will need an Apple ID that is a member of the Apple Developer program, as Collabora iOS relies on Fonts and iCloud capabilities, which are only available to accounts in the developer platform
If you don’t have an account in the developer program, you can enroll on Apple’s developer program website. If you are developing Collabora iOS for work your employer may be able to add you to a development team
A Mac
You will need a Mac with Xcode installed
An iOS or iPadOS device
Collabora Office cannot run in a simulator because the LibreOfficeKit bits are built for an iOS
target, but the simulator is iOS-simulator
. Therefore, you’ll need a real device to run this.
Building for My Mac (Designed for iPad)
on Mac Silicon will run, but it is unstable. In particular, sometimes bugs are present on Mac that are not present on a mobile device or vice-versa. We strongly suggest you build and run for a physical iOS or iPadOS device.
1) Build the LibreOfficeKit code for iOS
on a Mac
1.1) First you need to build the LibreOfficeKit code (LibreOffice core) for iOS. For the build dependencies, it is the best to install LODE, the LibreOffice Development Environment and add its bin
directory to the PATH
. Then get LibreOffice core source code and put in your autogen.input something like this:
# Comment out for production builds
--enable-debug
--enable-dbgutil
# Standard build options
--enable-werror
--enable-symbols
--with-myspell-dicts
--with-distro=LibreOfficeiOS
--with-lang=ar bg ca cs da de el en-US en-GB eo es eu fi fr gl he hr hu id is it ja ko lo nb nl oc pl pt pt-BR sq ru sk sl sv tr uk vi zh-CN zh-TW
and build “normally”. (Naturally, no unit tests will be run when cross-compiling LibreOffice.) Of course there is no requirement to use those –enable options; as a minimum, just --with-distro=LibreOfficeiOS
should work.
This will produce a large number of static archives (.a) here and there in instdir and workdir, but no app that can be run as such. (You can see a list of them in workdir/CustomTarget/ios/ios-all-static-libs.list)
2) Build COOL Dependencies
on a Mac
PYTHON MODULES, NODEJS, and HOMEBREW
2.1.1) Install the following Python modules:
/usr/bin/pip3 install polib
/usr/bin/pip3 install lxml
2.1.2) Install nodejs version 20.15.1 by downloading the macOS .pkg from the Prebuilt installer
tab at https://nodejs.org/en/download. Note: nodejs versions newer than 20.15.1 will cause the iOS build to fail in the node-canvas package. This package provides npm
and node
commands that are required to build everything in browser/
folder.
2.1.3) Install Homebrew from https://github.com/Homebrew/brew/releases/latest (macOS pkg) and add /opt/homebrew/bin and /opt/homebrew/sbin to the end of your PATH.
2.1.4) Install the following Homebrew modules:
brew install pkg-config
brew install pixman
brew install cairo
brew install pango
brew install giflib
These modules are required to build canvas
node module. On Intel based Macs the build system pulls a binary from GitHub, therefore building from source is only required on M1/M2 Macs.
POCO LIBRARY
2.2.1) The below instructions are for the so-called basic edition of the POCO library. Download the source code from https://pocoproject.org/download.html:
2.2.2) Compile. Note: the second and third commands force the path to load /usr/bin/python3 and /usr/bin/libtool and the second command sets the minimum iOS version to match the LibreOffice build:
./configure --config=iPhone --static --no-tests --no-samples \
--omit=ActiveRecord,Crypto,NetSSL_OpenSSL,Zip,Data,Data/SQLite,Data/ODBC,Data/MySQL,MongoDB,PDF,CppParser,PageCompiler,JWT,Prometheus,Redis \
--prefix=$HOME/poco-ios-arm64
PATH="/usr/bin:$PATH" make POCO_TARGET_OSARCH=arm64 IPHONE_SDK_VERSION_MIN=14.5 -s -j4
PATH="/usr/bin:$PATH" make POCO_TARGET_OSARCH=arm64 install
This will install the poco static libraries and headers to your $HOME directory into poco-ios-arm64 directory. You can change the directory to your wishes, but by installing it this way into a directory in $HOME
it doesn’t pollute your root directories, doesn’t need root permissions and can be removed easily.
ZSTD LIBRARY
2.3.1) The below instructions are for the so-called basic edition of the ZSTD library. Download the source code from https://github.com/facebook/zstd/releases.
Alternatively you can use the helper script to build libzstd for iOS: https://github.com/CollaboraOnline/online/blob/master/scripts/build-zstd-ios.sh
2.3.2) Compile. Note: in the first command, force SDK to iOS and set the minimum iOS version to match the LibreOffice build:
CC="/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -target arm64-apple-ios14.5" make
make DESTDIR=$HOME/zstd-ios-arm64 install
Important: the following command deletes any shared libraries that may have been installed in the previous command. This is important because recent versions of Xcode will link to a dynamic library if it exists in the same folder as a static library and our iOS app will not run if it is linked to any non-system dynamic libraries:
find "$HOME/zstd-ios-arm64" -name "*.dylib*" -exec rm {} \;
This will install the zstd static libraries and headers to your $HOME directory into zstd-ios-arm64 directory. You can change the directory to your wishes, but by installing it this way into a directory in $HOME
it doesn’t pollute your root directories, doesn’t need root permissions and can be removed easily.
3) Build the iOS app
on a Mac
3.1) Do a separate clone of the Collabora Online repo on macOS.
Run autogen.sh, and configure it with the –enable-iosapp option:
./autogen.sh
./configure \
--enable-iosapp \
--with-app-name="My Own Mobile Office Suite" \
--enable-experimental \
--with-vendor="MyOwnApp" \
--with-poco-includes=$HOME/poco-ios-arm64/include \
--with-poco-libs=$HOME/poco-ios-arm64/lib \
--with-zstd-includes=$HOME/zstd-ios-arm64/usr/local/include \
--with-zstd-libs=$HOME/zstd-ios-arm64/usr/local/lib \
--with-lo-builddir=/path/to/libreoffice/core
Then run:
(cd browser && make)
The configure script puts the app name as the CFBundleDisplayName
property into the ios/Mobile/Info.plist
file, and sets up some symbolic links that point to the LibreOffice core source and build directories (which typically will be the same, of course).
3.2) Before opening the Xcode project for the first time
- seriously consider disabling source code indexing, this spawns a vast number of git processes, and consumes huge amounts of CPU & memory:
Xcode -> Preferences, "Source Control", uncheck "Enable Source Control"
3.3) Now you can open the Mobile Xcode project. Important: you will still need to do some configuration before you can run the iOS app. Xcode is very restrictive and requires the following:
- Xcode must be signed into an Apple ID that is a member of the Apple Developer Program
- In the Xcode project’s Signing & Capabilities panel, you must change the Bundle Identifier to a unique bundle ID. To obtain a unique bundle ID, login to your Apple Developer account at https://developer.apple.com and create a unique bundle ID in the Certificates, Identifiers & Profiles page. Be sure to check the Fonts and iCloud options in the Capabilities section. A screen snapshot of a sample unique build ID configuration is here: https://collaboraonline.github.io/images/build-code-ios-bundle-ID-config.png
3.4) Now you can open the Mobile Xcode project, build it, and run it. Note: building for “My Mac (Designed for iPad)” on Mac Silicon will run, but it is unstable. Also, you can’t run in an emulator since LibreOffice for iOS is built for arm64 only. So, effectively, you can only test the build on a real iOS device.
Edit page