summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rwxr-xr-xplatform/ios/scripts/framework.sh40
-rwxr-xr-xplatform/ios/scripts/package.sh112
-rwxr-xr-xplatform/ios/scripts/publish.sh2
-rwxr-xr-xplatform/ios/scripts/run.sh7
-rw-r--r--platform/ios/src/MGLAccountManager.m4
-rw-r--r--platform/ios/src/MGLCategoryLoader.h7
-rw-r--r--platform/ios/src/MGLCategoryLoader.m24
-rw-r--r--platform/ios/src/MGLMapView.mm31
-rw-r--r--platform/ios/src/MGLMapboxEvents.m2
-rw-r--r--platform/ios/src/NSBundle+MGLAdditions.h2
-rw-r--r--platform/ios/src/NSBundle+MGLAdditions.m27
-rw-r--r--platform/ios/src/NSProcessInfo+MGLAdditions.h2
-rw-r--r--platform/ios/src/NSProcessInfo+MGLAdditions.m2
13 files changed, 104 insertions, 158 deletions
diff --git a/platform/ios/scripts/framework.sh b/platform/ios/scripts/framework.sh
deleted file mode 100755
index e2842a4707..0000000000
--- a/platform/ios/scripts/framework.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-set -o pipefail
-set -u
-
-cd build/ios/pkg
-rm -rf framework
-mkdir framework
-cd framework
-
-mkdir Mapbox.framework
-
-# headers
-cp -rv ../static/Headers Mapbox.framework/Headers
-cat ../../../../ios/framework/umbrella >> Mapbox.framework/Headers/Mapbox.h
-
-# resources
-cp -rv ../static/Mapbox.bundle Mapbox.framework/Mapbox.bundle
-
-# license
-cp -v ../../../../LICENSE.md Mapbox.framework
-
-# settings bundle
-cp -rv ../../../../ios/framework/Settings.bundle Mapbox.framework/Settings.bundle
-
-# binary
-cp -v ../static/libMapbox.a Mapbox.framework/Mapbox
-strip -Sx Mapbox.framework/Mapbox
-
-# module map
-mkdir Mapbox.framework/Modules
-cp -v ../../../../ios/framework/modulemap Mapbox.framework/Modules/module.modulemap
-
-# Info.plist
-VERSION=$( git tag | grep ^ios | sed 's/^ios-//' | sort -r | grep -v '\-rc.' | grep -v '\-pre.' | sed -n '1p' | sed 's/^v//' )
-echo "Using $VERSION for Info.plist. Note that you will need to manually update the product for pre-releases or release candidates."
-cp -v ../../../../ios/framework/Info.plist Mapbox.framework
-perl -pi -e "s/#####/$VERSION/" Mapbox.framework/Info.plist
-perl -pi -e "s/%%%%%/$VERSION/" Mapbox.framework/Info.plist
diff --git a/platform/ios/scripts/package.sh b/platform/ios/scripts/package.sh
index 8faebb60e8..0d5808aea3 100755
--- a/platform/ios/scripts/package.sh
+++ b/platform/ios/scripts/package.sh
@@ -7,17 +7,11 @@ set -u
NAME=Mapbox
OUTPUT=build/ios/pkg
LIBUV_VERSION=1.7.5
-ENABLE_BITCODE=YES
if [[ ${#} -eq 0 ]]; then # e.g. "make ipackage"
BUILDTYPE="Release"
BUILD_FOR_DEVICE=true
GCC_GENERATE_DEBUGGING_SYMBOLS="YES"
-elif [[ ${1} == "no-bitcode" ]]; then # e.g. "make ipackage-no-bitcode"
- BUILDTYPE="Release"
- BUILD_FOR_DEVICE=true
- GCC_GENERATE_DEBUGGING_SYMBOLS="YES"
- ENABLE_BITCODE=NO
elif [[ ${1} == "sim" ]]; then # e.g. "make ipackage-sim"
BUILDTYPE="Debug"
BUILD_FOR_DEVICE=false
@@ -41,10 +35,11 @@ trap finish EXIT
rm -rf ${OUTPUT}
mkdir -p "${OUTPUT}"/static
+mkdir -p "${OUTPUT}"/dynamic
-step "Recording library version..."
-VERSION="${OUTPUT}"/static/version.txt
+step "Recording library version…"
+VERSION="${OUTPUT}"/version.txt
echo -n "https://github.com/mapbox/mapbox-gl-native/commit/" > ${VERSION}
HASH=`git log | head -1 | awk '{ print $2 }' | cut -c 1-10` && true
echo -n "mapbox-gl-native "
@@ -52,27 +47,44 @@ echo ${HASH}
echo ${HASH} >> ${VERSION}
-step "Creating build files..."
+step "Creating build files…"
export MASON_PLATFORM=ios
export BUILDTYPE=${BUILDTYPE:-Release}
export HOST=ios
make Xcode/ios
+PROJ_VERSION=${TRAVIS_JOB_NUMBER:-${BITRISE_BUILD_NUMBER:-0}}
+
if [[ "${BUILD_FOR_DEVICE}" == true ]]; then
- step "Building iOS device targets..."
+ step "Building intermediate static libraries for iOS devices (build ${PROJ_VERSION})…"
xcodebuild -sdk iphoneos${IOS_SDK_VERSION} \
ARCHS="arm64 armv7 armv7s" \
ONLY_ACTIVE_ARCH=NO \
GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \
- ENABLE_BITCODE=${ENABLE_BITCODE} \
+ ENABLE_BITCODE=NO \
DEPLOYMENT_POSTPROCESSING=YES \
-project ./build/ios-all/gyp/mbgl.xcodeproj \
-configuration ${BUILDTYPE} \
-target everything \
-jobs ${JOBS}
+
+ step "Building dynamic framework for iOS devices (build ${PROJ_VERSION})…"
+ xcodebuild -sdk iphoneos${IOS_SDK_VERSION} \
+ ARCHS="arm64 armv7 armv7s" \
+ ONLY_ACTIVE_ARCH=NO \
+ GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \
+ ENABLE_BITCODE=YES \
+ DEPLOYMENT_POSTPROCESSING=YES \
+ CURRENT_PROJECT_VERSION=${PROJ_VERSION} \
+ CODE_SIGNING_REQUIRED=NO \
+ CODE_SIGN_IDENTITY= \
+ -project ./build/ios-all/gyp/ios.xcodeproj \
+ -configuration ${BUILDTYPE} \
+ -target iossdk \
+ -jobs ${JOBS}
fi
-step "Building iOS Simulator targets..."
+step "Building intermediate static libraries for iOS Simulator (build ${PROJ_VERSION})…"
xcodebuild -sdk iphonesimulator${IOS_SDK_VERSION} \
ARCHS="x86_64 i386" \
ONLY_ACTIVE_ARCH=NO \
@@ -82,54 +94,88 @@ xcodebuild -sdk iphonesimulator${IOS_SDK_VERSION} \
-target everything \
-jobs ${JOBS}
+step "Building dynamic framework for iOS Simulator (build ${PROJ_VERSION})…"
+xcodebuild -sdk iphonesimulator${IOS_SDK_VERSION} \
+ ARCHS="x86_64 i386" \
+ ONLY_ACTIVE_ARCH=NO \
+ GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \
+ ENABLE_BITCODE=YES \
+ CURRENT_PROJECT_VERSION=${PROJ_VERSION} \
+ -project ./build/ios-all/gyp/ios.xcodeproj \
+ -configuration ${BUILDTYPE} \
+ -target iossdk \
+ -jobs ${JOBS}
-step "Building static library..."
LIBS=(core.a platform-ios.a asset-fs.a http-nsurl.a)
+
+# https://medium.com/@syshen/create-an-ios-universal-framework-148eb130a46c
if [[ "${BUILD_FOR_DEVICE}" == true ]]; then
+ step "Assembling static framework for iOS Simulator and devices…"
+ mkdir -p ${OUTPUT}/static/${NAME}.framework
libtool -static -no_warning_for_no_symbols \
`find mason_packages/ios-${IOS_SDK_VERSION} -type f -name libuv.a` \
`find mason_packages/ios-${IOS_SDK_VERSION} -type f -name libgeojsonvt.a` \
- -o ${OUTPUT}/static/lib${NAME}.a \
+ -o ${OUTPUT}/static/${NAME}.framework/${NAME} \
${LIBS[@]/#/gyp/build/${BUILDTYPE}-iphoneos/libmbgl-} \
${LIBS[@]/#/gyp/build/${BUILDTYPE}-iphonesimulator/libmbgl-}
+
+ step "Copying dynamic framework into place for iOS devices"
+ cp -r \
+ gyp/build/${BUILDTYPE}-iphoneos/${NAME}.framework \
+ ${OUTPUT}/dynamic/
+
+ step "Merging simulator dynamic library into device dynamic library…"
+ lipo \
+ gyp/build/${BUILDTYPE}-iphoneos/${NAME}.framework/${NAME} \
+ gyp/build/${BUILDTYPE}-iphonesimulator/${NAME}.framework/${NAME} \
+ -create -output ${OUTPUT}/dynamic/${NAME}.framework/${NAME} | echo
else
+ step "Assembling static library for iOS Simulator…"
+ mkdir -p ${OUTPUT}/static/${NAME}.framework
libtool -static -no_warning_for_no_symbols \
`find mason_packages/ios-${IOS_SDK_VERSION} -type f -name libuv.a` \
`find mason_packages/ios-${IOS_SDK_VERSION} -type f -name libgeojsonvt.a` \
-o ${OUTPUT}/static/lib${NAME}.a \
${LIBS[@]/#/gyp/build/${BUILDTYPE}-iphonesimulator/libmbgl-}
+
+ step "Copying dynamic framework into place for iOS Simulator…"
+ cp -r \
+ gyp/build/${BUILDTYPE}-iphonesimulator/${NAME}.framework \
+ ${OUTPUT}/dynamic/${NAME}.framework
fi
-echo "Created ${OUTPUT}/static/lib${NAME}.a"
+if [[ "${GCC_GENERATE_DEBUGGING_SYMBOLS}" == false ]]; then
+ step "Stripping binaries…"
+ strip -Sx "${OUTPUT}/static/${NAME}.framework/${NAME}"
+ strip -Sx "${OUTPUT}/dynamic/${NAME}.framework/${NAME}"
+fi
-step "Copying Headers..."
-mkdir -p "${OUTPUT}/static/Headers"
-for i in `ls -R include/mbgl/darwin | grep -vi private`; do
- cp -pv include/mbgl/darwin/$i "${OUTPUT}/static/Headers"
-done
-for i in `ls -R include/mbgl/ios | grep -vi private`; do
- cp -pv include/mbgl/ios/$i "${OUTPUT}/static/Headers"
-done
+stat "${OUTPUT}/static/${NAME}.framework"
+stat "${OUTPUT}/dynamic/${NAME}.framework"
+step "Copying static library headers…"
+mkdir -p "${OUTPUT}/static/${NAME}.framework/Headers"
+cp -pv include/mbgl/{darwin,ios}/*.h "${OUTPUT}/static/${NAME}.framework/Headers"
-# Manually create resource bundle. We don't use a GYP target here because of
-# complications between faked GYP bundles-as-executables, device build
-# dependencies, and code signing.
-step "Copying Resources..."
-cp -pv LICENSE.md "${OUTPUT}/static"
-mkdir -p "${OUTPUT}/static/${NAME}.bundle"
-cp -pv platform/ios/resources/* "${OUTPUT}/static/${NAME}.bundle"
+step "Copying library resources…"
+cp -pv LICENSE.md "${OUTPUT}"
+cp -rv ios/app/Settings.bundle "${OUTPUT}"
+cp -pv platform/ios/resources/* "${OUTPUT}/static/${NAME}.framework"
+cp -pv ios/framework/Info.plist "${OUTPUT}/static/${NAME}.framework/Info.plist"
+perl -pi -e "s/(?<=<string>)0(?=<\/string>)/${PROJ_VERSION}/g" "${OUTPUT}/static/${NAME}.framework/Info.plist"
+mkdir "${OUTPUT}/static/${NAME}.framework/Modules"
+cp -pv ios/framework/modulemap "${OUTPUT}/static/${NAME}.framework/Modules/module.modulemap"
-step "Creating API Docs..."
+step "Generating API documentation…"
if [ -z `which jazzy` ]; then
- step "Installing jazzy..."
+ step "Installing jazzy…"
gem install jazzy
if [ -z `which jazzy` ]; then
echo "Unable to install jazzy. See https://github.com/mapbox/mapbox-gl-native/blob/master/platform/ios/INSTALL.md"
exit 1
fi
fi
-DOCS_OUTPUT="${OUTPUT}/static/Docs"
+DOCS_OUTPUT="${OUTPUT}/documentation"
DOCS_VERSION=$( git tag | grep ^ios | sed 's/^ios-//' | sort -r | grep -v '\-rc.' | grep -v '\-pre.' | sed -n '1p' | sed 's/^v//' )
rm -rf /tmp/mbgl
mkdir -p /tmp/mbgl/
diff --git a/platform/ios/scripts/publish.sh b/platform/ios/scripts/publish.sh
index c914fcaccd..bdfbc94314 100755
--- a/platform/ios/scripts/publish.sh
+++ b/platform/ios/scripts/publish.sh
@@ -19,7 +19,7 @@ fi
#
# zip
#
-cd build/ios/pkg/static
+cd build/ios/pkg
ZIP=mapbox-ios-sdk-${PUBLISH_VERSION}${PUBLISH_STYLE}.zip
rm -f ../${ZIP}
zip -r ../${ZIP} *
diff --git a/platform/ios/scripts/run.sh b/platform/ios/scripts/run.sh
index bfca74d318..02699f29b6 100755
--- a/platform/ios/scripts/run.sh
+++ b/platform/ios/scripts/run.sh
@@ -31,13 +31,6 @@ if [[ ${PUBLISH_PLATFORM} = 'ios' ]]; then
mapbox_time "deploy_ios_stripped"
./platform/ios/scripts/publish.sh "${PUBLISH_VERSION}"
-
- # debug symbols but no Bitcode
- mapbox_time "package_ios_no_bitcode" \
- make ipackage-no-bitcode
-
- mapbox_time "deploy_ios_no_bitcode"
- ./platform/ios/scripts/publish.sh "${PUBLISH_VERSION}" no-bitcode
else
# build & test iOS
mapbox_time "run_ios_tests" \
diff --git a/platform/ios/src/MGLAccountManager.m b/platform/ios/src/MGLAccountManager.m
index c5aeae7077..9b60a40986 100644
--- a/platform/ios/src/MGLAccountManager.m
+++ b/platform/ios/src/MGLAccountManager.m
@@ -1,6 +1,5 @@
#import "MGLAccountManager_Private.h"
#import "MGLMapboxEvents.h"
-#import "MGLCategoryLoader.h"
#import "NSProcessInfo+MGLAdditions.h"
#import "FABKitProtocol.h"
@@ -17,9 +16,6 @@
#pragma mark - Internal
+ (void)load {
- // Load all referenced categories due to absence of -ObjC linker flag
- [MGLCategoryLoader loadCategories];
-
// Read the initial configuration from Info.plist.
NSString *accessToken = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
if (accessToken.length) {
diff --git a/platform/ios/src/MGLCategoryLoader.h b/platform/ios/src/MGLCategoryLoader.h
deleted file mode 100644
index 874450d148..0000000000
--- a/platform/ios/src/MGLCategoryLoader.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#import <Foundation/Foundation.h>
-
-@interface MGLCategoryLoader : NSObject
-
-+ (void)loadCategories;
-
-@end
diff --git a/platform/ios/src/MGLCategoryLoader.m b/platform/ios/src/MGLCategoryLoader.m
deleted file mode 100644
index 9b66be73d8..0000000000
--- a/platform/ios/src/MGLCategoryLoader.m
+++ /dev/null
@@ -1,24 +0,0 @@
-#import "MGLCategoryLoader.h"
-
-#import "NSBundle+MGLAdditions.h"
-#import "NSProcessInfo+MGLAdditions.h"
-#import "NSString+MGLAdditions.h"
-
-#import "MGLMapView.h"
-
-@implementation MGLCategoryLoader
-
-+ (void)loadCategories
-{
- // https://github.com/mapbox/mapbox-gl-native/issues/2966
- //
- mgl_linkBundleCategory();
- mgl_linkProcessCategory();
- mgl_linkStringCategory();
-
- // https://github.com/mapbox/mapbox-gl-native/issues/3113
- //
- [MGLMapView description];
-}
-
-@end
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 3cb8209f1d..ebcc62eba6 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -3529,25 +3529,24 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration)
+ (UIImage *)resourceImageNamed:(NSString *)imageName
{
- if ( ! [[imageName pathExtension] length])
- {
- imageName = [imageName stringByAppendingString:@".png"];
- }
-
- return [UIImage imageWithContentsOfFile:[self pathForBundleResourceNamed:imageName ofType:nil inDirectory:@""]];
-}
-
-+ (NSString *)pathForBundleResourceNamed:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)directory
-{
- NSString *path = [[NSBundle bundleWithPath:[NSBundle mgl_resourceBundlePath]] pathForResource:name ofType:extension inDirectory:directory];
-
- if (!path)
+ NSString *extension = imageName.pathExtension.length ? imageName.pathExtension : @"png";
+ NSBundle *bundle = [NSBundle mgl_frameworkBundle];
+ NSString *directory = nil;
+ if (![bundle.infoDictionary[@"CFBundlePackageType"] isEqualToString:@"FMWK"]) {
+ // For static libraries, the bundle is the containing application bundle
+ // and the resources are in a bundle alongside the static library.
+ directory = @"Mapbox.bundle";
+ }
+ NSString *path = [bundle pathForResource:imageName.stringByDeletingPathExtension
+ ofType:extension
+ inDirectory:directory];
+ if ( ! path)
{
[NSException raise:@"Resource not found" format:
- @"The resource named “%@” could not be found in the Mapbox resource bundle.", name];
+ @"The resource named “%@” could not be found in the Mapbox resource bundle.", imageName];
}
-
- return path;
+
+ return [UIImage imageWithContentsOfFile:path];
}
- (BOOL)isFullyLoaded
diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m
index 6654cc6ac5..8aa790c41f 100644
--- a/platform/ios/src/MGLMapboxEvents.m
+++ b/platform/ios/src/MGLMapboxEvents.m
@@ -220,7 +220,7 @@ const NSTimeInterval MGLFlushInterval = 60;
_paused = YES;
[self resumeMetricsCollection];
- NSBundle *resourceBundle = [NSBundle bundleWithPath:[NSBundle mgl_resourceBundlePath]];
+ NSBundle *resourceBundle = [NSBundle mgl_frameworkBundle];
// Load Local Copy of Server's Public Key
NSString *cerPath = nil;
diff --git a/platform/ios/src/NSBundle+MGLAdditions.h b/platform/ios/src/NSBundle+MGLAdditions.h
index a86e85f79b..6d6ebc35ad 100644
--- a/platform/ios/src/NSBundle+MGLAdditions.h
+++ b/platform/ios/src/NSBundle+MGLAdditions.h
@@ -8,7 +8,7 @@ void mgl_linkBundleCategory();
@interface NSBundle (MGLAdditions)
-+ (NSString *)mgl_resourceBundlePath;
++ (instancetype)mgl_frameworkBundle;
@end
diff --git a/platform/ios/src/NSBundle+MGLAdditions.m b/platform/ios/src/NSBundle+MGLAdditions.m
index d5842ea596..05d8f5c87c 100644
--- a/platform/ios/src/NSBundle+MGLAdditions.m
+++ b/platform/ios/src/NSBundle+MGLAdditions.m
@@ -1,31 +1,14 @@
#import "NSBundle+MGLAdditions.h"
-#import "MGLMapView.h"
+#import "MGLAccountManager.h"
-@implementation NSBundle (MGLAdditions)
+void mgl_linkBundleCategory() {}
-void mgl_linkBundleCategory(){}
+@implementation NSBundle (MGLAdditions)
-+ (NSString *)mgl_resourceBundlePath
++ (instancetype)mgl_frameworkBundle
{
- NSString *resourceBundlePath = nil;
-
- // check for resource bundle in framework bundle (Fabric, premade framework)
- //
- NSString *frameworkBundlePath = [NSString stringWithFormat:@"%@/Mapbox.framework/Mapbox.bundle",
- [[NSBundle mainBundle] privateFrameworksPath]];
- if ([NSBundle bundleWithPath:frameworkBundlePath]) resourceBundlePath = frameworkBundlePath;
-
- // check for resource bundle in app bundle (static library)
- //
- if ( ! resourceBundlePath) resourceBundlePath = [[NSBundle bundleForClass:
- [MGLMapView class]] pathForResource:@"Mapbox" ofType:@"bundle"];
-
- // fall back to resources directly in app bundle (test app)
- //
- if ( ! resourceBundlePath) resourceBundlePath = [[NSBundle mainBundle] bundlePath];
-
- return resourceBundlePath;
+ return [self bundleForClass:[MGLAccountManager class]];
}
@end
diff --git a/platform/ios/src/NSProcessInfo+MGLAdditions.h b/platform/ios/src/NSProcessInfo+MGLAdditions.h
index b97979ddb4..6b34f54756 100644
--- a/platform/ios/src/NSProcessInfo+MGLAdditions.h
+++ b/platform/ios/src/NSProcessInfo+MGLAdditions.h
@@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
-void mgl_linkProcessCategory();
+void mgl_linkProcessInfoCategory();
@interface NSProcessInfo (MGLAdditions)
diff --git a/platform/ios/src/NSProcessInfo+MGLAdditions.m b/platform/ios/src/NSProcessInfo+MGLAdditions.m
index 1f12f7256e..73d76bc17f 100644
--- a/platform/ios/src/NSProcessInfo+MGLAdditions.m
+++ b/platform/ios/src/NSProcessInfo+MGLAdditions.m
@@ -2,7 +2,7 @@
@implementation NSProcessInfo (MGLAdditions)
-void mgl_linkProcessCategory(){}
+void mgl_linkProcessInfoCategory() {}
- (BOOL)mgl_isInterfaceBuilderDesignablesAgent
{