Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

How to cross compile the AVS Device SDK for iOS

leala-amzn edited this page Jun 13, 2019 · 7 revisions

These are step-by-step instructions to cross-compile and build the AVS Device SDK for iOS. If you encounter any errors or have questions, please check our issues list before creating a new issue.

Prerequisites

Confirm that these dependencies are installed:

curl --version
brew --version
xcode-select --version

Get started

  1. Install dependencies:

    brew install cmake pkg-config
    
  2. Create a build folder for your project:

    cd ~
    mkdir cross-compile
    cd cross-compile
    
  3. Clone CMake for iOS into your build folder:

    cd ~/cross-compile
    git clone https://github.com/leetal/ios-cmake.git
    
  4. Download and cross-compile Google Test:

    cd ~/cross-compile
    git clone https://github.com/google/googletest.git
    mkdir googletest_build
    
    cd googletest_build
    
    cmake ../googletest \
    -DIOS_DEPLOYMENT_TARGET=10.0 \
    -DCMAKE_TOOLCHAIN_FILE=../ios-cmake/ios.toolchain.cmake \
    -DIOS_PLATFORM=OS \
    
    make
    
  5. Download and cross-compile OpenSSL and curl. For this step, we're going to use an open source script from GitHub. Heads-up, this may take a while:

    • Clone the repository:
      cd ~/cross-compile
      git clone https://github.com/jasonacox/Build-OpenSSL-cURL.git
      cd Build-OpenSSL-cURL/
      
    • Open build.sh and change the curl version to 7.55.1 and save.
      ########################################
      # EDIT this section to Select Versions #
      ########################################
      
      OPENSSL="1.0.2l"
      LIBCURL="7.55.1"
      NGHTTP2="1.24.0"
      
      ########################################
      
    • Run the script:
      ./build.sh
      
  6. Clone the AVS Device SDK:

    cd ~/cross-compile
    git clone https://github.com/alexa/avs-device-sdk.git  
    cd avs-device-sdk/
    
  7. Replace source code in /AVSCommon/Utils/src/LibcurlUtils/LibcurlUtils.cpp

    if (config.getString(CAPATH_CONFIG_KEY, &caPath) &&
        !setopt(handle, CURLOPT_CAPATH, caPath.c_str(), "CURLOPT_CAPATH", caPath.c_str())) {
       return false;
    }

with this code:

if (config.getString(CAPATH_CONFIG_KEY, &caPath) &&
!setopt(handle, CURLOPT_CAINFO, caPath.c_str(), "CURLOPT_CAINFO", caPath.c_str()) &&
!setopt(handle, CURLOPT_CAPATH, caPath.c_str(), "CURLOPT_CAPATH", caPath.c_str())) {
return false;
}
  1. The SDK must be run as a STATIC library; make it global in all subfolders:
    cd ~/cross-compile/avs-device-sdk/
    find . -type f -name '*.txt' -exec sed -i '' s/SHARED/STATIC/ {} +
    

Build the SDK

Build the SDK using the following CMake parameters:

cd ~/cross-compile
mkdir avs_build

cd avs_build

cmake ../avs-device-sdk
-DIOS_DEPLOYMENT_TARGET=10.0 \
-DCMAKE_TOOLCHAIN_FILE=../ios-cmake/ios.toolchain.cmake \
-DIOS_PLATFORM=OS \
-DGSTREAMER_MEDIA_PLAYER=OFF \
-DCURL_LIBRARY=../Build-OpenSSL-cURL/archive/libcurl-7.54.1-openssl-1.0.2l-nghttp2-1.24.0/libcurl_iOS.a \
-DCURL_INCLUDE_DIR=../Build-OpenSSL-cURL/curl/curl-7.55.1/include \
-DGTEST_LIBRARY=../googletest_build/googlemock/libgmock.a \
-DGTEST_MAIN_LIBRARY=../googletest_build/googlemock/libgmock_main.a \
-DGTEST_INCLUDE_DIR=../googletest/googletest/include/ \
-DPKG_CONFIG_EXECUTABLE=/usr/local/bin/pkg-config

Build with the ability to run in the iOS Simulator (optional)

cd ~/cross-compile

mkdir avs_build_sim
cd avs_build_sim

cmake ../avs-device-sdk
-DIOS_DEPLOYMENT_TARGET=10.0 \
-DCMAKE_TOOLCHAIN_FILE=../ios-cmake/ios.toolchain.cmake \
-DIOS_PLATFORM=SIMULATOR64 \
-DGSTREAMER_MEDIA_PLAYER=OFF \
-DCURL_LIBRARY=../Build-OpenSSL-cURL/archive/libcurl-7.54.1-openssl-1.0.2l-nghttp2-1.24.0/libcurl_iOS.a \
-DCURL_INCLUDE_DIR=../Build-OpenSSL-cURL/curl/curl-7.55.1/include \
-DGTEST_LIBRARY=../googletest_build/googlemock/libgmock.a \
-DGTEST_MAIN_LIBRARY=../googletest_build/googlemock/libgmock_main.a \
-DGTEST_INCLUDE_DIR=../googletest/googletest/include/ \
-DPKG_CONFIG_EXECUTABLE=/usr/local/bin/pkg-config

To build what's required for the iOS proof of concept run these commands:

make CBLAuthDelegate
make DefaultClient
make KWD
make PlaylistParser

Make sure that each make command reaches 100%.

Clone this wiki locally