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

Migrate iOS and OS X targets to checked-in Xcode projects #4641

Merged
merged 20 commits into from
Apr 17, 2016
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 3 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
path = .mason
url = https://github.com/mapbox/mason.git

[submodule "test/ios/KIF"]
path = platform/ios/test/KIF
url = https://github.com/kif-framework/KIF.git

[submodule "platform/ios/vendor/SMCalloutView"]
path = platform/ios/vendor/SMCalloutView
url = https://github.com/nfarina/calloutview.git

[submodule "platform/ios/uitest/KIF"]
path = platform/ios/uitest/KIF
url = https://github.com/kif-framework/KIF.git
46 changes: 29 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,58 @@ default:
#### OS X targets ##############################################################

OSX_PROJ_PATH = build/osx-x86_64/platform/osx/platform.xcodeproj

osx:
$(RUN) PLATFORM=osx Xcode/All
OSX_WORK_PATH = platform/osx/osx.xcworkspace
OSX_DERIVED_DATA_PATH = build/DerivedData/osx

$(OSX_PROJ_PATH): platform/osx/platform.gyp platform/osx/scripts/configure.sh mbgl.gypi test/test.gypi bin/*.gypi
$(RUN) PLATFORM=osx Xcode/__project__

xproj: $(OSX_PROJ_PATH)
open $(OSX_PROJ_PATH)
osx: $(OSX_PROJ_PATH)
set -o pipefail && xcodebuild \
-derivedDataPath $(OSX_DERIVED_DATA_PATH) \
-configuration $(BUILDTYPE) \
-workspace $(OSX_WORK_PATH) -scheme CI build | xcpretty

$(OSX_PROJ_PATH)/xcshareddata/xcschemes/osxtest.xcscheme: platform/osx/scripts/osxtest.xcscheme
mkdir -p $(basename $@)
cp $< $@
xproj: $(OSX_PROJ_PATH)
open $(OSX_WORK_PATH)

test-osx: $(OSX_PROJ_PATH) $(OSX_PROJ_PATH)/xcshareddata/xcschemes/osxtest.xcscheme node_modules/express
set -o pipefail && xcodebuild -project $(OSX_PROJ_PATH) -configuration $(BUILDTYPE) -target test build | xcpretty
ulimit -c unlimited && (build/osx-x86_64/$(BUILDTYPE)/test & pid=$$! && wait $$pid \
test-osx: osx node_modules/express
ulimit -c unlimited && ($(OSX_DERIVED_DATA_PATH)/Build/Products/$(BUILDTYPE)/test & pid=$$! && wait $$pid \
|| (lldb -c /cores/core.$$pid --batch --one-line 'thread backtrace all' --one-line 'quit' && exit 1))
set -o pipefail && xcodebuild -project $(OSX_PROJ_PATH) -configuration $(BUILDTYPE) -scheme osxtest test | xcpretty
set -o pipefail && xcodebuild \
-derivedDataPath $(OSX_DERIVED_DATA_PATH) \
-configuration $(BUILDTYPE) \
-workspace $(OSX_WORK_PATH) -scheme CI test | xcpretty

#### iOS targets ##############################################################

IOS_PROJ_PATH = build/ios-all/platform/ios/platform.xcodeproj
IOS_WORK_PATH = platform/ios/ios.xcworkspace
IOS_DERIVED_DATA_PATH = build/DerivedData/ios

$(IOS_PROJ_PATH): platform/ios/platform.gyp platform/ios/scripts/configure.sh mbgl.gypi test/test.gypi
$(RUN) PLATFORM=ios Xcode/__project__

ios: $(IOS_PROJ_PATH)
set -o pipefail && xcodebuild \
ARCHS=i386 ONLY_ACTIVE_ARCH=YES \
ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES \
-derivedDataPath $(IOS_DERIVED_DATA_PATH) \
-configuration $(BUILDTYPE) -sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' \
-project $(IOS_PROJ_PATH) -target All build | xcpretty
-workspace $(IOS_WORK_PATH) -scheme CI build | xcpretty

iproj: $(IOS_PROJ_PATH)
open $(IOS_PROJ_PATH)
open $(IOS_WORK_PATH)

test-ios: ios
ios-sim start
ios-sim launch build/ios-all/$(BUILDTYPE)-iphonesimulator/ios-test.app --verbose
ios-sim start --devicetypeid 'com.apple.CoreSimulator.SimDeviceType.iPhone-6,9.3'
ios-sim launch $(IOS_DERIVED_DATA_PATH)/Build/Products/$(BUILDTYPE)-iphonesimulator/ios-test.app --verbose --devicetypeid 'com.apple.CoreSimulator.SimDeviceType.iPhone-6,9.3'
set -o pipefail && xcodebuild \
ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES \
-derivedDataPath $(IOS_DERIVED_DATA_PATH) \
-configuration $(BUILDTYPE) -sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' \
-workspace $(IOS_WORK_PATH) -scheme CI test | xcpretty

ipackage: $(IOS_PROJ_PATH)
BITCODE=$(BITCODE) FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=$(SYMBOLS) \
Expand Down
10 changes: 10 additions & 0 deletions mbgl.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'GCC_WARN_PEDANTIC': 'YES',
'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE',
'MACOSX_DEPLOYMENT_TARGET': '10.10',
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'COMBINE_HIDPI_IMAGES': 'YES',
},
}, {
'cflags_cc': [
Expand Down Expand Up @@ -120,6 +122,14 @@
},
},
},
'configurations': {
'Debug': {
'xcode_settings': {
'ENABLE_TESTABILITY': 'YES',
'ONLY_ACTIVE_ARCH': 'YES',
},
},
},
'targets': [
{
'target_name': 'core',
Expand Down
10 changes: 0 additions & 10 deletions platform/darwin/src/MGLAccountManager.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#import "MGLAccountManager_Private.h"
#import "MGLMapView.h"
#import "NSBundle+MGLAdditions.h"
#import "NSProcessInfo+MGLAdditions.h"
#import "NSString+MGLAdditions.h"

#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
#import "MGLMapboxEvents.h"
Expand Down Expand Up @@ -108,14 +106,6 @@ + (void)initializeIfNeeded {
} else {
NSLog(@"MGLAccountManager is used in a project that doesn’t have Fabric.");
}

// https://github.com/mapbox/mapbox-gl-native/issues/2966
mgl_linkBundleCategory();
mgl_linkStringCategory();
mgl_linkProcessInfoCategory();

// https://github.com/mapbox/mapbox-gl-native/issues/3113
[MGLMapView class];
}

#endif
Expand Down
1 change: 0 additions & 1 deletion platform/darwin/src/MGLOfflinePack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#import "MGLTilePyramidOfflineRegion.h"

#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/util/string.hpp>

/**
Assert that the current offline pack is valid.
Expand Down
2 changes: 0 additions & 2 deletions platform/darwin/src/NSBundle+MGLAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

NS_ASSUME_NONNULL_BEGIN

void mgl_linkBundleCategory();

@interface NSBundle (MGLAdditions)

/// Returns the bundle containing the SDK’s classes and Info.plist file.
Expand Down
2 changes: 0 additions & 2 deletions platform/darwin/src/NSBundle+MGLAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#import "MGLAccountManager.h"

void mgl_linkBundleCategory() {}

@implementation NSBundle (MGLAdditions)

+ (instancetype)mgl_frameworkBundle {
Expand Down
2 changes: 0 additions & 2 deletions platform/darwin/src/NSProcessInfo+MGLAdditions.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#import <Foundation/Foundation.h>

void mgl_linkProcessInfoCategory();

@interface NSProcessInfo (MGLAdditions)

/**
Expand Down
2 changes: 0 additions & 2 deletions platform/darwin/src/NSProcessInfo+MGLAdditions.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#import "NSProcessInfo+MGLAdditions.h"

void mgl_linkProcessInfoCategory() {}

#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
static NSString * const MGLIBDesignablesAgentProcessName = @"IBDesignablesAgentCocoaTouch";
#elif TARGET_OS_MAC
Expand Down
2 changes: 0 additions & 2 deletions platform/darwin/src/NSString+MGLAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

NS_ASSUME_NONNULL_BEGIN

void mgl_linkStringCategory();

@interface NSString (MGLAdditions)

/** Returns the receiver if non-empty or nil if empty. */
Expand Down
2 changes: 0 additions & 2 deletions platform/darwin/src/NSString+MGLAdditions.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#import "NSString+MGLAdditions.h"

void mgl_linkStringCategory() {}

@implementation NSString (MGLAdditions)

- (nullable NSString *)mgl_stringOrNilIfEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ - (void)testCoordinateBoundsIsEmpty {
}

- (void)testAngleConversions {
XCTAssertEqual(-180, MGLDegreesFromRadians(-M_PI));
XCTAssertEqualWithAccuracy(-180, MGLDegreesFromRadians(-M_PI), 5);
XCTAssertEqual(0, MGLDegreesFromRadians(0));
XCTAssertEqual(45, MGLDegreesFromRadians(M_PI_4));
XCTAssertEqual(90, MGLDegreesFromRadians(M_PI_2));
XCTAssertEqual(180, MGLDegreesFromRadians(M_PI));
XCTAssertEqual(360, MGLDegreesFromRadians(2 * M_PI));
XCTAssertEqual(720, MGLDegreesFromRadians(4 * M_PI));
XCTAssertEqualWithAccuracy(45, MGLDegreesFromRadians(M_PI_4), 5);
XCTAssertEqualWithAccuracy(90, MGLDegreesFromRadians(M_PI_2), 5);
XCTAssertEqualWithAccuracy(180, MGLDegreesFromRadians(M_PI), 5);
XCTAssertEqualWithAccuracy(360, MGLDegreesFromRadians(2 * M_PI), 5);
XCTAssertEqualWithAccuracy(720, MGLDegreesFromRadians(4 * M_PI), 5);

XCTAssertEqual(-360, MGLDegreesFromRadians(MGLRadiansFromDegrees(-360)));
XCTAssertEqual(-180, MGLDegreesFromRadians(MGLRadiansFromDegrees(-180)));
XCTAssertEqual(-90, MGLDegreesFromRadians(MGLRadiansFromDegrees(-90)));
XCTAssertEqual(-45, MGLDegreesFromRadians(MGLRadiansFromDegrees(-45)));
XCTAssertEqual(0, MGLDegreesFromRadians(MGLRadiansFromDegrees(0)));
XCTAssertEqual(45, MGLDegreesFromRadians(MGLRadiansFromDegrees(45)));
XCTAssertEqual(90, MGLDegreesFromRadians(MGLRadiansFromDegrees(90)));
XCTAssertEqual(180, MGLDegreesFromRadians(MGLRadiansFromDegrees(180)));
XCTAssertEqual(360, MGLDegreesFromRadians(MGLRadiansFromDegrees(360)));
XCTAssertEqualWithAccuracy(-360, MGLDegreesFromRadians(MGLRadiansFromDegrees(-360)), 4);
XCTAssertEqualWithAccuracy(-180, MGLDegreesFromRadians(MGLRadiansFromDegrees(-180)), 5);
XCTAssertEqualWithAccuracy(-90, MGLDegreesFromRadians(MGLRadiansFromDegrees(-90)), 5);
XCTAssertEqualWithAccuracy(-45, MGLDegreesFromRadians(MGLRadiansFromDegrees(-45)), 5);
XCTAssertEqualWithAccuracy(0, MGLDegreesFromRadians(MGLRadiansFromDegrees(0)), 5);
XCTAssertEqualWithAccuracy(45, MGLDegreesFromRadians(MGLRadiansFromDegrees(45)), 5);
XCTAssertEqualWithAccuracy(90, MGLDegreesFromRadians(MGLRadiansFromDegrees(90)), 5);
XCTAssertEqualWithAccuracy(180, MGLDegreesFromRadians(MGLRadiansFromDegrees(180)), 5);
XCTAssertEqualWithAccuracy(360, MGLDegreesFromRadians(MGLRadiansFromDegrees(360)), 4);
}

- (void)testAltitudeConversions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ - (void)testSharedObject {

// This test needs to come first so it can test the initial loading of packs.
- (void)testAAALoadPacks {
XCTestExpectation *kvoExpectation = [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
[self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
NSKeyValueChange changeKind = [change[NSKeyValueChangeKindKey] unsignedIntegerValue];
return changeKind = NSKeyValueChangeSetting;
}];
Expand Down Expand Up @@ -106,7 +106,7 @@ - (void)testRemovePack {
MGLOfflinePack *pack = [MGLOfflineStorage sharedOfflineStorage].packs.lastObject;
XCTAssertNotNil(pack, @"Added pack should still exist.");

XCTestExpectation *kvoExpectation = [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
[self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
NSKeyValueChange changeKind = [change[NSKeyValueChangeKindKey] unsignedIntegerValue];
NSIndexSet *indices = change[NSKeyValueChangeIndexesKey];
return changeKind = NSKeyValueChangeRemoval && indices.count == 1;
Expand Down
3 changes: 3 additions & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Mapbox welcomes participation and contributions from everyone. If you’d like

## master

- Applications linking against the SDK static framework no longer need to add `-ObjC` to the Other Linker Flags (`OTHER_LDFLAGS`) build setting. If you previously added this flag solely for this SDK, removing the flag may potentially reduce the overall size of your application. ([#4641](https://github.com/mapbox/mapbox-gl-native/pull/4641))
- Removed the `armv7s` slice from the SDK to reduce its size. iPhone 5 and iPhone 5c automatically use the `armv7` slice instead. ([#4641](https://github.com/mapbox/mapbox-gl-native/pull/4641))
- User location heading updates now resume properly when an app becomes active again. ([#4674](https://github.com/mapbox/mapbox-gl-native/pull/4674))
- Removed unused SVG files from the SDK’s resource bundle. ([#4641](https://github.com/mapbox/mapbox-gl-native/pull/4641))

## 3.2.0

Expand Down
19 changes: 11 additions & 8 deletions platform/ios/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ The Mapbox iOS SDK and iosapp demo application build against the iOS 7.0 SDK and

make iproj

Which will create and open an Xcode project that can build the entire library from source, as well as an Objective-C test app. Before building, use the scheme picker button in the toolbar to change the scheme from “All (ios project)” to “iosapp” and the destination from “My Mac” to one of the simulators or connected devices listed in the menu.
Which will create and open an Xcode workspace that includes both the SDK source and some Objective-C test applications. Before building, use the scheme picker button in the toolbar to change the scheme to “iosapp” and the destination to one of the simulators or connected devices listed in the menu.

If you don't have an Apple Developer account, change the destination from "My Mac" to a simulator such as "iPhone 6" before you run and build the app.
If you don't have an Apple Developer account, change the destination to a simulator such as "iPhone 6" before you run and build the app.

`ipackage` is only one of several available `make` build targets. Others include:

Expand All @@ -25,12 +25,11 @@ If you don't have an Apple Developer account, change the destination from "My Ma

You can customize the build output by passing the following arguments into the `make` invocation:

* `BITCODE=NO` builds without Bitcode support.
* `BUILD_DEVICE=false` builds only for the iOS Simulator.
* `FORMAT=dynamic` builds only a dynamic framework. `FORMAT=static` builds only a static framework, for compatibility with iOS 7.x.
* `SYMBOLS=NO` strips the build output of any debug symbols, yielding much smaller binaries.

### Access Tokens
### Access tokens

_The demo applications use Mapbox vector tiles, which require a Mapbox account and API access token. Obtain an access token on the [Mapbox account page](https://www.mapbox.com/studio/account/tokens/)._

Expand All @@ -44,13 +43,17 @@ Set up the access token by editing the scheme for the application target, then a

Run

make itest
make test-ios

To run the included integration tests on the command line.
To run the included unit tests and integration tests on the command line.

If you want to run the tests in Xcode instead, first `make ipackage` to create a local static library version, then open `platform/ios/test/ios-tests.xcodeproj`, and lastly `Command + U` on the `Mapbox GL Tests` application target.
To instead run the tests in Xcode:

### Usage
1. Run `make iproj` to set up the workspace.
1. Change the scheme to “test (platform project)” and press Command-R to run core unit tests.
1. Change the scheme to “CI” and press Command-U to run SDK integration tests.

### iosapp usage

- Pan to move
- Pinch to zoom
Expand Down
2 changes: 0 additions & 2 deletions platform/ios/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ If your application targets iOS 7.x, you’ll need to install the static framewo
- `libsqlite3.tbd`
- `libz.tbd`

1. In the Build Settings tab, add `-ObjC` to the “Other Linker Flags” (`OTHER_LDFLAGS`) build setting.

### Use

1. Mapbox vector tiles require a Mapbox account and API access token. In the project editor, select the application target. In the Info tab, set `MGLMapboxAccessToken` to your access token. You can obtain one from the [Mapbox account page](https://www.mapbox.com/studio/account/tokens/).
Expand Down
Loading