Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add static XCFramework option to packager scripts #149

Merged
merged 2 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions scripts/release/README-dynamic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Mapbox Maps SDK v10 for iOS

## Xcode Installation Instructions

1. Please drag the following 5 XCFrameworks (included in this archive) to your
Xcode project and add them to your application target.

- `MapboxCommon.xcframework`
- `MapboxCoreMaps.xcframework`
- `MapboxMaps.xcframework`
- `MapboxMobileEvents.xcframework`
- `Turf.xcframework`

2. On the General tab for the target, scroll to the section labeled "Frameworks,
Libraries and Embedded Content".

3. Change `Embed` from "Do Not Embed" to "Embed & Sign" for all 5 linked XCFrameworks

4. Add `import MapboxMaps` to your Swift source file.

5. Please see the Migration Guide for further guidelines.
macdrevx marked this conversation as resolved.
Show resolved Hide resolved
31 changes: 31 additions & 0 deletions scripts/release/README-static.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Mapbox Maps SDK v10 for iOS

## Xcode Installation Instructions

1. Please drag the following 5 XCFrameworks (included in this archive) to your
Xcode project and add them to your application target.

- `MapboxCommon.xcframework`
- `MapboxCoreMaps.xcframework`
- `MapboxMaps.xcframework`
- `MapboxMobileEvents.xcframework`
- `Turf.xcframework`

2. On the General tab for the target, scroll to the section labeled "Frameworks,
Libraries and Embedded Content".

3. Ensure `Embed` is set to "Do Not Embed" for all 5 linked XCFrameworks

4. Configure your application to link with `libz`, `libsqlite3`, and `libc++` by
clicking on the '+' button at the bottom of the "Frameworks, Libraries and
Embedded Content" list, selecting `libz.tbd`, clicking "Add", and
the repeating these steps for `libsqlite3.tbd` and `libc++.tbd`.

5. On the Build Settings tab for the target, find the "Other Linker Flags"
setting. Add the value `-ObjC` to the list of values for the target. You may
also want to add `$(inherited)` to ensure that any values for this setting
from the project or from configuration files are not overwritten.

6. Add `import MapboxMaps` to your Swift source file.

7. Please see the Migration Guide for further guidelines.
19 changes: 0 additions & 19 deletions scripts/release/README.md

This file was deleted.

5 changes: 3 additions & 2 deletions scripts/release/packager/build-dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ trap finish EXIT
NAME=${1}
GIT_REPO_URL=${2}
VERSION=${3}
SCHEME=${4}
LINK_TYPE=${4}
SCHEME=${5:-"$NAME"}

mkdir .build
pushd .build
Expand All @@ -21,7 +22,7 @@ step "Checkout tag: $VERSION"
git -C repo checkout "$VERSION"

step "Build $NAME"
../../create-xcframework.sh "repo/$NAME.xcodeproj" "$SCHEME" "$NAME"
../../create-xcframework.sh "$NAME" "$LINK_TYPE" "$SCHEME" "repo/$NAME.xcodeproj"

mv *.xcframework ../

Expand Down
25 changes: 20 additions & 5 deletions scripts/release/packager/create-xcframework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@ function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
function finish { >&2 echo -en "\033[0m"; }
trap finish EXIT

PROJECT=${1}
SCHEME=${2}
PRODUCT=${3}
PRODUCT=${1}
LINK_TYPE=${2}
SCHEME=${3:-"$PRODUCT"}
PROJECT=${4:-"$PRODUCT.xcodeproj"}

if [ "$LINK_TYPE" = "DYNAMIC" ]; then
MACH_O_TYPE=mh_dylib
elif [ "$LINK_TYPE" = "STATIC" ]; then
MACH_O_TYPE=staticlib
else
echo "Error: Invalid link type: $LINK_TYPE"
echo "Usage: $0 [DYNAMIC|STATIC]"
exit 1
fi

# Create iOS Simulator Framework
step "Archiving iOS Simulator Framework for $PRODUCT"
Expand All @@ -21,7 +32,9 @@ xcodebuild archive \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
SKIP_INSTALL=NO \
ARCHS='x86_64 arm64' \
EXCLUDED_ARCHS=
EXCLUDED_ARCHS= \
MACH_O_TYPE="$MACH_O_TYPE" \
LLVM_LTO=NO

SIMULATOR_FRAMEWORK_PATH=$(find .create-xcframework/iOS-Simulator.xcarchive -name "$PRODUCT.framework")

Expand All @@ -36,7 +49,9 @@ xcodebuild archive \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
SKIP_INSTALL=NO \
ARCHS='arm64' \
EXCLUDED_ARCHS=
EXCLUDED_ARCHS= \
MACH_O_TYPE="$MACH_O_TYPE" \
LLVM_LTO=NO

DEVICE_FRAMEWORK_PATH=$(find .create-xcframework/iOS.xcarchive -name "$PRODUCT.framework")

Expand Down
34 changes: 26 additions & 8 deletions scripts/release/packager/package-mapbox-maps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
function finish { >&2 echo -en "\033[0m"; }
trap finish EXIT

LINK_TYPE=${1:-"DYNAMIC"}

step 'Reading from versions.json'
CORE_VERSION=$(jq -r '.MapboxCoreMaps' ./versions.json)
COMMON_VERSION=$(jq -r '.MapboxCommon' ./versions.json)
Expand All @@ -18,10 +20,26 @@ mkdir artifacts
pushd artifacts

step 'Installing Dependencies'
../download-dependency.sh mapbox-common MapboxCommon "$COMMON_VERSION"
../download-dependency.sh mobile-maps-core MapboxCoreMaps.xcframework-dynamic "$CORE_VERSION"
../build-dependency.sh MapboxMobileEvents 'https://github.com/mapbox/mapbox-events-ios.git' "$MME_VERSION" MapboxMobileEvents
../build-dependency.sh Turf 'https://github.com/mapbox/turf-swift.git' "$TURF_VERSION" "Turf iOS"
if [ "$LINK_TYPE" = "DYNAMIC" ]; then
COMMON_ARTIFACT=MapboxCommon
CORE_ARTIFACT=MapboxCoreMaps.xcframework-dynamic
ZIP_ARCHIVE_NAME="MapboxMaps-dynamic.zip"
README_PATH=../README-dynamic.md
elif [ "$LINK_TYPE" = "STATIC" ]; then
COMMON_ARTIFACT=MapboxCommon-static
CORE_ARTIFACT=MapboxCoreMaps.xcframework-static
ZIP_ARCHIVE_NAME="MapboxMaps-static.zip"
README_PATH=../README-static.md
else
echo "Error: Invalid link type: $LINK_TYPE"
echo "Usage: $0 [DYNAMIC|STATIC]"
exit 1
fi

../download-dependency.sh mapbox-common "$COMMON_ARTIFACT" "$COMMON_VERSION"
../download-dependency.sh mobile-maps-core "$CORE_ARTIFACT" "$CORE_VERSION"
../build-dependency.sh MapboxMobileEvents 'https://github.com/mapbox/mapbox-events-ios.git' "$MME_VERSION" "$LINK_TYPE"
../build-dependency.sh Turf 'https://github.com/mapbox/turf-swift.git' "$TURF_VERSION" "$LINK_TYPE" "Turf iOS"

step 'Creating MapboxMaps.xcodeproj'
mkdir .xcode
Expand All @@ -33,17 +51,17 @@ xcodegen
popd

step 'Building MapboxMaps.xcframework'
../create-xcframework.sh .xcode/MapboxMaps.xcodeproj MapboxMaps MapboxMaps
../create-xcframework.sh MapboxMaps "$LINK_TYPE" MapboxMaps .xcode/MapboxMaps.xcodeproj
rm -rf .xcode

popd

step 'Add License and README to bundle'
cp ../../../LICENSE.md artifacts/
cp ../README.md artifacts/
cp "$README_PATH" artifacts/README.md

step 'Zip Bundle'
zip -r MapboxMaps-dynamic.zip artifacts
zip -r "$ZIP_ARCHIVE_NAME" artifacts

step 'Delete Artifacts Directory'
rm -rf artifacts
rm -rf artifacts