Platform flattening overhaul (#1393)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
87
platform/ios/scripts/bazel-package.sh
Normal file
87
platform/ios/scripts/bazel-package.sh
Normal file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# "static" or "dynamic"
|
||||
build_type="static"
|
||||
|
||||
# "release" or "debug"
|
||||
release_type="release"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--static)
|
||||
build_type="static"
|
||||
shift
|
||||
;;
|
||||
--dynamic)
|
||||
build_type="dynamic"
|
||||
shift
|
||||
;;
|
||||
--release)
|
||||
release_type="release"
|
||||
shift
|
||||
;;
|
||||
--debug)
|
||||
release_type="debug"
|
||||
shift
|
||||
;;
|
||||
--link)
|
||||
build_type="link"
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
echo "Build the maplibre xcframework using the bazel build files. You must install Baselisk to build using this method."
|
||||
echo "Usage: .bazel-package.sh --static|--dynamic --release|--debug"
|
||||
echo "Defaults to \"--static --release\""
|
||||
exit 1
|
||||
;;
|
||||
-*|--*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "------ Build type: $build_type Release type: $release_type ------"
|
||||
|
||||
target="Mapbox.$build_type"
|
||||
|
||||
compilation_mode="opt"
|
||||
if [ "$release_type" = "debug" ]; then
|
||||
compilation_mode="dbg"
|
||||
fi;
|
||||
|
||||
echo "------ Determining Maplibre version and hash ------"
|
||||
|
||||
sem_version=$(git describe --tags --match=ios-v*.*.* --abbrev=0 | sed 's/^ios-v//')
|
||||
hash=$(git log | head -1 | awk '{ print $2 }' | cut -c 1-10) && true
|
||||
|
||||
# Move and configure the info plists with the semantic version and hash.
|
||||
temp_info_static_plist="platform/ios/build/Info-static.plist"
|
||||
temp_info_plist="platform/ios/build/Info.plist"
|
||||
|
||||
if [ ! -d platform/ios/build ]; then
|
||||
mkdir platform/ios/build
|
||||
fi
|
||||
|
||||
cp platform/ios/framework/Info-static.plist "$temp_info_static_plist"
|
||||
cp platform/ios//framework/Info.plist "$temp_info_plist"
|
||||
|
||||
plutil -replace MLNSemanticVersionString -string "$sem_version" "$temp_info_static_plist"
|
||||
plutil -replace MLNCommitHash -string "$hash" "$temp_info_static_plist"
|
||||
plutil -replace MLNSemanticVersionString -string "$sem_version" "$temp_info_plist"
|
||||
plutil -replace MLNCommitHash -string "$hash" "$temp_info_plist"
|
||||
|
||||
echo "------ Building Maplibre version: $sem_version hash: $hash ------"
|
||||
|
||||
bazel build //platform/ios:"$target" --apple_platform_type=ios \
|
||||
--apple_generate_dsym \
|
||||
--compilation_mode="$compilation_mode" \
|
||||
--features=dead_strip \
|
||||
--objc_enable_binary_stripping \
|
||||
--copt=-Wall --copt=-Wextra --copt=-Wpedantic \
|
||||
--copt=-Werror
|
||||
|
||||
echo "Done."
|
||||
echo "Package will be available in \"/bazel-bin/platform/ios/$target.xcframework.zip\""
|
||||
28
platform/ios/scripts/bazel-xcodeproj.sh
Normal file
28
platform/ios/scripts/bazel-xcodeproj.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
echo "------ Determining Maplibre version and hash ------"
|
||||
|
||||
sem_version=0.0.0
|
||||
hash=$(git log | head -1 | awk '{ print $2 }' | cut -c 1-10) && true
|
||||
|
||||
# Move and configure the info plists with the semantic version and hash.
|
||||
temp_info_static_plist="platform/ios/build/Info-static.plist"
|
||||
temp_info_plist="platform/ios/build/Info.plist"
|
||||
|
||||
if [ ! -d platform/ios/build ]; then
|
||||
mkdir platform/ios/build
|
||||
fi
|
||||
|
||||
cp platform/ios/framework/Info-static.plist "$temp_info_static_plist"
|
||||
cp platform/ios/framework/Info.plist "$temp_info_plist"
|
||||
|
||||
plutil -replace MLNSemanticVersionString -string "$sem_version" "$temp_info_static_plist"
|
||||
plutil -replace MLNCommitHash -string "$hash" "$temp_info_static_plist"
|
||||
plutil -replace MLNSemanticVersionString -string "$sem_version" "$temp_info_plist"
|
||||
plutil -replace MLNCommitHash -string "$hash" "$temp_info_plist"
|
||||
|
||||
echo "------ Building Maplibre version: $sem_version hash: $hash ------"
|
||||
|
||||
bazel run //platform/ios:xcodeproj
|
||||
160
platform/ios/scripts/deploy-packages.sh
Normal file
160
platform/ios/scripts/deploy-packages.sh
Normal file
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
set -u
|
||||
|
||||
# dynamic environment variables:
|
||||
# VERSION_TAG={determined automatically}: Version tag in format ios-vX.X.X-pre.X
|
||||
# GITHUB_RELEASE=true: Upload to github
|
||||
|
||||
# environment variables and dependencies:
|
||||
# - You must run "mbx auth ..." before running
|
||||
# - Set GITHUB_TOKEN to a GitHub API access token in your environment to use GITHUB_RELEASE
|
||||
# - The "github-release" command is required to use GITHUB_RELEASE
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
buildPackageStyle() {
|
||||
local package=$1 style=""
|
||||
if [[ ${#} -eq 2 ]]; then
|
||||
style="$2"
|
||||
fi
|
||||
step "Building: make ${package} ${style}"
|
||||
FORMAT=${style} make ${package}
|
||||
step "Publishing ${package} with ${style}"
|
||||
local file_name=""
|
||||
if [ -z ${style} ]
|
||||
then
|
||||
./platform/ios/scripts/publish.sh "${PUBLISH_VERSION}"
|
||||
file_name=mapbox-ios-sdk-${PUBLISH_VERSION}.zip
|
||||
else
|
||||
./platform/ios/scripts/publish.sh "${PUBLISH_VERSION}" ${style}
|
||||
file_name=mapbox-ios-sdk-${PUBLISH_VERSION}-${style}.zip
|
||||
fi
|
||||
if [[ "${GITHUB_RELEASE}" == true ]]; then
|
||||
step "Uploading ${file_name} to GitHub"
|
||||
github-release upload \
|
||||
--tag "ios-v${PUBLISH_VERSION}" \
|
||||
--name ${file_name} \
|
||||
--file "${BINARY_DIRECTORY}/${file_name}" > /dev/null
|
||||
else
|
||||
step "CREATED ${file_name} - skipping upload to Github"
|
||||
fi
|
||||
}
|
||||
|
||||
export GITHUB_USER=maplibre
|
||||
export GITHUB_REPO=maplibre-native
|
||||
export BUILDTYPE=Release
|
||||
export PACKAGE_FORMAT=xcframework
|
||||
|
||||
VERSION_TAG=${VERSION_TAG:-''}
|
||||
PUBLISH_VERSION=
|
||||
BINARY_DIRECTORY='build/ios'
|
||||
GITHUB_RELEASE=${GITHUB_RELEASE:-false}
|
||||
BUILD_FOR_COCOAPODS=${BUILD_FOR_COCOAPODS:-false}
|
||||
PUBLISH_PRE_FLAG=''
|
||||
|
||||
if [[ -z `which github-release` ]]; then
|
||||
step "Installing github-release…"
|
||||
brew install github-release
|
||||
if [ -z `which github-release` ]; then
|
||||
echo "Unable to install github-release. See: https://github.com/aktau/github-release"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ${GITHUB_RELEASE} = "true" ]]; then
|
||||
GITHUB_RELEASE=true # Assign bool, not just a string
|
||||
fi
|
||||
|
||||
if [[ ${GITHUB_RELEASE} = "false" ]]; then
|
||||
GITHUB_RELEASE=false # Assign bool, not just a string
|
||||
fi
|
||||
|
||||
if [[ ${BUILD_FOR_COCOAPODS} = "false" ]]; then
|
||||
BUILD_FOR_COCOAPODS=false # Assign bool, not just a string
|
||||
fi
|
||||
|
||||
if [[ ${BUILD_FOR_COCOAPODS} = "true" ]]; then
|
||||
BUILD_FOR_COCOAPODS=true # Assign bool, not just a string
|
||||
fi
|
||||
|
||||
if [[ -z ${VERSION_TAG} ]]; then
|
||||
step "Determining version number from most recent relevant git tag…"
|
||||
VERSION_TAG=$( git describe --tags --match=ios-v*.*.* --abbrev=0 )
|
||||
echo "Found tag: ${VERSION_TAG}"
|
||||
fi
|
||||
|
||||
if [[ $( echo ${VERSION_TAG} | grep --invert-match ios-v ) ]]; then
|
||||
echo "Error: ${VERSION_TAG} is not a valid iOS version tag"
|
||||
echo "VERSION_TAG should be in format: ios-vX.X.X-pre.X"
|
||||
if [[ "${GITHUB_RELEASE}" == true ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if github-release info --tag ${VERSION_TAG} | grep --quiet "draft: ✗"; then
|
||||
echo "Error: ${VERSION_TAG} has already been published on GitHub"
|
||||
echo "See: https://github.com/${GITHUB_USER}/${GITHUB_REPO}/releases/tag/${VERSION_TAG}"
|
||||
if [[ "${GITHUB_RELEASE}" == true ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${GITHUB_RELEASE}" == true ]]; then
|
||||
PUBLISH_VERSION=$( echo ${VERSION_TAG} | sed 's/^ios-v//' )
|
||||
git checkout ${VERSION_TAG}
|
||||
step "Deploying version ${PUBLISH_VERSION}…"
|
||||
else
|
||||
PUBLISH_VERSION=${VERSION_TAG}
|
||||
step "Building packages for version ${PUBLISH_VERSION} (Not deploying to Github)"
|
||||
fi
|
||||
|
||||
npm install --ignore-scripts
|
||||
mkdir -p ${BINARY_DIRECTORY}
|
||||
|
||||
if [[ "${GITHUB_RELEASE}" == true ]]; then
|
||||
step "Create GitHub release…"
|
||||
if [[ $( echo ${PUBLISH_VERSION} | awk '/[0-9]-/' ) ]]; then
|
||||
PUBLISH_PRE_FLAG='--pre-release'
|
||||
fi
|
||||
RELEASE_NOTES=$( ./platform/ios/scripts/release-notes.js github )
|
||||
github-release release \
|
||||
--tag "ios-v${PUBLISH_VERSION}" \
|
||||
--name "ios-v${PUBLISH_VERSION}" \
|
||||
--draft ${PUBLISH_PRE_FLAG} \
|
||||
--description "${RELEASE_NOTES}"
|
||||
fi
|
||||
|
||||
# Used for binary release on Github - includes events SDK
|
||||
buildPackageStyle "${PACKAGE_FORMAT}" "dynamic"
|
||||
|
||||
echo "Binary artifact zip file: ${BINARY_ARTIFACT_ZIP_FILE}"
|
||||
echo "Binary artifact url: ${BINARY_ARTIFACT_URL}"
|
||||
|
||||
if [[ !-z "${BINARY_ARTIFACT_URL}" ]]; then
|
||||
step "Creating Swift package…"
|
||||
|
||||
rm -f Package.swift
|
||||
cp swift_package_template.swift Package.swift
|
||||
sed -i "s/__PACKAGE_URL__/${BINARY_ARTIFACT_URL}/g" Package.swift
|
||||
CHECKSUM=$(swift package compute-checksum ${BINARY_ARTIFACT_ZIP_FILE})
|
||||
echo "Checksum: ${CHECKSUM}"
|
||||
sed -i "s/__PACKAGE_CHECKSUM__/${CHECKSUM}/g" Package.swift
|
||||
cat Package.swift
|
||||
fi
|
||||
|
||||
|
||||
if [[ ${BUILD_FOR_COCOAPODS} == true ]]; then
|
||||
# Used for Cocoapods/Carthage
|
||||
buildPackageStyle "${PACKAGE_FORMAT}" "dynamic"
|
||||
buildPackageStyle "${PACKAGE_FORMAT} SYMBOLS=NO" "stripped-dynamic"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
step "Finished deploying ${PUBLISH_VERSION} in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds"
|
||||
17
platform/ios/scripts/deploy-snapshot.sh
Normal file
17
platform/ios/scripts/deploy-snapshot.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
DATE=`date +%Y-%m-%d`
|
||||
PROJ_VERSION=$(git rev-list --count HEAD)
|
||||
SNAPSHOT_TYPE="snapshot-dynamic"
|
||||
|
||||
step "Uploading ${SNAPSHOT_TYPE} build for ${DATE}-${PROJ_VERSION} to s3…"
|
||||
|
||||
./platform/ios/scripts/publish.sh "${SNAPSHOT_TYPE}" "${DATE}-${PROJ_VERSION}"
|
||||
|
||||
step "Finished deploying ${SNAPSHOT_TYPE} build in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds"
|
||||
178
platform/ios/scripts/deploy-swift-package.sh
Normal file
178
platform/ios/scripts/deploy-swift-package.sh
Normal file
@@ -0,0 +1,178 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
set -u
|
||||
|
||||
# dynamic environment variables:
|
||||
# VERSION_TAG={determined automatically}: Version tag in format ios-vX.X.X-pre.X
|
||||
|
||||
# environment variables and dependencies:
|
||||
# - You must run "mbx auth ..." before running
|
||||
# - Set GITHUB_TOKEN to a GitHub API access token in your environment
|
||||
# - The "github-release" command is required
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
export GITHUB_USER=maplibre
|
||||
export GITHUB_REPO=maplibre-native
|
||||
export BUILDTYPE=Release
|
||||
export DISTRIBUTION_GITHUB_REPO=https://api.github.com/repos/maplibre/maplibre-gl-native-distribution
|
||||
|
||||
VERSION_TAG=${VERSION_TAG:-''}
|
||||
PUBLISH_VERSION=
|
||||
BINARY_DIRECTORY='build/ios/pkg/dynamic'
|
||||
PUBLISH_PRE_FLAG=''
|
||||
S3_DISTRIBUTION=false
|
||||
|
||||
uploadToGithub() {
|
||||
local file_path=$1
|
||||
local version_tag=$2
|
||||
file_name=${file_path##*/}
|
||||
github-release upload \
|
||||
--tag "${version_tag}" \
|
||||
--name ${file_name} \
|
||||
--file "${file_path}" > /dev/null
|
||||
|
||||
EXT_TARGET_GITHUB_URL="https://github.com/${GITHUB_USER}/${GITHUB_REPO}/releases/download/${version_tag}/${file_name}"
|
||||
}
|
||||
|
||||
uploadToS3() {
|
||||
local file_path=$1
|
||||
local progress=$2
|
||||
file_name=${file_path##*/}
|
||||
|
||||
PROGRESS=""
|
||||
if [ "${progress}" == false ]; then
|
||||
PROGRESS="--no-progress"
|
||||
fi
|
||||
|
||||
local target_s3_location="s3://mapbox-gl-native/ios/builds/${file_name}"
|
||||
local target_s3_url="https://mapbox-gl-native.s3.us-east-2.amazonaws.com/ios/builds/${file_name}"
|
||||
|
||||
aws s3 cp ${file_path} ${target_s3_location} --acl public-read ${PROGRESS}
|
||||
|
||||
EXT_TARGET_S3_URL="${target_s3_url}"
|
||||
}
|
||||
|
||||
rm -rf ${BINARY_DIRECTORY}
|
||||
|
||||
if [[ -z `which github-release` ]]; then
|
||||
step "Installing github-release…"
|
||||
brew install github-release
|
||||
if [ -z `which github-release` ]; then
|
||||
echo "Unable to install github-release. See: https://github.com/aktau/github-release"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z `which jq` ]]; then
|
||||
step "Installing jq …"
|
||||
brew install jq
|
||||
if [ -z `which jq` ]; then
|
||||
echo "Unable to install which jq."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z ${VERSION_TAG} ]]; then
|
||||
step "Determining version number from most recent relevant git tag…"
|
||||
VERSION_TAG=$( git describe --tags --match=ios-v*.*.* --abbrev=0 )
|
||||
echo "Found tag: ${VERSION_TAG}"
|
||||
fi
|
||||
|
||||
if [[ $( echo ${VERSION_TAG} | grep --invert-match ios-v ) ]]; then
|
||||
echo "Error: ${VERSION_TAG} is not a valid iOS version tag"
|
||||
echo "VERSION_TAG should be in format: ios-vX.X.X-pre.X"
|
||||
exit 1
|
||||
fi
|
||||
if github-release info --tag ${VERSION_TAG} | grep --quiet "draft: ✗"; then
|
||||
echo "Error: ${VERSION_TAG} has already been published on GitHub"
|
||||
echo "See: https://github.com/${GITHUB_USER}/${GITHUB_REPO}/releases/tag/${VERSION_TAG}"
|
||||
exit 1
|
||||
fi
|
||||
PUBLISH_VERSION=$( echo ${VERSION_TAG} | sed 's/^ios-v//' )
|
||||
|
||||
git checkout ${VERSION_TAG}
|
||||
|
||||
npm install --ignore-scripts
|
||||
mkdir -p ${BINARY_DIRECTORY}
|
||||
|
||||
step "Building: make xcframework"
|
||||
make xcframework
|
||||
|
||||
step "Zipping xcframeworks…"
|
||||
MAPBOX_ZIP_FILE="Mapbox-${PUBLISH_VERSION}.zip"
|
||||
(cd ${BINARY_DIRECTORY} && rm -f ${MAPBOX_ZIP_FILE} && zip -yr ${MAPBOX_ZIP_FILE} Mapbox.xcframework)
|
||||
|
||||
if [[ ${S3_DISTRIBUTION} == true ]]; then
|
||||
step "Uploading ${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE} to s3"
|
||||
uploadToS3 "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" false
|
||||
MAPBOX_ZIP_FILE_URL=$EXT_TARGET_S3_URL
|
||||
fi
|
||||
|
||||
step "Create GitHub release…"
|
||||
RELEASE_NOTES=$( ./platform/ios/scripts/release-notes.js github )
|
||||
|
||||
if [[ -z "${RELEASE_NOTES}" ]]; then
|
||||
echo "Release notes cannot be empty."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
github-release release \
|
||||
--tag "ios-v${PUBLISH_VERSION}" \
|
||||
--name "ios-v${PUBLISH_VERSION}" \
|
||||
--description "${RELEASE_NOTES}"
|
||||
|
||||
step "Uploading ${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE} to github release [${VERSION_TAG}]"
|
||||
uploadToGithub "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" "${VERSION_TAG}"
|
||||
MAPBOX_ZIP_FILE_URL=$EXT_TARGET_GITHUB_URL
|
||||
|
||||
step "Creating Swift package…"
|
||||
|
||||
rm -f Package.swift
|
||||
cp platform/ios/scripts/swift_package_template.swift Package.swift
|
||||
|
||||
setTarget() {
|
||||
local token=$1
|
||||
local targetBinaryPath=$2
|
||||
local targetUrl=$3
|
||||
local checksum=$(swift package compute-checksum ${targetBinaryPath})
|
||||
|
||||
echo "token=[${token}]"
|
||||
echo "url=[$targetUrl]"
|
||||
echo "cheksum=[$checksum]"
|
||||
|
||||
sed -i '' -e 's|'"${token}_PACKAGE_URL"'|'"${targetUrl}"'|g' Package.swift
|
||||
sed -i '' -e 's|'"${token}_PACKAGE_CHECKSUM"'|'"${checksum}"'|g' Package.swift
|
||||
}
|
||||
|
||||
setTarget "MAPBOX" "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" "${MAPBOX_ZIP_FILE_URL}"
|
||||
|
||||
step "Publishing Swift package…"
|
||||
|
||||
if [[ -z "${DIST_GITHUB_TOKEN}" ]]; then
|
||||
echo "DIST_GITHUB_TOKEN is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UPDATED_PACKAGE_CONTENT=$(cat Package.swift | base64)
|
||||
ORIGINAL_FILE_SHA="$(curl -H "Authorization: token ${DIST_GITHUB_TOKEN}" ${DISTRIBUTION_GITHUB_REPO}/contents/Package.swift | jq -r -c '.sha')"
|
||||
PAYLOAD="{\"message\": \"New release: ${PUBLISH_VERSION}\",\"content\": \"$UPDATED_PACKAGE_CONTENT\", \"sha\": \"$ORIGINAL_FILE_SHA\"}"
|
||||
|
||||
# package definition update
|
||||
curl -v -X PUT \
|
||||
-H "Authorization: token ${DIST_GITHUB_TOKEN}" \
|
||||
"${DISTRIBUTION_GITHUB_REPO}"/contents/Package.swift \
|
||||
-d "${PAYLOAD}"
|
||||
|
||||
# setting up new tag
|
||||
curl -v -X POST \
|
||||
-H "Authorization: token ${DIST_GITHUB_TOKEN}" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
"${DISTRIBUTION_GITHUB_REPO}"/releases \
|
||||
-d "{\"tag_name\":\"${PUBLISH_VERSION}\"}"
|
||||
|
||||
step "Finished deploying ${PUBLISH_VERSION} in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds"
|
||||
44
platform/ios/scripts/deploy-to-cocoapods.sh
Normal file
44
platform/ios/scripts/deploy-to-cocoapods.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This relies on either:
|
||||
# 1. You being authenticated locally with CocoaPods trunk.
|
||||
# 2. The `COCOAPODS_TRUNK_TOKEN` environment variable being set.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
CIRCLE_TAG=${CIRCLE_TAG:-""}
|
||||
|
||||
step "Pushing release to CocoaPods trunk…"
|
||||
|
||||
if [[ $CIRCLE_TAG ]]; then
|
||||
pod trunk push platform/ios/Mapbox-iOS-SDK.podspec --allow-warnings
|
||||
else
|
||||
echo "Skipping push to CocoaPods trunk for untagged build"
|
||||
fi
|
||||
|
||||
step "Pushing release/builds to Mapbox podspecs repo…"
|
||||
|
||||
if [[ -z $(pod repo list | grep -i mapbox-public) ]]; then
|
||||
pod repo add mapbox-public https://github.com/mapbox/pod-specs
|
||||
else
|
||||
echo "Found existing mapbox-public podspecs repo"
|
||||
fi
|
||||
|
||||
if [[ -z $(git config --global user.email) && $CI ]]; then
|
||||
echo "Setting machine user as git committer"
|
||||
git config --global user.email "MapboxCI@users.noreply.github.com"
|
||||
fi
|
||||
|
||||
if [[ $CIRCLE_TAG ]]; then
|
||||
pod repo push mapbox-public platform/ios/Mapbox-iOS-SDK.podspec --allow-warnings
|
||||
pod repo push mapbox-public platform/ios/Mapbox-iOS-SDK-stripped.podspec --allow-warnings
|
||||
else
|
||||
echo "Skipping push of release podspecs to mapbox-public for untagged build"
|
||||
|
||||
# pod repo push mapbox-public platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec --allow-warnings
|
||||
echo "Skipping push of snapshot to mapbox-public until we have a way to update the versions in the snapshot podspec"
|
||||
fi
|
||||
53
platform/ios/scripts/document.sh
Normal file
53
platform/ios/scripts/document.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source ~/.bashrc
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
if [ -z `which jazzy` ]; then
|
||||
echo "jazzy not installed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEFAULT_THEME="platform/darwin/docs/theme"
|
||||
THEME=${JAZZY_THEME:-$DEFAULT_THEME}
|
||||
CUSTOM_HEAD=${JAZZY_CUSTOM_HEAD:-''}
|
||||
OUTPUT=${OUTPUT:-documentation}
|
||||
|
||||
BRANCH=$( git describe --tags --match=ios-v*.*.* --abbrev=0 )
|
||||
SHORT_VERSION=$( echo ${BRANCH} | sed 's/^ios-v//' )
|
||||
RELEASE_VERSION=$( echo ${SHORT_VERSION} | sed -e 's/^ios-v//' -e 's/-.*//' )
|
||||
|
||||
rm -rf /tmp/mbgl
|
||||
mkdir -p /tmp/mbgl/
|
||||
|
||||
step "Generating readme and release notes"
|
||||
README=/tmp/mbgl/README.md
|
||||
npm install --ignore-scripts
|
||||
node platform/ios/scripts/release-notes.js jazzy >> "${README}"
|
||||
|
||||
rm -rf ${OUTPUT}
|
||||
mkdir -p ${OUTPUT}
|
||||
|
||||
cp -r platform/darwin/docs/img "${OUTPUT}"
|
||||
cp -r platform/ios/docs/img "${OUTPUT}"
|
||||
|
||||
step "Generating jazzy docs for ${SHORT_VERSION}…"
|
||||
|
||||
jazzy \
|
||||
--config platform/ios/jazzy.yml \
|
||||
--sdk iphonesimulator \
|
||||
--github-file-prefix https://github.com/mapbox/mapbox-gl-native-ios/tree/${BRANCH} \
|
||||
--module-version ${SHORT_VERSION} \
|
||||
--readme ${README} \
|
||||
--documentation="platform/{darwin,ios}/docs/guides/*.md" \
|
||||
--root-url https://maplibre.org/maplibre-native/ios/api/ \
|
||||
--theme ${THEME} \
|
||||
--head "${CUSTOM_HEAD}" \
|
||||
--output ${OUTPUT} \
|
||||
--title "MapLibre Native for iOS" \
|
||||
--module-version ${SHORT_VERSION}
|
||||
24
platform/ios/scripts/install-packaging-dependencies.sh
Normal file
24
platform/ios/scripts/install-packaging-dependencies.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
COCOAPODS_VERSION="1.7.5"
|
||||
JAZZY_VERSION="0.11.1"
|
||||
CILAUNCH=${CILAUNCH:-false}
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
step "Installing packaging dependencies…"
|
||||
|
||||
##
|
||||
## aws
|
||||
##
|
||||
if [ -z `which aws` ]; then
|
||||
brew install awscli
|
||||
else
|
||||
echo "Found awscli"
|
||||
fi
|
||||
|
||||
step "Finished installing packaging dependencies"
|
||||
31
platform/ios/scripts/ios-code-coverage.sh
Normal file
31
platform/ios/scripts/ios-code-coverage.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
#
|
||||
# Get code coverage report, then convert it to JSON.
|
||||
# The coverage reports end up in different locations based on whether coverage
|
||||
# is generated via CI or locally.
|
||||
#
|
||||
cov_result="";
|
||||
if [ -f build/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport ]; then
|
||||
cov_result=build/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport
|
||||
elif [ -f build/ios/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport ]; then
|
||||
cov_result=build/ios/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport
|
||||
else
|
||||
echo "Coverage file does not exist. Please run tests before executing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
xcrun xccov view $cov_result --json > output.json
|
||||
|
||||
#
|
||||
# Convert the line coverage for the dynamic target to a percentage. Currently,
|
||||
# only CI tests are included when calculated code coverage.
|
||||
#
|
||||
percentage=`node -e "console.log(require('./output.json').lineCoverage)"`
|
||||
cov=$(printf "%.2f" $(echo "$percentage*100" | bc -l))
|
||||
|
||||
# Generate a formatted JSON file and upload it to S3.
|
||||
./././scripts/code-coverage.sh $cov "iOS" "$1"
|
||||
13
platform/ios/scripts/lint-plists.sh
Executable file
13
platform/ios/scripts/lint-plists.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
echo Linting...
|
||||
|
||||
plutil -lint platform/ios/app/Info.plist
|
||||
plutil -lint platform/ios/bench_UITests/Info.plist
|
||||
plutil -lint platform/ios/benchmark/Info.plist
|
||||
plutil -lint platform/ios/framework/Info.plist
|
||||
plutil -lint platform/ios/framework/Info-static.plist
|
||||
plutil -lint platform/ios/Integration_Test_Harness/Info.plist
|
||||
plutil -lint platform/ios/Integration_Tests/Info.plist
|
||||
plutil -lint platform/ios/iosapp-UITests/Info.plist
|
||||
plutil -lint platform/ios/test/Info.plist
|
||||
79
platform/ios/scripts/lint-podspecs.js
Normal file
79
platform/ios/scripts/lint-podspecs.js
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const execSync = require('child_process').execSync;
|
||||
const _ = require('lodash');
|
||||
const semver = require('semver');
|
||||
|
||||
console.step = _.partial(console.log, '\n\033[1m\033[36m*', _, '\033[0m');
|
||||
process.exitCode = 0;
|
||||
|
||||
const podspecsPath = 'platform/ios';
|
||||
|
||||
/*
|
||||
Step 1. Run the official CocoaPods linter against all of our podspecs.
|
||||
*/
|
||||
console.step(`Running CocoaPods linter against podspecs in '${podspecsPath}'`)
|
||||
execSync(`pod spec lint ${podspecsPath}/*.podspec --quick`, {stdio: 'inherit'});
|
||||
|
||||
/*
|
||||
Step 2. Check that our podspecs contain properly formatted version strings.
|
||||
*/
|
||||
console.step('Checking Mapbox SDK version strings in podspecs')
|
||||
const podspecs = fs.readdirSync(podspecsPath).filter(fn => fn.endsWith('.podspec'));
|
||||
|
||||
let matchedVersions = [];
|
||||
|
||||
for (const podspecFilename of podspecs) {
|
||||
console.log(podspecFilename);
|
||||
const podspecContents = fs.readFileSync(`${podspecsPath}/${podspecFilename}`, 'utf8');
|
||||
|
||||
/*
|
||||
This regular expression:
|
||||
- Matches single lines in the format: version = '9.9.9'
|
||||
- Groups the version number inside the single quotes.
|
||||
- Ignores whitespace at the start of the line and between parts of the definition using: \s*?
|
||||
*/
|
||||
const regex = /^\s*?version\s*?=\s*?'(.*)'$/gmi;
|
||||
|
||||
const match = regex.exec(podspecContents);
|
||||
if (!match) {
|
||||
console.error(' ❌ No version string found');
|
||||
process.exitCode = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const matchedVersion = match[1];
|
||||
matchedVersions.push(matchedVersion);
|
||||
|
||||
if (!semver.valid(matchedVersion)) {
|
||||
console.error(` ❌ ${matchedVersion} is not a valid semantic version`);
|
||||
process.exitCode = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(` ✅ ${matchedVersion} is a valid semantic version`);
|
||||
}
|
||||
|
||||
/*
|
||||
Step 3. Check that versions are consistent across our podspecs.
|
||||
*/
|
||||
console.step('Checking version consistency')
|
||||
const uniqueVersions = _.uniq(matchedVersions);
|
||||
if (uniqueVersions.length != 1) {
|
||||
console.error('❌ Versions in podspecs do not match:', uniqueVersions);
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
console.log(`✅ ${uniqueVersions[0]} is set in all podspecs`);
|
||||
}
|
||||
|
||||
/*
|
||||
Step 4. Finish up and summarize the results.
|
||||
*/
|
||||
process.on('exit', (code) => {
|
||||
if (code == 0) {
|
||||
console.log('\nPodspec linting completed successfully! 🕵️♀️');
|
||||
} else {
|
||||
console.log('\nPodspec linting failed. 💥');
|
||||
}
|
||||
});
|
||||
26
platform/ios/scripts/metrics.sh
Normal file
26
platform/ios/scripts/metrics.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
# Generate stripped versions for every architecture
|
||||
xcrun bitcode_strip build/ios/pkg/dynamic/Mapbox.framework/Mapbox -r -o build/ios/pkg/dynamic/Mapbox-stripped
|
||||
strip -Sx build/ios/pkg/dynamic/Mapbox-stripped
|
||||
lipo build/ios/pkg/dynamic/Mapbox-stripped -extract armv7 -output build/ios/pkg/dynamic/Mapbox-stripped-armv7
|
||||
lipo build/ios/pkg/dynamic/Mapbox-stripped -extract arm64 -output build/ios/pkg/dynamic/Mapbox-stripped-arm64
|
||||
lipo build/ios/pkg/dynamic/Mapbox-stripped -extract x86_64 -output build/ios/pkg/dynamic/Mapbox-stripped-x86_64
|
||||
|
||||
# Track individual architectures
|
||||
scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped-armv7" "iOS armv7"
|
||||
scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped-arm64" "iOS arm64"
|
||||
scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped-x86_64" "iOS x86_64"
|
||||
|
||||
# Track overall library size
|
||||
scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped" "iOS Dynamic"
|
||||
|
||||
if [[ $CIRCLE_BRANCH == main ]]; then
|
||||
# Build source data for http://mapbox.github.io/mapbox-gl-native/metrics/binary-size/
|
||||
# and log binary sizes to metrics warehouse
|
||||
scripts/publish_binary_size.js
|
||||
fi
|
||||
|
||||
275
platform/ios/scripts/package.sh
Normal file
275
platform/ios/scripts/package.sh
Normal file
@@ -0,0 +1,275 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
set -u
|
||||
|
||||
NAME=Mapbox
|
||||
OUTPUT=build/ios/pkg
|
||||
DERIVED_DATA=build/ios
|
||||
PRODUCTS=${DERIVED_DATA}
|
||||
LOG_PATH=build/xcodebuild-$(date +"%Y-%m-%d_%H%M%S").log
|
||||
|
||||
BUILD_FOR_DEVICE=${BUILD_DEVICE:-true}
|
||||
BUILD_DOCS=${BUILD_DOCS:-true}
|
||||
SYMBOLS=${SYMBOLS:-YES}
|
||||
|
||||
BUILDTYPE=${BUILDTYPE:-Debug}
|
||||
if [[ ${SYMBOLS} == YES && ${BUILDTYPE} == Release ]]; then
|
||||
BUILDTYPE='RelWithDebInfo'
|
||||
fi
|
||||
|
||||
FORMAT=${FORMAT:-dynamic}
|
||||
BUILD_DYNAMIC=true
|
||||
BUILD_STATIC=false
|
||||
INCLUDE_EVENTS_IN_PACKAGE=false
|
||||
if [[ ${FORMAT} == "static" ]]; then
|
||||
BUILD_STATIC=true
|
||||
BUILD_DYNAMIC=false
|
||||
elif [[ ${FORMAT} == "dynamic-with-events" ]]; then
|
||||
INCLUDE_EVENTS_IN_PACKAGE=true
|
||||
elif [[ ${FORMAT} == "stripped-dynamic" ]]; then
|
||||
echo "Packaging for stripped-dynamic"
|
||||
elif [[ ${FORMAT} != "dynamic" ]]; then
|
||||
echo "Error: FORMAT must be dynamic or static."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
SDK=iphonesimulator
|
||||
if [[ ${BUILD_FOR_DEVICE} == true ]]; then
|
||||
SDK=iphoneos
|
||||
fi
|
||||
IOS_SDK_VERSION=`xcrun --sdk ${SDK} --show-sdk-version`
|
||||
|
||||
step "Configuring ${FORMAT} framework for ${SDK} ${IOS_SDK_VERSION} (symbols: ${SYMBOLS}, buildtype: ${BUILDTYPE}, include events:${INCLUDE_EVENTS_IN_PACKAGE})"
|
||||
|
||||
xcodebuild -version
|
||||
|
||||
rm -rf ${OUTPUT}
|
||||
if [[ ${BUILD_STATIC} == true ]]; then
|
||||
mkdir -p "${OUTPUT}"/static
|
||||
fi
|
||||
if [[ ${BUILD_DYNAMIC} == true ]]; then
|
||||
mkdir -p "${OUTPUT}"/dynamic
|
||||
fi
|
||||
|
||||
step "Recording library version…"
|
||||
VERSION="${OUTPUT}"/version.txt
|
||||
echo -n "https://github.com/maplibre/maplibre-native/commit/" > ${VERSION}
|
||||
HASH=`git log | head -1 | awk '{ print $2 }' | cut -c 1-10` && true
|
||||
echo -n "maplibre-gl-native-ios "
|
||||
echo ${HASH}
|
||||
echo ${HASH} >> ${VERSION}
|
||||
|
||||
PROJ_VERSION=$(git rev-list --count HEAD)
|
||||
SEM_VERSION=$( git describe --tags --match=ios-v*.*.* --abbrev=0 | sed 's/^ios-v//' )
|
||||
SHORT_VERSION=${SEM_VERSION%-*}
|
||||
|
||||
step "Building targets (build ${PROJ_VERSION}, version ${SEM_VERSION})"
|
||||
|
||||
SCHEME='dynamic'
|
||||
if [[ ${BUILD_STATIC} == true ]]; then
|
||||
SCHEME='static'
|
||||
fi
|
||||
|
||||
CI_XCCONFIG=''
|
||||
if [[ ! -z "${CI:=}" ]]; then
|
||||
xcconfig='platform/darwin/ci.xcconfig'
|
||||
echo "CI environment, using ${xcconfig}"
|
||||
CI_XCCONFIG="-xcconfig ./${xcconfig}"
|
||||
fi
|
||||
|
||||
step "Building ${FORMAT} framework for iOS Simulator using ${SCHEME} scheme"
|
||||
xcodebuild \
|
||||
CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \
|
||||
CURRENT_COMMIT_HASH=${HASH} \
|
||||
ONLY_ACTIVE_ARCH=NO \
|
||||
${CI_XCCONFIG} \
|
||||
-derivedDataPath ${DERIVED_DATA} \
|
||||
-workspace ./platform/ios/ios.xcworkspace \
|
||||
-scheme ${SCHEME} \
|
||||
-configuration ${BUILDTYPE} \
|
||||
-sdk iphonesimulator \
|
||||
-jobs ${JOBS} | tee ${LOG_PATH} | xcpretty
|
||||
|
||||
if [[ ${BUILD_FOR_DEVICE} == true ]]; then
|
||||
step "Building ${FORMAT} framework for iOS devices using ${SCHEME} scheme"
|
||||
xcodebuild \
|
||||
CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \
|
||||
CURRENT_COMMIT_HASH=${HASH} \
|
||||
ONLY_ACTIVE_ARCH=NO \
|
||||
${CI_XCCONFIG} \
|
||||
-derivedDataPath ${DERIVED_DATA} \
|
||||
-workspace ./platform/ios/ios.xcworkspace \
|
||||
-scheme ${SCHEME} \
|
||||
-configuration ${BUILDTYPE} \
|
||||
-sdk iphoneos \
|
||||
-jobs ${JOBS} | tee ${LOG_PATH} | xcpretty
|
||||
fi
|
||||
|
||||
LIBS=(Mapbox.a)
|
||||
|
||||
|
||||
function copyAndMakeFatFramework {
|
||||
local NAME=$1
|
||||
|
||||
step "Copying ${NAME} dynamic framework into place for iOS devices"
|
||||
cp -r \
|
||||
${PRODUCTS}/${BUILDTYPE}-iphoneos/${NAME}.framework \
|
||||
${OUTPUT}/dynamic/
|
||||
|
||||
if [[ -e ${PRODUCTS}/${BUILDTYPE}-iphoneos/${NAME}.framework.dSYM ]]; then
|
||||
step "Copying ${NAME} dSYM"
|
||||
cp -r ${PRODUCTS}/${BUILDTYPE}-iphoneos/${NAME}.framework.dSYM \
|
||||
${OUTPUT}/dynamic/
|
||||
if [[ -e ${PRODUCTS}/${BUILDTYPE}-iphonesimulator/${NAME}.framework.dSYM ]]; then
|
||||
step "Merging device and simulator dSYMs…"
|
||||
lipo \
|
||||
${PRODUCTS}/${BUILDTYPE}-iphoneos/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME} \
|
||||
${PRODUCTS}/${BUILDTYPE}-iphonesimulator/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME} \
|
||||
-create -output ${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}
|
||||
lipo -info ${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}
|
||||
fi
|
||||
fi
|
||||
|
||||
step "Merging ${NAME} simulator dynamic library into device dynamic library…"
|
||||
lipo \
|
||||
${PRODUCTS}/${BUILDTYPE}-iphoneos/${NAME}.framework/${NAME} \
|
||||
${PRODUCTS}/${BUILDTYPE}-iphonesimulator/${NAME}.framework/${NAME} \
|
||||
-create -output ${OUTPUT}/dynamic/${NAME}.framework/${NAME} | echo
|
||||
}
|
||||
|
||||
|
||||
# https://medium.com/@syshen/create-an-ios-universal-framework-148eb130a46c
|
||||
if [[ ${BUILD_FOR_DEVICE} == true ]]; then
|
||||
if [[ ${BUILD_STATIC} == true ]]; then
|
||||
step "Assembling static framework for iOS Simulator and devices…"
|
||||
mkdir -p ${OUTPUT}/static/${NAME}.framework
|
||||
libtool -static -no_warning_for_no_symbols \
|
||||
-o ${OUTPUT}/static/${NAME}.framework/${NAME} \
|
||||
${LIBS[@]/#/${PRODUCTS}/${BUILDTYPE}-iphoneos/lib} \
|
||||
${LIBS[@]/#/${PRODUCTS}/${BUILDTYPE}-iphonesimulator/lib} \
|
||||
`cmake -LA -N ${DERIVED_DATA} | grep MASON_PACKAGE_icu_LIBRARIES | cut -d= -f2`
|
||||
|
||||
cp -rv ${PRODUCTS}/${BUILDTYPE}-iphoneos/${NAME}.bundle ${OUTPUT}/static
|
||||
fi
|
||||
|
||||
if [[ ${BUILD_DYNAMIC} == true ]]; then
|
||||
copyAndMakeFatFramework "${NAME}"
|
||||
|
||||
if [[ ${INCLUDE_EVENTS_IN_PACKAGE} == true ]]; then
|
||||
copyAndMakeFatFramework "MapboxMobileEvents"
|
||||
fi
|
||||
|
||||
# Bundling mapbox-events-ios
|
||||
fi
|
||||
|
||||
cp -rv platform/ios/app/Settings.bundle ${OUTPUT}
|
||||
else
|
||||
if [[ ${BUILD_STATIC} == true ]]; then
|
||||
step "Assembling static library for iOS Simulator…"
|
||||
mkdir -p ${OUTPUT}/static/${NAME}.framework
|
||||
libtool -static -no_warning_for_no_symbols \
|
||||
-o ${OUTPUT}/static/${NAME}.framework/${NAME} \
|
||||
${LIBS[@]/#/${PRODUCTS}/${BUILDTYPE}-iphonesimulator/lib} \
|
||||
`cmake -LA -N ${DERIVED_DATA} | grep MASON_PACKAGE_icu_LIBRARIES | cut -d= -f2`
|
||||
|
||||
cp -rv ${PRODUCTS}/${BUILDTYPE}-iphonesimulator/${NAME}.bundle ${OUTPUT}/static
|
||||
fi
|
||||
|
||||
if [[ ${BUILD_DYNAMIC} == true ]]; then
|
||||
step "Copying dynamic framework into place for iOS Simulator…"
|
||||
cp -r \
|
||||
${PRODUCTS}/${BUILDTYPE}-iphonesimulator/${NAME}.framework \
|
||||
${OUTPUT}/dynamic/${NAME}.framework
|
||||
if [[ -e ${PRODUCTS}/${BUILDTYPE}-iphonesimulator/${NAME}.framework.dSYM ]]; then
|
||||
step "Copying dSYM"
|
||||
cp -r ${PRODUCTS}/${BUILDTYPE}-iphonesimulator/${NAME}.framework.dSYM \
|
||||
${OUTPUT}/dynamic/
|
||||
fi
|
||||
fi
|
||||
|
||||
cp -rv platform/ios/app/Settings.bundle ${OUTPUT}
|
||||
fi
|
||||
|
||||
function get_comparable_uuid {
|
||||
echo $(dwarfdump --uuid ${1} | sed -n 's/.*UUID:\([^\"]*\) .*/\1/p' | sort)
|
||||
}
|
||||
|
||||
function validate_dsym {
|
||||
step "Validating dSYM and framework UUIDs…"
|
||||
DSYM_UUID=$(get_comparable_uuid "${1}")
|
||||
FRAMEWORK_UUID=$(get_comparable_uuid "${2}")
|
||||
echo -e "${1}\n ${DSYM_UUID}\n${2}\n ${FRAMEWORK_UUID}"
|
||||
if [[ ${DSYM_UUID} != ${FRAMEWORK_UUID} ]]; then
|
||||
echo "Error: dSYM and framework UUIDs do not match."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function removeSimulatorSlice {
|
||||
local NAME=$1
|
||||
|
||||
validate_dsym \
|
||||
"${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}" \
|
||||
"${OUTPUT}/dynamic/${NAME}.framework/${NAME}"
|
||||
|
||||
step "Removing i386 slice from ${NAME} dSYM"
|
||||
lipo -remove i386 "${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}" -o "${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}"
|
||||
lipo -info "${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}"
|
||||
}
|
||||
|
||||
|
||||
if [[ ${BUILD_DYNAMIC} == true && ${BUILDTYPE} == Release ]]; then
|
||||
removeSimulatorSlice "${NAME}"
|
||||
|
||||
if [[ ${INCLUDE_EVENTS_IN_PACKAGE} == true ]]; then
|
||||
removeSimulatorSlice MapboxMobileEvents
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ${BUILD_STATIC} == true ]]; then
|
||||
step "Copying static library headers…"
|
||||
cp -rv "${PRODUCTS}/${BUILDTYPE}-${SDK}/Headers" "${OUTPUT}/static/${NAME}.framework/Headers"
|
||||
cat platform/ios/framework/Mapbox-static.h > "${OUTPUT}/static/${NAME}.framework/Headers/Mapbox.h"
|
||||
cat "${PRODUCTS}/${BUILDTYPE}-${SDK}/Headers/Mapbox.h" >> "${OUTPUT}/static/${NAME}.framework/Headers/Mapbox.h"
|
||||
fi
|
||||
|
||||
step "Copying library resources…"
|
||||
cp -pv LICENSE.md ${OUTPUT}
|
||||
if [[ ${BUILD_STATIC} == true ]]; then
|
||||
cp -pv "${OUTPUT}/static/${NAME}.bundle/Info.plist" "${OUTPUT}/static/${NAME}.framework/Info.plist"
|
||||
plutil -replace CFBundlePackageType -string FMWK "${OUTPUT}/static/${NAME}.framework/Info.plist"
|
||||
mkdir "${OUTPUT}/static/${NAME}.framework/Modules"
|
||||
cp -pv platform/ios/framework/modulemap "${OUTPUT}/static/${NAME}.framework/Modules/module.modulemap"
|
||||
fi
|
||||
if [[ ${BUILD_DYNAMIC} == true && ${BUILD_FOR_DEVICE} == true ]]; then
|
||||
step "Copying bitcode symbol maps…"
|
||||
find "${PRODUCTS}/${BUILDTYPE}-iphoneos" -name '*.bcsymbolmap' -type f -exec cp -pv {} "${OUTPUT}/dynamic/" \;
|
||||
fi
|
||||
sed -n -e '/^## /,$p' platform/ios/CHANGELOG.md > "${OUTPUT}/CHANGELOG.md"
|
||||
|
||||
rm -rf /tmp/mbgl
|
||||
mkdir -p /tmp/mbgl/
|
||||
README=/tmp/mbgl/README.md
|
||||
cp platform/ios/docs/pod-README.md "${README}"
|
||||
if [[ ${BUILD_DYNAMIC} == false ]]; then
|
||||
sed -i '' -e '/{{DYNAMIC}}/,/{{\/DYNAMIC}}/d' "${README}"
|
||||
fi
|
||||
if [[ ${BUILD_STATIC} == false ]]; then
|
||||
sed -i '' -e '/{{STATIC}}/,/{{\/STATIC}}/d' "${README}"
|
||||
fi
|
||||
sed -i '' \
|
||||
-e '/{{DYNAMIC}}/d' -e '/{{\/DYNAMIC}}/d' \
|
||||
-e '/{{STATIC}}/d' -e '/{{\/STATIC}}/d' \
|
||||
"${README}"
|
||||
cp ${README} "${OUTPUT}"
|
||||
|
||||
if [ ${BUILD_DOCS} == true ]; then
|
||||
step "Generating API documentation for ${BUILDTYPE} Build…"
|
||||
make idocument OUTPUT="${OUTPUT}/documentation"
|
||||
fi
|
||||
91
platform/ios/scripts/publish.sh
Normal file
91
platform/ios/scripts/publish.sh
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
#
|
||||
# iOS release tag format is `vX.Y.Z`; `X.Y.Z` gets passed in
|
||||
# In the case of stripped builds, we also append the `-stripped`.
|
||||
#
|
||||
PUBLISH_VERSION="$1"
|
||||
|
||||
if [[ ${#} -eq 2 ]]; then
|
||||
PUBLISH_STYLE="-$2"
|
||||
else
|
||||
PUBLISH_STYLE=""
|
||||
fi
|
||||
|
||||
GITHUB_REPO=${GITHUB_REPO:-'maplibre-native'}
|
||||
|
||||
#
|
||||
# zip
|
||||
#
|
||||
cd build/ios/pkg
|
||||
BINARY_ARTIFACT_ZIP_FILE="mapbox-ios-sdk-${PUBLISH_VERSION}${PUBLISH_STYLE}.zip"
|
||||
step "Compressing ${BINARY_ARTIFACT_ZIP_FILE}…"
|
||||
rm -f ../${BINARY_ARTIFACT_ZIP_FILE}
|
||||
zip -yr ../${BINARY_ARTIFACT_ZIP_FILE} *
|
||||
cd ..
|
||||
|
||||
#
|
||||
# report file sizes
|
||||
#
|
||||
step "Echoing file sizes…"
|
||||
du -sh ${BINARY_ARTIFACT_ZIP_FILE}
|
||||
du -sch pkg/*
|
||||
du -sch pkg/dynamic/*
|
||||
|
||||
#
|
||||
# upload
|
||||
#
|
||||
DRYRUN=""
|
||||
if [[ ${SKIP_S3-} ]]; then
|
||||
DRYRUN="--dryrun"
|
||||
fi
|
||||
|
||||
PROGRESS=""
|
||||
if [ -n "${CI:-}" ]; then
|
||||
PROGRESS="--no-progress"
|
||||
fi
|
||||
|
||||
step "Uploading ${BINARY_ARTIFACT_ZIP_FILE} to s3… ${DRYRUN}"
|
||||
|
||||
aws s3 cp ${BINARY_ARTIFACT_ZIP_FILE} s3://mapbox-gl-native/ios/builds --acl public-read ${PROGRESS} ${DRYRUN}
|
||||
BINARY_ARTIFACT_URL=https://mapbox-gl-native.s3.us-east-2.amazonaws.com/ios/builds/${BINARY_ARTIFACT_ZIP_FILE}
|
||||
export BINARY_ARTIFACT_URL
|
||||
export BINARY_ARTIFACT_ZIP_FILE
|
||||
echo "URL: ${BINARY_ARTIFACT_URL}"
|
||||
echo "mapbox-gl-native is currently hardcoded"
|
||||
|
||||
#
|
||||
# upload & update snapshot
|
||||
#
|
||||
if [[ ${PUBLISH_VERSION} =~ "snapshot" ]]; then
|
||||
step "Updating ${PUBLISH_VERSION} to ${PUBLISH_STYLE}…"
|
||||
GENERIC_BINARY_ARTIFACT_ZIP_FILE="mapbox-ios-sdk-${PUBLISH_VERSION}.zip"
|
||||
aws s3 cp \
|
||||
s3://mapbox-gl-native/ios/builds/${BINARY_ARTIFACT_ZIP_FILE} \
|
||||
s3://mapbox-gl-native/ios/builds/${GENERIC_BINARY_ARTIFACT_ZIP_FILE} --acl public-read ${PROGRESS} ${DRYRUN}
|
||||
fi
|
||||
|
||||
#
|
||||
# verify upload integrity
|
||||
#
|
||||
|
||||
step "Validating local and remote checksums…"
|
||||
|
||||
if [[ ! ${SKIP_S3-} ]]; then
|
||||
curl --output remote-${BINARY_ARTIFACT_ZIP_FILE} ${BINARY_ARTIFACT_URL}
|
||||
LOCAL_CHECKSUM=$( shasum -a 256 -b ${BINARY_ARTIFACT_ZIP_FILE} | cut -d ' ' -f 1 )
|
||||
REMOTE_CHECKSUM=$( shasum -a 256 -b remote-${BINARY_ARTIFACT_ZIP_FILE} | cut -d ' ' -f 1 )
|
||||
|
||||
if [ "${LOCAL_CHECKSUM}" == "${REMOTE_CHECKSUM}" ]; then
|
||||
echo "Checksums match: ${LOCAL_CHECKSUM}"
|
||||
else
|
||||
echo "Checksums did not match: ${LOCAL_CHECKSUM} != ${REMOTE_CHECKSUM}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
2
platform/ios/scripts/release-notes-github.md.ejs
Normal file
2
platform/ios/scripts/release-notes-github.md.ejs
Normal file
@@ -0,0 +1,2 @@
|
||||
<%-CHANGELOG-%>
|
||||
|
||||
21
platform/ios/scripts/release-notes-jazzy.md.ejs
Normal file
21
platform/ios/scripts/release-notes-jazzy.md.ejs
Normal file
@@ -0,0 +1,21 @@
|
||||
# MapLibre Native for iOS
|
||||
|
||||
MapLibre Native for iOS is an open-source framework for embedding interactive map views with scalable, customizable vector maps into Cocoa Touch applications on iOS 9.0 and above using Objective-C, Swift, or Interface Builder. It takes stylesheets that conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/), applies them to vector tiles that conform to the [Mapbox Vector Tile Specification](https://docs.mapbox.com/data/tilesets/guides/vector-tiles-standards/), and renders them using OpenGL.
|
||||
|
||||

|
||||
|
||||
We welcome your [bug reports, feature requests, and contributions](https://github.com/maplibre/maplibre-native/issues).
|
||||
|
||||
## Changes in version <%-CURRENTVERSION%>
|
||||
|
||||
<%-CURRENTCHANGELOG%>
|
||||
|
||||
## Recent changes
|
||||
|
||||
<% OTHERRELEASES.forEach(function(release) { %>
|
||||
### <%-release.version%>
|
||||
|
||||
<%-release.changelog%>
|
||||
<% }) -%>
|
||||
|
||||
See the [full changelog](https://github.com/maplibre/maplibre-native/blob/main/platform/ios/platform/ios/CHANGELOG.md) for previous releases.
|
||||
103
platform/ios/scripts/release-notes.js
Normal file
103
platform/ios/scripts/release-notes.js
Normal file
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const execSync = require('child_process').execSync;
|
||||
const ejs = require('ejs');
|
||||
const _ = require('lodash');
|
||||
const semver = require('semver');
|
||||
|
||||
const changelogPath = 'platform/ios/CHANGELOG.md';
|
||||
const changelog = fs.readFileSync(changelogPath, 'utf8');
|
||||
|
||||
let outputMode = {};
|
||||
switch(process.argv[2]) {
|
||||
case "jazzy":
|
||||
outputMode.isJazzy = true; break;
|
||||
case "github":
|
||||
default:
|
||||
outputMode.isGitHub = true;
|
||||
}
|
||||
|
||||
/*
|
||||
Find current and immediately previous releases by parsing git tags.
|
||||
*/
|
||||
let currentVersion = execSync('git describe --tags --match=ios-v*.*.* --abbrev=0')
|
||||
.toString()
|
||||
.trim()
|
||||
.replace('ios-v', '');
|
||||
|
||||
let gitTags = execSync('git tag --list ios-v*.*.*')
|
||||
.toString()
|
||||
.split('\n')
|
||||
.map(function (tag) {
|
||||
tag = tag.replace('ios-v', '').trim();
|
||||
return semver.clean(tag);
|
||||
});
|
||||
let previousVersion = semver.maxSatisfying(gitTags, "<" + currentVersion);
|
||||
|
||||
/*
|
||||
Parse the raw changelog text and split it into individual releases.
|
||||
|
||||
This regular expression:
|
||||
- Matches lines starting with "## x.x.x".
|
||||
- Groups the version number.
|
||||
- Skips the (optional) release date.
|
||||
- Groups the changelog content.
|
||||
- Ends when another "## x.x.x" is found.
|
||||
*/
|
||||
const regex = /^## (\d+\.\d+\.\d+).*?\n(.+?)(?=\n^## \d+\.\d+\.\d+.*?\n)/gms;
|
||||
|
||||
let releaseNotes = [];
|
||||
while (match = regex.exec(changelog)) {
|
||||
releaseNotes.push({
|
||||
'version': match[1],
|
||||
'changelog': match[2].trim(),
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
Match the current tag with the most appropriate release notes.
|
||||
*/
|
||||
const versionsInReleaseNotes = _.map(releaseNotes, 'version');
|
||||
const bestReleaseNotesForCurrentVersion = semver.minSatisfying(versionsInReleaseNotes, ">=" + currentVersion);
|
||||
const currentReleaseNotes = _.find(releaseNotes, { version: bestReleaseNotesForCurrentVersion });
|
||||
|
||||
if (!currentReleaseNotes) {
|
||||
console.error('Could not find a release section satisfying %s in %s — did you forget to rename the "main" section to %s?', currentVersion, changelogPath, currentVersion.split("-")[0]);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
Fill and print the release notes template.
|
||||
*/
|
||||
let templatedReleaseNotes;
|
||||
|
||||
if (outputMode.isGitHub) {
|
||||
templatedReleaseNotes = ejs.render(fs.readFileSync('platform/ios/scripts/release-notes-github.md.ejs', 'utf8'), {
|
||||
'CURRENTVERSION': currentVersion,
|
||||
'PREVIOUSVERSION': previousVersion,
|
||||
'CHANGELOG': currentReleaseNotes.changelog,
|
||||
'isPrerelease': semver.prerelease(currentVersion)
|
||||
});
|
||||
}
|
||||
|
||||
if (outputMode.isJazzy) {
|
||||
const minorReleaseSeries = semver.major(currentVersion) + "." + semver.minor(currentVersion) + ".0";
|
||||
const range = ">=" + minorReleaseSeries + " <" + currentVersion;
|
||||
const otherReleasesInSeries = _.filter(releaseNotes, function(release) {
|
||||
return semver.satisfies(release.version, range);
|
||||
});
|
||||
|
||||
otherReleasesInSeries.forEach(function(release) {
|
||||
// Bump section headings from h3 to h4.
|
||||
release.changelog = release.changelog.replace(/^### /gm, '#### ');
|
||||
});
|
||||
|
||||
templatedReleaseNotes = ejs.render(fs.readFileSync('platform/ios/scripts/release-notes-jazzy.md.ejs', 'utf8'), {
|
||||
'CURRENTVERSION': currentVersion,
|
||||
'CURRENTCHANGELOG': currentReleaseNotes.changelog,
|
||||
'OTHERRELEASES': otherReleasesInSeries
|
||||
});
|
||||
}
|
||||
|
||||
process.stdout.write(templatedReleaseNotes);
|
||||
@@ -1,18 +0,0 @@
|
||||
include(cmake/mason.cmake)
|
||||
|
||||
# include once for every platform to get all dependency defines
|
||||
set(MLN_PLATFORM "android")
|
||||
include(cmake/mason-dependencies.cmake)
|
||||
set(MLN_PLATFORM "ios")
|
||||
include(cmake/mason-dependencies.cmake)
|
||||
|
||||
get_cmake_property(_VARS VARIABLES)
|
||||
foreach (_VAR ${_VARS})
|
||||
if (_VAR MATCHES "^MASON_PACKAGE_.+_NAME$")
|
||||
set(_PACKAGE "${${_VAR}}")
|
||||
if (MASON_PACKAGE_${_PACKAGE}_HEADER_ONLY)
|
||||
file(RELATIVE_PATH _PREFIX "${CMAKE_CURRENT_LIST_DIR}/.." "${MASON_PACKAGE_${_PACKAGE}_PREFIX}")
|
||||
message("${_PACKAGE} ${_PREFIX} ${MASON_PACKAGE_${_PACKAGE}_VERSION}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
19
platform/ios/scripts/swift_package_template.swift
Normal file
19
platform/ios/scripts/swift_package_template.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
// swift-tools-version:5.3
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "MapLibre Native",
|
||||
products: [
|
||||
.library(
|
||||
name: "Mapbox",
|
||||
targets: ["Mapbox"])
|
||||
],
|
||||
dependencies: [
|
||||
],
|
||||
targets: [
|
||||
.binaryTarget(
|
||||
name: "Mapbox",
|
||||
url: "MAPBOX_PACKAGE_URL",
|
||||
checksum: "MAPBOX_PACKAGE_CHECKSUM")
|
||||
]
|
||||
)
|
||||
71
platform/ios/scripts/update-swift-package.sh
Normal file
71
platform/ios/scripts/update-swift-package.sh
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
set -u
|
||||
|
||||
# USE THIS SCRIPT ONLY FOR MANUAL UPDATE
|
||||
# IN CASE AUTOPMATED DEPLOY FAILS
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
step "Creating Swift package…"
|
||||
|
||||
rm -f Package.swift
|
||||
cp platform/ios/scripts/swift_package_template.swift Package.swift
|
||||
|
||||
export GITHUB_USER=maplibre
|
||||
export GITHUB_REPO=maplibre-native
|
||||
export BUILDTYPE=Release
|
||||
export DISTRIBUTION_GITHUB_REPO=https://api.github.com/repos/maplibre/maplibre-gl-native-distribution
|
||||
|
||||
VERSION_TAG="ios-v5.11.0"
|
||||
PUBLISH_VERSION="5.11.0"
|
||||
BINARY_DIRECTORY='/Volumes/Data/Temp/maplibre'
|
||||
PUBLISH_PRE_FLAG=''
|
||||
S3_DISTRIBUTION=false
|
||||
MAPBOX_ZIP_FILE_URL="https://github.com/maplibre/maplibre-native/releases/download/ios-v5.11.0/Mapbox-5.11.0.zip"
|
||||
MAPBOX_ZIP_FILE="Mapbox-5.11.0.zip"
|
||||
DIST_GITHUB_TOKEN="PUT YOUR TOKEN HERE:"
|
||||
|
||||
setTarget() {
|
||||
local token=$1
|
||||
local targetBinaryPath=$2
|
||||
local targetUrl=$3
|
||||
local checksum=$(swift package compute-checksum ${targetBinaryPath})
|
||||
|
||||
echo "token=[${token}]"
|
||||
echo "url=[$targetUrl]"
|
||||
echo "cheksum=[$checksum]"
|
||||
|
||||
sed -i '' -e 's|'"${token}_PACKAGE_URL"'|'"${targetUrl}"'|g' Package.swift
|
||||
sed -i '' -e 's|'"${token}_PACKAGE_CHECKSUM"'|'"${checksum}"'|g' Package.swift
|
||||
}
|
||||
|
||||
setTarget "MAPBOX" "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" "${MAPBOX_ZIP_FILE_URL}"
|
||||
|
||||
step "Publishing Swift package…"
|
||||
|
||||
if [[ -z "${DIST_GITHUB_TOKEN}" ]]; then
|
||||
echo "DIST_GITHUB_TOKEN is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UPDATED_PACKAGE_CONTENT=$(cat Package.swift | base64)
|
||||
ORIGINAL_FILE_SHA="$(curl -H "Authorization: token ${DIST_GITHUB_TOKEN}" ${DISTRIBUTION_GITHUB_REPO}/contents/Package.swift | jq -r -c '.sha')"
|
||||
PAYLOAD="{\"message\": \"New release: ${PUBLISH_VERSION}\",\"content\": \"$UPDATED_PACKAGE_CONTENT\", \"sha\": \"$ORIGINAL_FILE_SHA\"}"
|
||||
|
||||
# package definition update
|
||||
curl -v -X PUT \
|
||||
-H "Authorization: token ${DIST_GITHUB_TOKEN}" \
|
||||
"${DISTRIBUTION_GITHUB_REPO}"/contents/Package.swift \
|
||||
-d "${PAYLOAD}"
|
||||
|
||||
# setting up new tag
|
||||
curl -v -X POST \
|
||||
-H "Authorization: token ${DIST_GITHUB_TOKEN}" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
"${DISTRIBUTION_GITHUB_REPO}"/releases \
|
||||
-d "{\"tag_name\":\"${PUBLISH_VERSION}\"}"
|
||||
32
platform/ios/scripts/update-version.sh
Normal file
32
platform/ios/scripts/update-version.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
set -u
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: v<semantic version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SEM_VERSION=$1
|
||||
SEM_VERSION=${SEM_VERSION/#macos-}
|
||||
SEM_VERSION=${SEM_VERSION/#v}
|
||||
SHORT_VERSION=${SEM_VERSION%-*}
|
||||
|
||||
step "Version ${SEM_VERSION}"
|
||||
|
||||
cd platform/ios/
|
||||
|
||||
step "Updating Xcode targets to version ${SHORT_VERSION}…"
|
||||
|
||||
xcrun agvtool bump -all
|
||||
xcrun agvtool new-marketing-version "${SHORT_VERSION}"
|
||||
|
||||
step "Updating CocoaPods podspecs to version ${SEM_VERSION}…"
|
||||
|
||||
find . -type f -name '*.podspec' -exec sed -i '' "s/^ *version *=.*$/ version = '${SEM_VERSION}'/" {} +
|
||||
131
platform/ios/scripts/validate-framework-zip.sh
Normal file
131
platform/ios/scripts/validate-framework-zip.sh
Normal file
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env bash
|
||||
# Created by Cory Dolphin on 03/21/16.
|
||||
# Copyright (c) 2016 Twitter. All rights reserved.
|
||||
|
||||
# Verifies a zip archive submission of SDKs passes basic static checks for format and contents.
|
||||
# This test is likely to generate false positives, e.g. even if your SDK passes this, you still must
|
||||
# test integration of your code fully.
|
||||
|
||||
# Usage: $ ./validate_zip.sh <path to zip>
|
||||
|
||||
set -e
|
||||
|
||||
if [ ! -f "$1" ]; then
|
||||
printf "No file found at ${1}\n"
|
||||
printf "Usage: $ ./validate_zip.sh <path to zip>\n"; exit 1;
|
||||
fi
|
||||
|
||||
function verifyFramework() {
|
||||
# set -x
|
||||
local FRAMEWORK_PATH=$1
|
||||
local FRAMEWORK_NAME=$(basename $FRAMEWORK_PATH)
|
||||
local PRODUCT="${FRAMEWORK_NAME%.*}"
|
||||
local BINARY_PATH="${FRAMEWORK_PATH}/${PRODUCT}"
|
||||
local HEADER_PATH="${FRAMEWORK_PATH}/Headers"
|
||||
printf "Found $FRAMEWORK_NAME. Verifying...\n"
|
||||
|
||||
local MODULE_MAP=( $(find $FRAMEWORK_PATH -name "*.modulemap") )
|
||||
if [[ -z "$MODULE_MAP" ]]; then
|
||||
printf "ERROR: No modulemap found in $FRAMEWORK_NAME\n";
|
||||
exit 3;
|
||||
fi
|
||||
printf "$FRAMEWORK_NAME contains modulemap: ✓\n"
|
||||
|
||||
# Verify there is a modulemap so Swift can use the framework
|
||||
if grep -q "link" "$MODULE_MAP"; then
|
||||
printf "$FRAMEWORK_NAME modulemap contains dependent system frameworks ✓\n"
|
||||
else
|
||||
printf "Warning: ${FRAMEWORK_NAME} does not list any system library dependencies. Double check all dependent frameworks and libraries are listed. \n";
|
||||
fi
|
||||
|
||||
# Verify there is at least one header listed in the module map
|
||||
if grep -q ".*.h" "$MODULE_MAP"; then
|
||||
printf "$FRAMEWORK_NAME modulemap contains headers ✓\n";
|
||||
else
|
||||
printf "Error: ${FRAMEWORK_NAME} does not list any headers in the modulemap\n";
|
||||
exit 4;
|
||||
fi
|
||||
|
||||
# Verify there is at least a headers folder
|
||||
if [[ ! -d "$HEADER_PATH" ]]; then
|
||||
printf "ERROR: Headers not not found in ${FRAMEWORK_NAME}\n";
|
||||
exit 5;
|
||||
fi
|
||||
|
||||
# Verify the static lib at least has simulator and the two common ARM architectures
|
||||
local PRESENT_ARCHITECTURES=$( xcrun lipo -info "${BINARY_PATH}" )
|
||||
for arch in "armv7" "arm64" "x86_64"; do
|
||||
if [[ ! $PRESENT_ARCHITECTURES == *$arch* ]]; then
|
||||
printf "ERROR: Architecture ${arch} not found in ${FRAMEWORK_NAME}\n";
|
||||
exit 6;
|
||||
fi
|
||||
done
|
||||
printf "$FRAMEWORK_NAME contains simulator and device architectures: ✓\n"
|
||||
|
||||
# Verify there are at least some bitcode segments in the rmv7 and arm64 slices
|
||||
# Note, this is not conclusive, it is possible some symbols are missing the segment
|
||||
for arch in "armv7" "arm64"; do
|
||||
local SYMBOLS=$(otool -l -arch "${arch}" "${BINARY_PATH}")
|
||||
if [[ ! $SYMBOLS == *"LLVM"* ]]; then
|
||||
printf "ERROR: Bitcode segments not found in ${FRAMEWORK_NAME}. Users will fail to archive their builds \n";
|
||||
exit 7;
|
||||
fi
|
||||
done
|
||||
printf "$FRAMEWORK_NAME contains bitcode: ✓\n"
|
||||
|
||||
# Verify there is a plist file
|
||||
local PLIST_PATH=( $(find $FRAMEWORK_PATH -name Info.plist) )
|
||||
if [[ -z "$PLIST_PATH" ]]; then
|
||||
printf "ERROR: No Info.plist found in $FRAMEWORK_NAME\n"
|
||||
exit 8;
|
||||
fi
|
||||
printf "$FRAMEWORK_NAME contains Info.plist: ✓\n"
|
||||
|
||||
# Verify there is a bundle identifier in Info.plist
|
||||
# And verify it does not contain any vestigial string templating
|
||||
local BUNDLE_NAME=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${PLIST_PATH}")
|
||||
if [[ -z "$BUNDLE_NAME" ]]; then
|
||||
printf "ERROR: Info.plist not found in $FRAMEWORK_NAME or CFBundleIdentifier not set\n";
|
||||
exit 9;
|
||||
elif [[ "$BUNDLE_NAME" == *"$"* ]]; then
|
||||
printf "ERROR: CFBundleIdentifier is invalid: $BUNDLE_NAME\n";
|
||||
exit 10;
|
||||
else
|
||||
printf "$FRAMEWORK_NAME has bundle: $BUNDLE_NAME ✓\n"
|
||||
fi
|
||||
|
||||
# Verify there is a bundle version in the Info.plist
|
||||
local BUNDLE_VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${PLIST_PATH}")
|
||||
if [[ -z "$BUNDLE_VERSION" ]]; then
|
||||
printf "ERROR: No CFBundleShortVersionString found in $FRAMEWORK_NAME\n";
|
||||
exit 11;
|
||||
else
|
||||
printf "$FRAMEWORK_NAME has version: $BUNDLE_VERSION ✓\n"
|
||||
fi
|
||||
|
||||
printf "===========================================\n"
|
||||
printf "Analyzed $PRODUCT version $BUNDLE_VERSION. \n"
|
||||
printf "Basic static verifications passed. 🚀🚀🚀 \n"
|
||||
printf "Please perform final verification testing \n\n"
|
||||
}
|
||||
|
||||
# Extract the zip archive to a temporary location
|
||||
TEMP_DIR=$(mktemp -d /tmp/fabric_framework_validation.XXXXX)
|
||||
printf "Unzipping $(basename "$1") to $TEMP_DIR\n"
|
||||
unzip "$1" -d "$TEMP_DIR" &> /dev/null
|
||||
|
||||
# Find frameworks and ensure they are at the top level, e.g. NOT nested within a sub directory
|
||||
printf "Scanning for frameworks...\n"
|
||||
FRAMEWORKS=( $(find "$TEMP_DIR" -name "*.framework" -maxdepth 1) )
|
||||
if [ -z "$FRAMEWORKS" ]; then
|
||||
printf "ERROR: No frameworks found at the top level within the zip archive.";
|
||||
exit 2;
|
||||
fi
|
||||
|
||||
# Verify each framework found individually
|
||||
for framework in "${FRAMEWORKS[@]}"; do
|
||||
verifyFramework "$framework"
|
||||
printf ""
|
||||
done
|
||||
|
||||
rm -r "$TEMP_DIR"
|
||||
148
platform/ios/scripts/xcpackage.sh
Normal file
148
platform/ios/scripts/xcpackage.sh
Normal file
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
set -u
|
||||
|
||||
NAME=Mapbox
|
||||
OUTPUT=build/ios/pkg
|
||||
DERIVED_DATA=build/ios
|
||||
PRODUCTS=${DERIVED_DATA}
|
||||
LOG_PATH=build/xcodebuild-$(date +"%Y-%m-%d_%H%M%S").log
|
||||
|
||||
BUILD_DOCS=${BUILD_DOCS:-true}
|
||||
SYMBOLS=${SYMBOLS:-YES}
|
||||
|
||||
BUILDTYPE=${BUILDTYPE:-Debug}
|
||||
if [[ ${SYMBOLS} == YES && ${BUILDTYPE} == Release ]]; then
|
||||
BUILDTYPE='RelWithDebInfo'
|
||||
fi
|
||||
|
||||
FORMAT=${FORMAT:-dynamic}
|
||||
if [[ ${FORMAT} != "dynamic" ]]; then
|
||||
echo "Error: only dynamic FORMAT is supported in xcpackage build."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
|
||||
function finish { >&2 echo -en "\033[0m"; }
|
||||
trap finish EXIT
|
||||
|
||||
IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
|
||||
IOS_SIM_SDK_VERSION=`xcrun --sdk iphonesimulator --show-sdk-version`
|
||||
|
||||
step "Configuring ${FORMAT} framework for iphoneos ${IOS_SDK_VERSION} and iphonesimulator ${IOS_SIM_SDK_VERSION} (symbols: ${SYMBOLS}, buildtype: ${BUILDTYPE})"
|
||||
|
||||
xcodebuild -version
|
||||
|
||||
rm -rf ${OUTPUT}
|
||||
BINOUT="${OUTPUT}"/dynamic
|
||||
mkdir -p ${BINOUT}
|
||||
|
||||
step "Recording library version…"
|
||||
VERSION="${OUTPUT}"/version.txt
|
||||
echo -n "https://github.com/maplibre/maplibre-native/commit/" > ${VERSION}
|
||||
HASH=`git log | head -1 | awk '{ print $2 }' | cut -c 1-10` && true
|
||||
echo -n "maplibre-gl-native-ios "
|
||||
echo ${HASH}
|
||||
echo ${HASH} >> ${VERSION}
|
||||
|
||||
PROJ_VERSION=$(git rev-list --count HEAD)
|
||||
SEM_VERSION=$( git describe --tags --match=ios-v*.*.* --abbrev=0 | sed 's/^ios-v//' )
|
||||
SHORT_VERSION=${SEM_VERSION%-*}
|
||||
|
||||
step "Building targets (build ${PROJ_VERSION}, version ${SEM_VERSION})"
|
||||
|
||||
SCHEME='dynamic'
|
||||
|
||||
CI_XCCONFIG=''
|
||||
if [[ ! -z "${CI:=}" ]]; then
|
||||
xcconfig='platform/darwin/ci.xcconfig'
|
||||
echo "CI environment, using ${xcconfig}"
|
||||
CI_XCCONFIG="-xcconfig ./${xcconfig}"
|
||||
fi
|
||||
|
||||
step "Building ${FORMAT} archive for iOS Simulator using ${SCHEME} scheme -> ${BINOUT}/${NAME}-iphonesimulator.xcarchive"
|
||||
xcodebuild \
|
||||
archive \
|
||||
CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \
|
||||
CURRENT_COMMIT_HASH=${HASH} \
|
||||
SKIP_INSTALL=NO \
|
||||
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
|
||||
-workspace ./platform/ios/ios.xcworkspace \
|
||||
-archivePath ${BINOUT}/${NAME}-iphonesimulator.xcarchive \
|
||||
-scheme ${SCHEME} \
|
||||
-configuration ${BUILDTYPE} \
|
||||
-sdk iphonesimulator \
|
||||
-jobs ${JOBS} | tee ${LOG_PATH} | xcpretty
|
||||
|
||||
step "Building ${FORMAT} archive for iOS devices using ${SCHEME} scheme -> ${BINOUT}/${NAME}-iphoneos.xcarchive"
|
||||
xcodebuild \
|
||||
archive \
|
||||
CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \
|
||||
CURRENT_COMMIT_HASH=${HASH} \
|
||||
SKIP_INSTALL=NO \
|
||||
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
|
||||
-workspace ./platform/ios/ios.xcworkspace \
|
||||
-archivePath ${BINOUT}/${NAME}-iphoneos.xcarchive \
|
||||
-scheme ${SCHEME} \
|
||||
-configuration ${BUILDTYPE} \
|
||||
-sdk iphoneos \
|
||||
-jobs ${JOBS} | tee ${LOG_PATH} | xcpretty
|
||||
|
||||
LIBS=(Mapbox.a)
|
||||
|
||||
function realpath {
|
||||
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
|
||||
}
|
||||
|
||||
function addFramework {
|
||||
local archive=$1
|
||||
local frameworkName=$2
|
||||
local includeDebugSymbols=$3
|
||||
|
||||
local frameworkPath="${archive}/Products/Library/Frameworks/${frameworkName}.framework"
|
||||
BUILD_ARGS="$BUILD_ARGS -framework $frameworkPath"
|
||||
|
||||
if [[ $includeDebugSymbols == true ]]; then
|
||||
SYMBOL_PATH=$(realpath "${archive}/dSYMs/${frameworkName}.framework.dSYM")
|
||||
BUILD_ARGS="$BUILD_ARGS -debug-symbols ${SYMBOL_PATH}"
|
||||
fi
|
||||
}
|
||||
|
||||
step "Creating ${NAME} xcframework"
|
||||
|
||||
INCLUDE_DEBUG_SYMBOLS=false
|
||||
if [[ $BUILDTYPE='RelWithDebInfo' || $BUILDTYPE='Debug' ]]; then
|
||||
INCLUDE_DEBUG_SYMBOLS=true
|
||||
fi
|
||||
|
||||
|
||||
# Mapbox mobile
|
||||
BUILD_ARGS=""
|
||||
addFramework "${BINOUT}/${NAME}-iphoneos.xcarchive" ${NAME} ${INCLUDE_DEBUG_SYMBOLS}
|
||||
addFramework "${BINOUT}/${NAME}-iphonesimulator.xcarchive" ${NAME} ${INCLUDE_DEBUG_SYMBOLS}
|
||||
BUILD_ARGS="$BUILD_ARGS -output ${BINOUT}/${NAME}.xcframework"
|
||||
echo "Creating ${NAME}.xcframework with args: $BUILD_ARGS"
|
||||
xcodebuild -create-xcframework $BUILD_ARGS
|
||||
echo "${NAME}.xcframework created"
|
||||
|
||||
step "Copying library resources…"
|
||||
cp -pv LICENSE.md ${OUTPUT}
|
||||
sed -n -e '/^## /,$p' platform/ios/CHANGELOG.md > "${OUTPUT}/CHANGELOG.md"
|
||||
|
||||
rm -rf /tmp/mbgl
|
||||
mkdir -p /tmp/mbgl/
|
||||
README=/tmp/mbgl/README.md
|
||||
cp platform/ios/docs/pod-README.md "${README}"
|
||||
sed -i '' -e '/{{STATIC}}/,/{{\/STATIC}}/d' "${README}"
|
||||
sed -i '' \
|
||||
-e '/{{DYNAMIC}}/d' -e '/{{\/DYNAMIC}}/d' \
|
||||
-e '/{{STATIC}}/d' -e '/{{\/STATIC}}/d' \
|
||||
"${README}"
|
||||
cp ${README} "${OUTPUT}"
|
||||
|
||||
if [ ${BUILD_DOCS} == true ]; then
|
||||
step "Generating API documentation for ${BUILDTYPE} Build…"
|
||||
make idocument OUTPUT="${OUTPUT}/documentation"
|
||||
fi
|
||||
Reference in New Issue
Block a user