mapbox / ios-sdk-examples

Live example code for the Mapbox iOS SDK
https://www.mapbox.com/ios-sdk/examples/
Other
95 stars 35 forks source link

Mapbox iOS Examples + Xcode Server Bots #416

Open roblabs opened 4 years ago

roblabs commented 4 years ago

Goal — one button Xcode builds with Xcode Server Bots 🤖 or XCS.

The repo for ios-sdk-examples already has a CI solution. The goal with this issue is to document how to use Mapbox iOS Examples with Xcode Server Bots, to better understand the build, and to use the excellent reporting tools built into Xcode.

Advantages of XCS

Related to https://github.com/mapbox/mapbox-gl-native-ios/issues/493

How to

Notes excerpted from roblabs / xcode-continuous-integration which discusses a process to setup XCS for any Xcode project.

  1. The Git branch and Xcode scheme you want to test is very important, so check out a local copy to your development folder. For example, set the branch you want and perform the initial step to make the Xcode Project.

From a fresh clone of the Mapbox project ios-sdk-examples

git clone \
  https://github.com/mapbox/ios-sdk-examples.git \
  tmp/ios-sdk-examples

cd tmp/ios-sdk-examples

# Initial steps to properly getting a local build working
pod --version
pod install --repo-update

xed Examples.xcworkspace
  1. The call to xed will launch the Xcode application and opens the given documents. From man xed.

  2. Change the Scheme to Examples.

    xcs-Examples-scheme
  3. On your development Mac, choose Product > Create Bot.

  4. Add Pre-Integration Triggers

    • Script environment - Git repo metadata & Build versions
    • Script mapbox - project specific build commands

Pre-integration Script `environment` 👉 ``` bash #!/bin/sh # Pre-Integration Script # environment # MARK: - Xcode Server Environment Variable Reference # https://developer.apple.com/library/archive/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/EnvironmentVariableReference.html echo XCS=${XCS} echo "XCS_BOT_NAME = ${XCS_BOT_NAME}" echo "XCS_INTEGRATION_NUMBER = ${XCS_INTEGRATION_NUMBER}" echo "XCS_PRIMARY_REPO_DIR = ${XCS_PRIMARY_REPO_DIR}" echo "XCS_SOURCE_DIR = ${XCS_SOURCE_DIR}" echo "XCS_DERIVED_DATA_DIR = ${XCS_DERIVED_DATA_DIR}" echo "XCS_PRIMARY_REPO_REVISION=${XCS_PRIMARY_REPO_REVISION}" # Only used when not checking out a branch or a tag. echo "XCS_PRIMARY_REPO_BRANCH = ${XCS_PRIMARY_REPO_BRANCH}" # Only used when checking out a branch. echo "XCS_PRIMARY_REPO_TAG = ${XCS_PRIMARY_REPO_TAG}" # Only used when checking out a tag. echo "XCS_OUTPUT_DIR = ${XCS_OUTPUT_DIR}" echo "XCS_BOT_ID = ${XCS_BOT_ID}" echo "XCS_BOT_TINY_ID = ${XCS_BOT_TINY_ID}" echo "http://Bots JSON = https://$(hostname):20343/api/bots" echo "http://bots/latest = https://$(hostname)/xcode/bots/latest" echo "http://latest this bot = https://$(hostname)/xcode/bots/latest/${XCS_BOT_TINY_ID}" echo "http://Integration JSON = https://$(hostname)/xcode/internal/api/integrations/${XCS_INTEGRATION_ID}" echo "http://Download = https://$(hostname)/xcode/internal/api/integrations/${XCS_INTEGRATION_ID}/assets" echo "xcbot://See Bot in Xcode = xcbot://$(hostname)/botID/${XCS_BOT_ID}/integrationID/${XCS_INTEGRATION_ID}" # MARK: - build environment hostname sw_vers # Xcode version & path /usr/bin/xcodebuild -version /usr/bin/xcode-select -print-path ```

Pre-integration Script `mapbox` 👉 ``` bash #!/bin/sh # Pre-Integration Script # Script: ios_sdk_examples_pod_install # MARK: - Update PATH echo $PATH export PATH=/usr/local/bin:.:$PATH echo $PATH # set verbose set -v cd ${XCS_PRIMARY_REPO_DIR} pwd # MARK: - project specific build commands # WARNING: CocoaPods requires your terminal to be using UTF-8 encoding. export LANG=en_US.UTF-8 # Versions of build dependencies pod --version # This version is heavy with pod pod install --repo-update wait echo xed ${XCS_PRIMARY_REPO_DIR}/Examples.xcworkspace wait ```

References: