1 ![Kodi Logo](resources/banner_slim.png)
4 This guide has been tested using Xcode 11.3.1 running on MacOS 10.15.2 (Catalina). Please note this combination is the only version our CI system builds. The minimum OS requirement for this version of Xcode is MacOS 10.14.4. Other combinations may work but we provide no assurances that other combinations will build correctly and run identically to Team Kodi releases. It is meant to cross-compile Kodi for tvOS 11+ (AppleTV 4/4K) using **[Kodi's unified depends build system](../tools/depends/README.md)**. Please read it in full before you proceed to familiarize yourself with the build procedure.
7 1. **[Document conventions](#1-document-conventions)**
8 2. **[Prerequisites](#2-prerequisites)**
9 3. **[Get the source code](#3-get-the-source-code)**
10 4. **[Configure and build tools and dependencies](#4-configure-and-build-tools-and-dependencies)**
11 4.1. **[Advanced Configure Options](#41-Advanced-Configure-Options)**
12 5. **[Generate Kodi Build files](#5-Generate-Kodi-Build-files)**
13 5.1. **[Generate XCode Project Files](#51-Generate-Xcode-Project-Files)**
14 5.2. **[Build with Xcode](#62-build)**
15 6. **[Build Kodi](#6-build-kodi)**
16 6.1. **[Build with Xcode](#61-Build-with-Xcode)**
17 6.2. **[Build with xcodebuild](#62-Build-with-xcodebuild)**
18 7. **[Packaging to distribute as deb](#7-Packaging-to-distribute-as-deb)**
19 7.1. **[Package via Xcode](#71-Package-via-Xcode)**
20 7.2. **[Package via Xcodebuild](#72-Package-via-Xcodebuild)**
21 8. **[Signing](#8-Signing)**
22 8.1. **[Signing using a developer account](#81-Signing-using-a-developer-account)**
23 8.2. **[Using iOS App Signer to install](#82-Using-iOS-App-Signer-to-install)**
24 9. **[Install](#9-Install)**
25 9.1. **[Jailbroken devices](#91-Jailbroken-devices)**
26 9.2. **[Using Xcode to install](#92-Using-Xcode-to-install)**
28 ## 1. Document conventions
29 This guide assumes you are using `terminal`, also known as `console`, `command-line` or simply `cli`. Commands need to be run at the terminal, one at a time and in the provided order.
31 This is a comment that provides context:
34 this is another command
38 **Example:** Clone Kodi's current master branch:
40 git clone https://github.com/xbmc/xbmc kodi
43 Commands that contain strings enclosed in angle brackets denote something you need to change to suit your needs.
45 git clone -b <branch-name> https://github.com/xbmc/xbmc kodi
48 **Example:** Clone Kodi's current Krypton branch:
50 git clone -b Krypton https://github.com/xbmc/xbmc kodi
53 Several different strategies are used to draw your attention to certain pieces of information. In order of how critical the information is, these items are marked as a note, tip, or warning. For example:
55 **NOTE:** Linux is user friendly... It's just very particular about who its friends are.
56 **TIP:** Algorithm is what developers call code they do not want to explain.
57 **WARNING:** Developers don't change light bulbs. It's a hardware problem.
59 **[back to top](#table-of-contents)** | **[back to section top](#1-document-conventions)**
62 * **[Java Development Kit (JDK)](http://www.oracle.com/technetwork/java/javase/downloads/index.html)**
63 * **[Xcode](https://developer.apple.com/xcode/)**. Install it from the AppStore or from the **[Apple Developer Homepage](https://developer.apple.com/)**.
64 * Device with **tvOS 11.0 or newer** to install Kodi after build.
66 Building for tvOS should work with the following combinations of Xcode and macOS versions:
67 * Xcode 12.4 against tvOS SDK 14.3 on 10.15.7 (Catalina)(recommended)(CI)
68 * Xcode 13.x against tvOS SDK 15.4 on 12.x (Monterey)(recommended)
70 Team Kodi CI infrastructure is limited, and therefore we only have the single combination tested. Newer xcode/macos combinations generally should work, however the team does not actively test/use pre-release versions, so use with caution. Earlier versions may work, however we dont actively support them, so use with caution.
71 **WARNING:** Start Xcode after installation finishes. You need to accept the licenses and install missing components.
73 **[back to top](#table-of-contents)**
75 ## 3. Get the source code
76 Change to your `home` directory:
81 Clone Kodi's current master branch:
83 git clone https://github.com/xbmc/xbmc kodi
86 **[back to top](#table-of-contents)**
88 ## 4. Configure and build tools and dependencies
89 Kodi can be built as a 64bit program only for tvOS. The dependencies are built in `$HOME/kodi/tools/depends` and installed into `/Users/Shared/xbmc-depends`.
90 **NOTE:** `--with-platform` is mandatory for all Apple platforms
94 cd $HOME/kodi/tools/depends
96 ./configure --host=aarch64-apple-darwin --with-platform=tvos
99 Build tools and dependencies:
101 make -j$(getconf _NPROCESSORS_ONLN)
104 **TIP:** By adding `-j<number>` to the make command, you can choose how many concurrent jobs will be used and expedite the build process. It is recommended to use `-j$(getconf _NPROCESSORS_ONLN)` to compile on all available processor cores. The build machine can also be configured to do this automatically by adding `export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"` to your shell config (e.g. `~/.bashrc`).
106 **WARNING:** Look for the `Dependencies built successfully.` success message. If in doubt run a single threaded `make` command until the message appears. If the single make fails, clean the specific library by issuing `make -C target/<name_of_failed_lib> distclean` and run `make`again.
108 **NOTE:** **Advanced developers** may want to specify an tvOS SDK version (if multiple versions are installed) in the configure line(s) shown above. The example below would use the tvOS SDK 11.0:
110 ./configure --host=aarch64-apple-darwin --with-platform=tvos --with-sdk=11.0
113 ### 4.1. Advanced Configure Options
119 --with-toolchain=<path>
121 specify path to toolchain. Auto set for android. Defaults to xcode root for darwin, /usr for linux
124 --enable-debug=<yes:no>
126 enable debugging information (default is yes)
134 --with-tarballs=<path>
136 path where tarballs will be saved [prefix/xbmc-tarballs]
141 optional. specify target cpu. guessed if not specified
144 --with-linker=<linker>
146 specify linker to use. (default is ld)
149 --with-platform=<platform>
154 --enable-gplv3=<yes:no>
156 enable gplv3 components. (default is yes)
159 --with-target-cflags=<cflags>
161 C compiler flags (target)
164 --with-target-cxxflags=<cxxflags>
166 C++ compiler flags (target)
169 --with-target-ldflags=<ldflags>
171 linker flags. Use e.g. for -l<lib> (target)
174 --with-ffmpeg-options
176 FFmpeg configure options, e.g. --enable-vaapi (target)
181 --with-sdk=<sdknumber>
183 specify sdk platform version.
185 **[back to top](#table-of-contents)**
187 ## 5. Generate Kodi Build files
188 Before you can use Xcode to build Kodi, the Xcode project has to be generated with CMake. CMake is built as part of the dependencies and doesn't have to be installed separately. A toolchain file is also generated and is used to configure CMake.
189 Default behaviour will not build binary addons. To add addons to your build go to **[Add Binary Addons to Project](#52-Add-Binary-Addons-to-Project)**
191 ## 5.1. Generate XCode Project Files
193 Before you can use Xcode to build Kodi, the Xcode project has to be generated with CMake. CMake is built as part of the dependencies and doesn't have to be installed separately. A toolchain file is also generated and is used to configure CMake.
195 Create an out-of-source build directory:
197 mkdir $HOME/kodi-build
200 Generate Xcode project for TVOS:
202 make -C tools/depends/target/cmakebuildsys BUILD_DIR=$HOME/kodi-build
205 **TIP:** BUILD_DIR can be omitted, and project will be created in $HOME/kodi/build
206 Change all relevant paths onwards if omitted.
208 Additional cmake arguments can be supplied via the CMAKE_EXTRA_ARGUMENTS command line variable
210 An example to set signing settings in xcode project:
212 make -C tools/depends/target/cmakebuildsys CMAKE_EXTRA_ARGUMENTS="-DPLATFORM_BUNDLE_IDENTIFIER='tv.kodi.kodi' -DCODE_SIGN_IDENTITY='iPhone Developer: *** (**********)' -DPROVISIONING_PROFILE_APP='tv.kodi.kodi' -DPROVISIONING_PROFILE_TOPSHELF='tv.kodi.kodi.Topshelf'"
214 Available Signing arguments
216 PLATFORM_BUNDLE_IDENTIFIER - bundle ID (used for the app, top shelf and entitlements)
217 DEVELOPMENT_TEAM - dev team ID **OR** CODE_SIGN_IDENTITY - certificate name
218 PROVISIONING_PROFILE_APP - provprofile name for the app
219 PROVISIONING_PROFILE_TOPSHELF - provprofile name for the top shelf
221 ## 5.2. Add Binary Addons to Project
223 **TIP:** If you wish to add signing settings automatically, look at **[Generate XCode Project Files](#51-Generate-XCode-Project-Files)** for the additional `CMAKE_EXTRA_ARGUMENTS`
225 You can find a complete list of available binary add-ons **[here](https://github.com/xbmc/repo-binary-addons)**.
227 Binary addons will be built as a dependency in the Xcode project. You can choose the addons you wish to build during the Xcode project generation step
229 Generate Xcode project to build specific add-ons:
231 make -C tools/depends/target/cmakebuildsys CMAKE_EXTRA_ARGUMENTS="-DENABLE_XCODE_ADDONBUILD=ON -DADDONS_TO_BUILD='audioencoder.flac pvr.vdr.vnsi audiodecoder.snesapu'"
234 Generate Xcode project to build a specific group of add-ons:
236 make -C tools/depends/target/cmakebuildsys CMAKE_EXTRA_ARGUMENTS="-DENABLE_XCODE_ADDONBUILD=ON -DADDONS_TO_BUILD='pvr.*'"
238 For additional information on regular expression usage for ADDONS_TO_BUILD, view ADDONS_TO_BUILD section located at [Kodi add-ons CMake based buildsystem](../cmake/addons/README.md)
240 Generate Xcode project to build all add-ons automatically:
242 make -C tools/depends/target/cmakebuildsys CMAKE_EXTRA_ARGUMENTS="-DENABLE_XCODE_ADDONBUILD=ON"
245 **TIP:** If you wish to not automatically build addons added to your xcode project, omit `-DENABLE_XCODE_ADDONBUILD=ON`. The target will be added to the project, but the dependency will not be set to automatically build
246 **TIP:** Binary add-ons added to the generated Xcode project can be built independently of the Kodi app by selecting the scheme/target `binary-addons` in the Xcode project.
247 You can also build the binary-addons target via xcodebuild. This will not build the Kodi App, but will build any/all binary addons added for the project Generation.
249 xcodebuild -config "Debug" -target binary-addons
251 **[back to top](#table-of-contents)** | **[back to section top](#5-Generate-Kodi-Build-files)**
255 ### 6.1. Build with Xcode
257 Start Xcode, open the Kodi project file created in **[Generate Kodi Build files](#5-Generate-Kodi-Build-files)**
259 **TIP:** (`kodi.xcodeproj`) is located in `$HOME/kodi-build`
261 Once the project has loaded, select `Generic TvOs Device` (or your actual connected device if you have it connected) and hit `Build`.
263 This will create a `Kodi.app` file located in `$HOME/kodi-build/build/Debug-appletvos`. This App can be deployed via Xcode to an AppleTV via `Window -> Devices and Simulators -> Select device and click +`
265 **TIP:** If you build as a release target, the location of the `Kodi.app` will be `$HOME/kodi-build/build/Release-appletvos`
267 **WARNING:** If you have selected a specific tvOS SDK Version in step 4 then you might need to adapt the active target to use the same tvOS SDK version, otherwise build will fail. Be sure to select a device configuration.
268 **WARNING:** Building for simulator is NOT supported.
270 ### 6.2. Build with xcodebuild
271 Alternatively, you can also build via Xcode from the command-line with `xcodebuild`, triggered by CMake:
273 Change to build directory:
276 xcodebuild -config "Debug" -jobs $(getconf _NPROCESSORS_ONLN)
279 This will create a `Kodi.app` file located in `$HOME/kodi-build/build/Debug-appletvos`. This App can be deployed via Xcode to an AppleTV via `Window -> Devices and Simulators -> Select device and click +`
281 **TIP:** You can specify Release instead of Debug as -config parameter.
282 **TIP:** If you build as a release target, the location of the `Kodi.app` will be `$HOME/kodi-build/build/Release-appletvos`
284 **[back to top](#table-of-contents)** | **[back to section top](#6-Build)**
286 ## 7. Packaging to distribute as deb
287 CMake generates a target called `deb` which will package Kodi ready for distribution. After Kodi has been built, the target can be triggered by selecting it in Xcode active scheme or manually running
289 ## 7.1. Package via Xcode
291 Start Xcode, open the Kodi project file created in **[Generate XCode Project Files](#51-Generate-Project-Files)**
293 **TIP:** (`kodi.xcodeproj`) is located in `$HOME/kodi-build`
295 Click on `Product` in the top menu bar, and then go to `Scheme`, then select `deb`
299 **TIP:** The generated package will be located at $HOME/kodi-build/tools/darwin/packaging/tvos.
301 ## 7.2. Package via Xcodebuild
303 Change to build directory:
306 xcodebuild -target deb
309 **TIP:** The generated package will be located at $HOME/kodi-build/tools/darwin/packaging/tvos.
311 **[back to top](#table-of-contents)**
315 **TIP:** If your device is jailbroken, you can go direct to **[Installing on Jailbroken Device](#91-Jailbroken-devices)**
317 ## 8.1. Signing using a developer account
319 For this to work you need to alter the Xcode project by setting your codesign identity or supplying credentials during
321 Note that using a free developer account the signing will need to be reapplied every 7 days.
323 1. Open the Xcode project in Xcode as above (requires Xcode 7 or later)
324 2. Select Xcode->Preferences and select Accounts
325 * Hit the + sign to add an Apple ID account and Login.
326 2. Next select the kodi build target
327 3. Under the `General` tab, enter a unique bundle identifier and check the box to `Automatically Manage Signing`.
328 4. Select your team under `Automatically Manage Signing`.
330 ## An important note on Code Signing
331 It's also important that you select the signing on all 4 spots in the project settings. After the last buildstep, our support script will do a full sign of all binaries and bundle them with the given identity, including all the `*.viz`, `*.pvr`, `*.so`, etc. files Xcode doesn't know anything about. This should allow you to deploy Kodi to all non-jailbroken devices the same way you deploy normal apps to.
332 In that case Kodi will be sandboxed like any other app. All Kodi files are then located in the sandboxed *Documents* folder and can be easily accessed via iTunes file sharing.
334 ## 8.2. Using iOS App Signer to install
336 1. Build the deb target via xcodebuild or Xcode as per **[Build Kodi](#6-build-kodi)**
337 2. Open iOS Appsigner
338 3. Browse to $HOME/kodi/build/tools/darwin/packaging/tvos for your input file
339 4. Select your signing certificate
340 5. Select your provisioning profile
341 6. Click start and select save location for the ipa file
342 7. Run Xcode -> Window -> Devices and Simulators
343 8. Select your Apple TV you setup in earlier for Wireless connecting press the +
344 9. Find your ipa file and click open.
346 **[back to top](#table-of-contents)**
350 There are a number of different methods that can be used to install kodi on an AppleTV 4/4K.
352 ## 9.1. Jailbroken devices
353 On jailbroken devices the resulting deb file created from **[Packaging to distribute as deb](#7-Packaging-to-distribute-as-deb)** can be copied to the tvOS device via *ssh/scp* and installed manually. You need to SSH into the tvOS device and issue:
355 dpkg -i <name of the deb file>
358 ## 9.2. Using Xcode to install
360 Whether you have paid or free developer account you can deploy Kodi via Xcode to work on a non-jailbroken devices.
362 ## Wirelessly connecting to AppleTV 4/4K
363 The Apple TV 4K cannot be connected to mac via a cable so the connection must be wireless to XCode to add the application.
365 1. Make sure your Mac and your Apple TV are on the same network.
366 2. Choose `Window->Devices and Simulators`, then in the window that appears, click Devices.
367 3. On your Apple TV, open the Settings app and choose `Remotes and Devices->Remote App and Devices`.
368 4. The Apple TV searches for possible devices including the Mac. (If you have any Firewall or Internet security, disable/turn off to allow searching.)
369 5. On your Mac, select the Apple TV in the Devices pane. The pane for the Apple TV is displayed and shows the current status of the connection request.
370 6. Enter the verification code displayed on your AppleTV into the Device window pane for the device and click Connect.
372 Xcode sets up the Apple TV for wireless debugging and pairs with the device.
373 Once your Apple TV has been connected in Xcode, you can deploy either the **[Deb](#7-Packaging-to-distribute-as-deb)** or **[App](#6-Build file)** file.
375 1. Choose Window > Devices and Simulators, then in the window that appears, click Devices.
376 2. On your Mac, select the Apple TV in the Devices pane.
377 3. Click the + symbol under `installed apps` and navigate to and select: `$HOME/kodi-build/build/Debug-appletvos/Kodi.app` and then `Open`.
379 **[back to top](#table-of-contents)**