Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[tvos] Package script
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Jun 5, 2018
1 parent a8083d6 commit a924a96
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,22 +252,22 @@ ios-static-analyzer: $(IOS_PROJ_PATH)

.PHONY: ipackage
ipackage: $(IOS_PROJ_PATH)
FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=$(SYMBOLS) \
FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) BUILD_TV=$(BUILD_TV) SYMBOLS=$(SYMBOLS) \
./platform/ios/scripts/package.sh

.PHONY: ipackage-strip
ipackage-strip: $(IOS_PROJ_PATH)
FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=NO \
FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) BUILD_TV=$(BUILD_TV) SYMBOLS=NO \
./platform/ios/scripts/package.sh

.PHONY: ipackage-sim
ipackage-sim: $(IOS_PROJ_PATH)
BUILDTYPE=Debug FORMAT=dynamic BUILD_DEVICE=false SYMBOLS=$(SYMBOLS) \
BUILDTYPE=Debug FORMAT=dynamic BUILD_DEVICE=false BUILD_TV=$(BUILD_TV) SYMBOLS=$(SYMBOLS) \
./platform/ios/scripts/package.sh

.PHONY: iframework
iframework: $(IOS_PROJ_PATH)
FORMAT=dynamic BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=$(SYMBOLS) \
FORMAT=dynamic BUILD_DEVICE=$(BUILD_DEVICE) BUILD_TV=$(BUILD_TV) SYMBOLS=$(SYMBOLS) \
./platform/ios/scripts/package.sh

.PHONY: ideploy
Expand Down
101 changes: 99 additions & 2 deletions platform/ios/scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PRODUCTS=${DERIVED_DATA}

BUILDTYPE=${BUILDTYPE:-Debug}
BUILD_FOR_DEVICE=${BUILD_DEVICE:-true}
BUILD_FOR_TV=${BUILD_TV:-true}
SYMBOLS=${SYMBOLS:-YES}

BUILD_DYNAMIC=true
Expand All @@ -27,6 +28,15 @@ if [[ ${BUILD_FOR_DEVICE} == true ]]; then
fi
IOS_SDK_VERSION=`xcrun --sdk ${SDK} --show-sdk-version`

TVOS_SDK=
if [[ ${BUILD_FOR_TV} == true ]]; then
TVOS_SDK=appletvsimulator
if [[ ${BUILD_FOR_DEVICE} == true ]]; then
TVOS_SDK=appletvos
fi
fi
TVOS_SDK_VERSION=`xcrun --sdk ${TVOS_SDK} --show-sdk-version`

function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
function finish { >&2 echo -en "\033[0m"; }
trap finish EXIT
Expand All @@ -42,6 +52,9 @@ fi
if [[ ${BUILD_DYNAMIC} == true ]]; then
mkdir -p "${OUTPUT}"/dynamic
fi
if [[ ${BUILD_FOR_TV} == true ]]; then
mkdir -p "${OUTPUT}"/tv
fi

step "Recording library version…"
VERSION="${OUTPUT}"/version.txt
Expand Down Expand Up @@ -94,6 +107,38 @@ if [[ ${BUILD_FOR_DEVICE} == true ]]; then
-jobs ${JOBS} | xcpretty
fi

if [[ ${BUILD_FOR_TV} == true ]]; then
step "Building for tvOS Simulator using scheme tv"
xcodebuild \
CURRENT_PROJECT_VERSION=${PROJ_VERSION} \
CURRENT_SHORT_VERSION=${SHORT_VERSION} \
CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \
CURRENT_COMMIT_HASH=${HASH} \
ONLY_ACTIVE_ARCH=NO \
-derivedDataPath ${DERIVED_DATA} \
-workspace ./platform/ios/ios.xcworkspace \
-scheme tv \
-configuration ${BUILDTYPE} \
-sdk appletvsimulator \
-jobs ${JOBS} | xcpretty

if [[ ${BUILD_FOR_DEVICE} == true ]]; then
step "Building for tvOS devices using scheme tv"
xcodebuild \
CURRENT_PROJECT_VERSION=${PROJ_VERSION} \
CURRENT_SHORT_VERSION=${SHORT_VERSION} \
CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \
CURRENT_COMMIT_HASH=${HASH} \
ONLY_ACTIVE_ARCH=NO \
-derivedDataPath ${DERIVED_DATA} \
-workspace ./platform/ios/ios.xcworkspace \
-scheme tv \
-configuration ${BUILDTYPE} \
-sdk appletvos \
-jobs ${JOBS} | xcpretty
fi
fi

LIBS=(Mapbox.a)

# https://medium.com/@syshen/create-an-ios-universal-framework-148eb130a46c
Expand Down Expand Up @@ -130,14 +175,41 @@ if [[ ${BUILD_FOR_DEVICE} == true ]]; then
fi
fi

step "Merging simulator dynamic library into device dynamic library…"
step "Merging iOS 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
fi

cp -rv ${PRODUCTS}/${BUILDTYPE}-iphoneos/Settings.bundle ${OUTPUT}

if [[ ${BUILD_FOR_TV} == true ]]; then
step "Copying dynamic framework into place for tvOS devices"
cp -r \
${PRODUCTS}/${BUILDTYPE}-appletvos/${NAME}.framework \
${OUTPUT}/tv/

if [[ -e ${PRODUCTS}/${BUILDTYPE}-appletvos/${NAME}.framework.dSYM ]]; then
step "Copying dSYM"
cp -r ${PRODUCTS}/${BUILDTYPE}-appletvos/${NAME}.framework.dSYM \
${OUTPUT}/tv/
if [[ -e ${PRODUCTS}/${BUILDTYPE}-appletvsimulator/${NAME}.framework.dSYM ]]; then
step "Merging device and simulator dSYMs…"
lipo \
${PRODUCTS}/${BUILDTYPE}-appletvos/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME} \
${PRODUCTS}/${BUILDTYPE}-appletvsimulator/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME} \
-create -output ${OUTPUT}/tv/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}
lipo -info ${OUTPUT}/tv/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}
fi
fi

step "Merging tvOS simulator dynamic library into device dynamic library…"
lipo \
${PRODUCTS}/${BUILDTYPE}-appletveos/${NAME}.framework/${NAME} \
${PRODUCTS}/${BUILDTYPE}-appletvsimulator/${NAME}.framework/${NAME} \
-create -output ${OUTPUT}/tv/${NAME}.framework/${NAME} | echo
fi
else
if [[ ${BUILD_STATIC} == true ]]; then
step "Assembling static library for iOS Simulator…"
Expand All @@ -163,6 +235,18 @@ else
fi

cp -rv ${PRODUCTS}/${BUILDTYPE}-iphonesimulator/Settings.bundle ${OUTPUT}

if [[ ${BUILD_FOR_TV} == true ]]; then
step "Copying dynamic framework into place for tvOS Simulator…"
cp -r \
${PRODUCTS}/${BUILDTYPE}-appletvsimulator/${NAME}.framework \
${OUTPUT}/tv/${NAME}.framework
if [[ -e ${PRODUCTS}/${BUILDTYPE}-appletvsimulator/${NAME}.framework.dSYM ]]; then
step "Copying dSYM"
cp -r ${PRODUCTS}/${BUILDTYPE}-appletvsimulator/${NAME}.framework.dSYM \
${OUTPUT}/tv/
fi
fi
fi

if [[ ${SYMBOLS} = NO ]]; then
Expand All @@ -173,6 +257,9 @@ if [[ ${SYMBOLS} = NO ]]; then
if [[ ${BUILD_DYNAMIC} == true ]]; then
strip -Sx "${OUTPUT}/dynamic/${NAME}.framework/${NAME}"
fi
if [[ ${BUILD_FOR_TV} == true ]]; then
strip -Sx "${OUTPUT}/tv/${NAME}.framework/${NAME}"
fi
fi

function get_comparable_uuid {
Expand Down Expand Up @@ -200,6 +287,12 @@ if [[ ${BUILD_DYNAMIC} == true && ${BUILDTYPE} == Release ]]; then
lipo -info "${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}"
fi

if [[ ${BUILD_FOR_TV} == true && ${BUILDTYPE} == Release ]]; then
validate_dsym \
"${OUTPUT}/tv/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}" \
"${OUTPUT}/tv/${NAME}.framework/${NAME}"
fi

function create_podspec {
step "Creating local podspec (${1})"
[[ $SYMBOLS = YES ]] && POD_SUFFIX="-symbols" || POD_SUFFIX=""
Expand Down Expand Up @@ -244,7 +337,7 @@ if [[ ${BUILD_STATIC} == true ]]; then
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…"
step "Copying iOS Bitcode symbol maps…"
find "${PRODUCTS}/${BUILDTYPE}-iphoneos" -name '*.bcsymbolmap' -type f -exec cp -pv {} "${OUTPUT}/dynamic/" \;

step "Copying demo project and sym linking to published framework…"
Expand All @@ -264,6 +357,10 @@ if [[ ${BUILD_DYNAMIC} == true && ${BUILD_FOR_DEVICE} == true ]]; then
fi
rm /tmp/iosdemobuildoutput
fi
if [[ ${BUILD_FOR_TV} == true && ${BUILD_FOR_DEVICE} == true ]]; then
step "Copying tvOS Bitcode symbol maps…"
find "${PRODUCTS}/${BUILDTYPE}-appletvos" -name '*.bcsymbolmap' -type f -exec cp -pv {} "${OUTPUT}/tv/" \;
fi
sed -n -e '/^## /,$p' platform/ios/CHANGELOG.md > "${OUTPUT}/CHANGELOG.md"

rm -rf /tmp/mbgl
Expand Down

0 comments on commit a924a96

Please sign in to comment.