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

Mapbox iOS Examples + Xcode Server Bots #416

Open
roblabs opened this issue Oct 5, 2020 · 0 comments
Open

Mapbox iOS Examples + Xcode Server Bots #416

roblabs opened this issue Oct 5, 2020 · 0 comments

Comments

@roblabs
Copy link

roblabs commented Oct 5, 2020

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

  • The reporting from Xcode gives insight into the automated Tests & Code Coverage
  • Allows testing on many simulators and devices in my local setup
  • No extra dependency to install
  • the Mapbox team has done an excellent job over the years of adding features and tests. These notes may help others that are learning the code or want to use Mapbox APIs in their own repos. We use it in our lab, and we thought it were worthwhile to share out.

Related to mapbox/mapbox-gl-native-ios#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

  1. On your development Mac, choose Product > Create Bot.
  2. Add Pre-Integration Triggers
    • Script environment - Git repo metadata & Build versions
    • Script mapbox - project specific build commands

Pre-integration Script `environment` πŸ‘‰
#!/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` πŸ‘‰
#!/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:

roblabs added a commit to roblabs/xcode-continuous-integration that referenced this issue Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant