diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | ios/framework/Mapbox-static.h | 2 | ||||
-rwxr-xr-x | platform/ios/scripts/package.sh | 40 | ||||
-rw-r--r-- | platform/ios/src/MGLAccountManager.m | 4 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 3 | ||||
-rw-r--r-- | platform/ios/src/MGLMapboxEvents.m | 8 | ||||
-rw-r--r-- | platform/ios/src/NSBundle+MGLAdditions.h | 9 | ||||
-rw-r--r-- | platform/ios/src/NSBundle+MGLAdditions.m | 25 | ||||
-rw-r--r-- | platform/osx/src/MGLMapView.mm | 2 |
9 files changed, 71 insertions, 23 deletions
@@ -53,6 +53,7 @@ ipackage: Xcode/ios ; @JOBS=$(JOBS) BITCODE=$(BITCODE) FORMAT=$(FORMAT) BUILD_DE ipackage-strip: Xcode/ios ; @JOBS=$(JOBS) BITCODE=$(BITCODE) FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=NO ./platform/ios/scripts/package.sh ipackage-sim: Xcode/ios ; @JOBS=$(JOBS) BUILDTYPE=Debug BITCODE=$(BITCODE) FORMAT=dynamic BUILD_DEVICE=false SYMBOLS=$(SYMBOLS) ./platform/ios/scripts/package.sh iframework: Xcode/ios ; @JOBS=$(JOBS) BITCODE=$(BITCODE) FORMAT=dynamic BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=$(SYMBOLS) ./platform/ios/scripts/package.sh +ifabric: Xcode/ios ; @JOBS=$(JOBS) BITCODE=$(BITCODE) FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=NO BUNDLE_RESOURCES=YES ./platform/ios/scripts/package.sh itest: ipackage-sim ; ./platform/ios/scripts/test.sh idocument: ; OUTPUT=$(OUTPUT) ./platform/ios/scripts/document.sh diff --git a/ios/framework/Mapbox-static.h b/ios/framework/Mapbox-static.h index d3674b0b61..864a3fd5b6 100644 --- a/ios/framework/Mapbox-static.h +++ b/ios/framework/Mapbox-static.h @@ -1,3 +1,5 @@ #import <GLKit/GLKit.h> #import <ImageIO/ImageIO.h> #import <MobileCoreServices/MobileCoreServices.h> +#import <QuartzCore/QuartzCore.h> +#import <SystemConfiguration/SystemConfiguration.h> diff --git a/platform/ios/scripts/package.sh b/platform/ios/scripts/package.sh index 4a964d4346..582da2b699 100755 --- a/platform/ios/scripts/package.sh +++ b/platform/ios/scripts/package.sh @@ -21,13 +21,19 @@ elif [[ ${FORMAT} == "dynamic" ]]; then BUILD_STATIC=false fi +BUNDLE_RESOURCES=${BUNDLE_RESOURCES:-} +BUNDLE_PATH= +if [[ ${BUNDLE_RESOURCES} ]]; then + BUNDLE_PATH="/${NAME}.bundle" +fi + SDK=iphonesimulator if [[ ${BUILD_FOR_DEVICE} == true ]]; then SDK=iphoneos fi IOS_SDK_VERSION=`xcrun --sdk ${SDK} --show-sdk-version` -echo "Configuring ${FORMAT:-dynamic and static} ${BUILDTYPE} framework for ${SDK}; symbols: ${GCC_GENERATE_DEBUGGING_SYMBOLS}; Bitcode: ${ENABLE_BITCODE}" +echo "Configuring ${FORMAT:-dynamic and static} ${BUILDTYPE} framework for ${SDK}; symbols: ${GCC_GENERATE_DEBUGGING_SYMBOLS}; Bitcode: ${ENABLE_BITCODE}; Mapbox.bundle: ${BUNDLE_RESOURCES}" function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } function finish { >&2 echo -en "\033[0m"; } @@ -195,18 +201,28 @@ fi step "Copying library resources…" SEM_VERSION=$( git describe --tags --match=ios-v*.*.* --abbrev=0 | sed 's/^ios-v//' ) SHORT_VERSION=${SEM_VERSION%-*} -cp -pv LICENSE.md "${OUTPUT}" -cp -rv ios/app/Settings.bundle "${OUTPUT}" +if [[ ${BUNDLE_RESOURCES} ]]; then + cp -pv LICENSE.md "${OUTPUT}/static/${NAME}.framework" + cp -rv ios/app/Settings.bundle "${OUTPUT}/static/${NAME}.framework" +else + cp -pv LICENSE.md "${OUTPUT}" + cp -rv ios/app/Settings.bundle "${OUTPUT}" +fi if [[ ${BUILD_STATIC} == true ]]; then - cp -pv platform/ios/resources/* "${OUTPUT}/static/${NAME}.framework" - cp -pv ios/framework/Info.plist "${OUTPUT}/static/${NAME}.framework/Info.plist" - plutil -replace CFBundleExecutable -string ${NAME} "${OUTPUT}/static/${NAME}.framework/Info.plist" - plutil -replace CFBundleIdentifier -string com.mapbox.sdk.ios "${OUTPUT}/static/${NAME}.framework/Info.plist" - plutil -replace CFBundleName -string ${NAME} "${OUTPUT}/static/${NAME}.framework/Info.plist" - plutil -replace CFBundleShortVersionString -string "${SHORT_VERSION}" "${OUTPUT}/static/${NAME}.framework/Info.plist" - plutil -replace CFBundleVersion -string ${PROJ_VERSION} "${OUTPUT}/static/${NAME}.framework/Info.plist" - plutil -replace MGLSemanticVersionString -string "${SEM_VERSION}" "${OUTPUT}/static/${NAME}.framework/Info.plist" - plutil -replace MGLCommitHash -string "${HASH}" "${OUTPUT}/static/${NAME}.framework/Info.plist" + mkdir -p "${OUTPUT}/static/${NAME}.framework${BUNDLE_PATH}" + cp -pv platform/ios/resources/* "${OUTPUT}/static/${NAME}.framework${BUNDLE_PATH}" + INFO_PLIST_PATH="${OUTPUT}/static/${NAME}.framework/Info.plist" + cp -pv ios/framework/Info.plist "${INFO_PLIST_PATH}" + plutil -replace CFBundleExecutable -string ${NAME} "${INFO_PLIST_PATH}" + plutil -replace CFBundleIdentifier -string com.mapbox.sdk.ios "${INFO_PLIST_PATH}" + plutil -replace CFBundleName -string ${NAME} "${INFO_PLIST_PATH}" + plutil -replace CFBundleShortVersionString -string "${SHORT_VERSION}" "${INFO_PLIST_PATH}" + plutil -replace CFBundleVersion -string ${PROJ_VERSION} "${INFO_PLIST_PATH}" + plutil -replace MGLSemanticVersionString -string "${SEM_VERSION}" "${INFO_PLIST_PATH}" + plutil -replace MGLCommitHash -string "${HASH}" "${INFO_PLIST_PATH}" + if [[ ${BUNDLE_RESOURCES} ]]; then + cp -pv "${INFO_PLIST_PATH}" "${OUTPUT}/static/${NAME}.framework${BUNDLE_PATH}/Info.plist" + fi mkdir "${OUTPUT}/static/${NAME}.framework/Modules" cp -pv ios/framework/modulemap "${OUTPUT}/static/${NAME}.framework/Modules/module.modulemap" fi diff --git a/platform/ios/src/MGLAccountManager.m b/platform/ios/src/MGLAccountManager.m index 6b98d5286a..d50f0f86de 100644 --- a/platform/ios/src/MGLAccountManager.m +++ b/platform/ios/src/MGLAccountManager.m @@ -73,11 +73,11 @@ #pragma mark - Fabric + (NSString *)bundleIdentifier { - return [NSBundle mgl_frameworkBundle].bundleIdentifier; + return [NSBundle mgl_frameworkBundleIdentifier]; } + (NSString *)kitDisplayVersion { - return [NSBundle mgl_frameworkBundle].infoDictionary[@"CFBundleShortVersionString"]; + return [NSBundle mgl_frameworkInfoDictionary][@"CFBundleShortVersionString"]; } + (void)initializeIfNeeded { diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 83904f168f..cddeaf4bb9 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3841,7 +3841,8 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) NSString *extension = imageName.pathExtension.length ? imageName.pathExtension : @"png"; NSBundle *bundle = [NSBundle mgl_frameworkBundle]; NSString *path = [bundle pathForResource:imageName.stringByDeletingPathExtension - ofType:extension]; + ofType:extension + inDirectory:bundle.mgl_resourcesDirectory]; if ( ! path) { [NSException raise:@"Resource not found" format: diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m index 567b0c3c90..bfd8267def 100644 --- a/platform/ios/src/MGLMapboxEvents.m +++ b/platform/ios/src/MGLMapboxEvents.m @@ -220,20 +220,20 @@ const NSTimeInterval MGLFlushInterval = 60; _paused = YES; [self resumeMetricsCollection]; - NSBundle *resourceBundle = [NSBundle mgl_frameworkBundle]; + NSBundle *frameworkBundle = [NSBundle mgl_frameworkBundle]; // Load Local Copy of Server's Public Key NSString *cerPath = nil; - cerPath = [resourceBundle pathForResource:@"api_mapbox_com-geotrust" ofType:@"der"]; + cerPath = [frameworkBundle pathForResource:@"api_mapbox_com-geotrust" ofType:@"der" inDirectory:frameworkBundle.mgl_resourcesDirectory]; if (cerPath != nil) { _geoTrustCert = [NSData dataWithContentsOfFile:cerPath]; } - cerPath = [resourceBundle pathForResource:@"api_mapbox_com-digicert" ofType:@"der"]; + cerPath = [frameworkBundle pathForResource:@"api_mapbox_com-digicert" ofType:@"der" inDirectory:frameworkBundle.mgl_resourcesDirectory]; if (cerPath != nil) { _digicertCert = [NSData dataWithContentsOfFile:cerPath]; } - cerPath = [resourceBundle pathForResource:@"star_tilestream_net" ofType:@"der"]; + cerPath = [frameworkBundle pathForResource:@"star_tilestream_net" ofType:@"der" inDirectory:frameworkBundle.mgl_resourcesDirectory]; if (cerPath != nil) { _testServerCert = [NSData dataWithContentsOfFile:cerPath]; } diff --git a/platform/ios/src/NSBundle+MGLAdditions.h b/platform/ios/src/NSBundle+MGLAdditions.h index 6d6ebc35ad..52ef7fbfa7 100644 --- a/platform/ios/src/NSBundle+MGLAdditions.h +++ b/platform/ios/src/NSBundle+MGLAdditions.h @@ -8,8 +8,17 @@ void mgl_linkBundleCategory(); @interface NSBundle (MGLAdditions) +/// Returns the bundle containing the SDK’s classes and Info.plist file. + (instancetype)mgl_frameworkBundle; ++ (nullable NSString *)mgl_frameworkBundleIdentifier; + ++ (nullable NS_DICTIONARY_OF(NSString *, id) *)mgl_frameworkInfoDictionary; + +/// The relative path to the directory containing the SDK’s resource files, or +/// `nil` if the files are located directly within the bundle’s root directory. +@property (readonly, copy, nullable) NSString *mgl_resourcesDirectory; + @end NS_ASSUME_NONNULL_END diff --git a/platform/ios/src/NSBundle+MGLAdditions.m b/platform/ios/src/NSBundle+MGLAdditions.m index 868b4ff8e6..e1f3e7c720 100644 --- a/platform/ios/src/NSBundle+MGLAdditions.m +++ b/platform/ios/src/NSBundle+MGLAdditions.m @@ -6,10 +6,9 @@ void mgl_linkBundleCategory() {} @implementation NSBundle (MGLAdditions) -+ (instancetype)mgl_frameworkBundle -{ ++ (instancetype)mgl_frameworkBundle { NSBundle *bundle = [self bundleForClass:[MGLAccountManager class]]; - if (![bundle.infoDictionary[@"CFBundlePackageType"] isEqualToString:@"FMWK"]) { + if (![bundle.infoDictionary[@"CFBundlePackageType"] isEqualToString:@"FMWK"] && !bundle.mgl_resourcesDirectory) { // For static frameworks, the bundle is the containing application // bundle but the resources are still in the framework bundle. bundle = [NSBundle bundleWithPath:[bundle.privateFrameworksPath @@ -18,4 +17,24 @@ void mgl_linkBundleCategory() {} return bundle; } ++ (nullable NSString *)mgl_frameworkBundleIdentifier { + return self.mgl_frameworkInfoDictionary[@"CFBundleIdentifier"]; +} + ++ (nullable NS_DICTIONARY_OF(NSString *, id) *)mgl_frameworkInfoDictionary { + NSBundle *bundle = self.mgl_frameworkBundle; + if (bundle.mgl_resourcesDirectory) { + NSString *infoPlistPath = [bundle pathForResource:@"Info" + ofType:@"plist" + inDirectory:bundle.mgl_resourcesDirectory]; + return [NSDictionary dictionaryWithContentsOfFile:infoPlistPath]; + } else { + return bundle.infoDictionary; + } +} + +- (NSString *)mgl_resourcesDirectory { + return [self pathForResource:@"Mapbox" ofType:@"bundle"] ? @"Mapbox.bundle" : nil; +} + @end diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index ca282facdb..cd299ff32d 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -92,7 +92,7 @@ typedef std::map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationContextMap /// Returns an NSImage for the default marker image. NSImage *MGLDefaultMarkerImage() { NSString *path = [[NSBundle mgl_frameworkBundle] pathForResource:MGLDefaultStyleMarkerSymbolName - ofType:@"pdf"]; + ofType:@"pdf"]; return [[NSImage alloc] initWithContentsOfFile:path]; } |