Skip to main content

How to Compile the iOS Version

  1. First setup the development environment.

  2. Install Xcode from AppStore (Last tested 14.2)

  3. Install Xcode command-line tools

    $ xcode-select --install

    Or in case of errors try to download and install it from Apple site: https://developer.apple.com/download/all/?q=xcode.

  4. Log in into Xcode account (optional) In case if you don't have Apple Developer account. Open Xcode and go to preferences (via top menu)

    Preferences -> Accounts

    Press + button. You can log in with your AppleID (login and password from your iOS/macOS devices). Follow Xcode instructions. For OsmAnd team members: send your AppleID login, so you will be added to to developers list. When you'll get email with invite message activate it. Close Xcode.

  5. Install command-line tools- cmake, svn, cocoapods

    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    $ brew install svn
    $ brew install cmake # tested on 3.25.2, 3.19, 3.11

    # for intel
    $ sudo gem install cocoapods

    # for m1
    $ brew install cocoapods
  6. Run prepare.sh to compile Qt library and download external dependencies

    $ cd ios
    $ ./prepare.sh

    Error: Xcode not set up properly. You may need to confirm the license.... Solution: switch XcodeCommandLineTools to Xcode app, confirm the license and switch it back.

    $ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    $ sudo xcodebuild -license accept
    $ sudo xcode-select --switch /Library/Developer/CommandLineTools

    Solution 2: check if xcrun is available: /usr/bin/xcrun -find xcrun. If you've got: xcrun: error: unable to find utility "xcrun", not a developer tool or in PATH. Then open Xcode > Preferences > Locations and in field "Command Line Tools" select your command line tools "Xcode XX.X" And run $ ./prepare.sh again.

    Solution 3: If you've got error like this: CMake Error at CMakeLists.txt:1 (cmake_minimum_required): CMake 3.21.2 or higher is required. You are running version 3.11.2. Then download dmg installer from CMake web site and perfom manual instalation. And run $ ./prepare.sh again.

    https://cmake.org/download/

    Solution 4: If you've got error like this: Failed to configure 'qtbase-ios' for 'ios.simulator.clang.static', aborting.... Go to folded core/external/qtbase-ios/ and delete all folders starting with upstream. And run $ ./prepare.sh again.

  7. Open osmand.xcworkspace in Xcode

  8. First build. Set the build target to OsmAnd Maps. (Near play/stop buttons). Select as target your device or as one of iOS simulators. But don't use default 'Any iOS Device (arm64)'. Build the project (play button).

  9. Troubleshooting.

  • In case of build errors you can press in Xcode: Product -> Clean build folder
  • Close Xcode. Delete baked and binaries folders in OsmAnd directory (if it already exists).
  • Delete Xcode DerivedData folder: rm -rf ~/Library/Developer/Xcode/DerivedData
  • Check that all repositories are up to date and on correct branches.
  • Restart your computer. (Yes, it can help).
  • Then run $ ./prepare.sh and try to build the project again.
  1. Troubleshooting (m1 mac)
  • In case of ld: library not found for -lOsmAndCore_static_standalone:
  • Project Navigator -> OsmAnd_projects -> OsmAnd_projects (in Project/Targets list) -> Build settings -> All -> Architectures -> Excluded Architectures -> Debug
  • Add string field of type Any IOS Simulator SDK with value arm64. (you will need to add it after each prepare.sh run)
  • Build project. In case of errors, delete folders Baked and Binaries and run prepare.sh once again.
  1. Debug Qt (optional). If you want to see Qt values in debug mode run this:
    $ mkdir -p ~/qtlldb
    $ git clone https://github.com/gbooker/lldb-qt-formatters ~/qtlldb
    $ touch ~/.lldbinit
    $ echo "command script import ~/qtlldb/both.py" >> ~/.lldbinit
    After set this parameters reboot your computer.