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

[ios] Fallback to Mapbox.bundle as the framework bundle #9074

Merged
merged 3 commits into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions platform/darwin/src/NSBundle+MGLAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ NS_ASSUME_NONNULL_BEGIN

+ (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
28 changes: 12 additions & 16 deletions platform/darwin/src/NSBundle+MGLAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ @implementation NSBundle (MGLAdditions)

+ (instancetype)mgl_frameworkBundle {
NSBundle *bundle = [self bundleForClass:[MGLAccountManager class]];
if (![bundle.infoDictionary[@"CFBundlePackageType"] isEqualToString:@"FMWK"] && !bundle.mgl_resourcesDirectory) {

if (![bundle.infoDictionary[@"CFBundlePackageType"] isEqualToString:@"FMWK"]) {
// For static frameworks, the bundle is the containing application
// bundle but the resources are still in the framework bundle.
bundle = [NSBundle bundleWithPath:[bundle.privateFrameworksPath
stringByAppendingPathComponent:@"Mapbox.framework"]];
// bundle but the resources are in Mapbox.bundle.
NSString *bundlePath = [bundle pathForResource:@"Mapbox" ofType:@"bundle"];
if (bundlePath) {
bundle = [self bundleWithPath:bundlePath];
} else {
[NSException raise:@"MGLBundleNotFoundException" format:
@"The Mapbox framework bundle could not be found. If using the Mapbox iOS SDK as a static framework, make sure that Mapbox.bundle is copied into the root of the app bundle."];
}
}

return bundle;
}

Expand All @@ -21,18 +28,7 @@ + (nullable NSString *)mgl_frameworkBundleIdentifier {

+ (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;
return bundle.infoDictionary;
}

@end
1 change: 1 addition & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* The error passed into `-[MGLMapViewDelegate mapViewDidFailLoadingMap:withError:]` now includes a more specific description and failure reason. ([#8418](https://github.com/mapbox/mapbox-gl-native/pull/8418))
* Fixed an issue rendering polylines that contain duplicate vertices. ([#8808](https://github.com/mapbox/mapbox-gl-native/pull/8808))
* Fixed a bug which caused the compass and other ornaments to underlap navigation and tab bars. ([#7716](https://github.com/mapbox/mapbox-gl-native/pull/7716))
* Fixed an issue in the static framework where localizations would never load. ([#9074](https://github.com/mapbox/mapbox-gl-native/pull/9074))

## 3.5.4 - May 9, 2017

Expand Down
2 changes: 1 addition & 1 deletion platform/ios/src/MGLAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ - (void)loadCertificates {

- (void)loadCertificate:(NSData **)certificate withResource:(NSString *)resource {
NSBundle *frameworkBundle = [NSBundle mgl_frameworkBundle];
NSString *cerPath = [frameworkBundle pathForResource:resource ofType:@"der" inDirectory:frameworkBundle.mgl_resourcesDirectory];
NSString *cerPath = [frameworkBundle pathForResource:resource ofType:@"der"];
if (cerPath != nil) {
*certificate = [NSData dataWithContentsOfFile:cerPath];
}
Expand Down
3 changes: 1 addition & 2 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5293,8 +5293,7 @@ + (UIImage *)resourceImageNamed:(NSString *)imageName
NSString *extension = imageName.pathExtension.length ? imageName.pathExtension : @"png";
NSBundle *bundle = [NSBundle mgl_frameworkBundle];
NSString *path = [bundle pathForResource:imageName.stringByDeletingPathExtension
ofType:extension
inDirectory:bundle.mgl_resourcesDirectory];
ofType:extension];
if ( ! path)
{
[NSException raise:@"Resource not found" format:
Expand Down