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

Convert iOS SDK into dynamic framework #3183

Merged
merged 14 commits into from
Jan 22, 2016
Merged

Convert iOS SDK into dynamic framework #3183

merged 14 commits into from
Jan 22, 2016

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Dec 4, 2015

make iproj now produces a target that pulls together static libraries like core and platform-ios into a true dynamic framework (as opposed to a static library executable stuffed inside a framework bundle). iosapp is pretty much just a regular iOS application that links Mapbox.framework (except for the inclusion of default_styles.hpp).

For now, I’ve patched support for code signing files in Copy Files build phases into the ancient checked-in copy of gyp, pending #3178.

Dynamic framework distribution relies on a shell script copied from realm/realm-swift#2759. This script works around an App Store bug.

Fixes #828, fixes #3161, paving the way for #1623. Based on #3135 for OS X.

/cc @incanus @friedbunny

@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS build refactor ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Dec 4, 2015
@1ec5 1ec5 self-assigned this Dec 4, 2015
@1ec5 1ec5 added this to the ios-v3.1.0 milestone Dec 4, 2015
@1ec5
Copy link
Contributor Author

1ec5 commented Dec 4, 2015

Current progress on make ipackage:

Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) were found.

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 4, 2015

Um, OK, so apparently the fix is to pass -showBuildSettings to xcodebuild. Huh? Edit: Never mind, that prevented the xcodebuild invocation from doing anything with the framework target.

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 4, 2015

One downside to shipping a true dynamic framework (as opposed to a framework bundle containing a static library, as we do now) is that App Store submissions aren’t allowed to contain simulator content, as reported in Carthage/Carthage#188. If we ship a fat framework containing both device and simulator content, developers will need to strip the irrelevant content before code-signing. (Currently I’m relying on the “code sign on copy” build phase option that gets enabled when you use the Embedded Binaries section in the project editor.)

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 4, 2015

Currently, make ipackage produces a fat framework (with both device and simulator content) that weighs in at 62 MB, and make ipackage-strip reduces it to 42 MB. We’ll have to add instructions for stripping simulator content before submitting to the App Store, like Realm’s, to get around this Xcode bug.

@1ec5 1ec5 changed the title [WIP] Convert iOS SDK into dynamic framework Convert iOS SDK into dynamic framework Dec 5, 2015
@tkrajacic
Copy link

Making the framework compatible with Carthage should now be possible which is awesome!

  • The Xcode scheme that builds the framework needs to be shared for that purpose
  • Better yet, the framework can be prebuilt

See https://github.com/Carthage/Carthage#supporting-carthage-for-your-framework

@1ec5 1ec5 force-pushed the 1ec5-ios-framework-828 branch from abf61a0 to fa7bbc7 Compare December 12, 2015 23:51
@1ec5
Copy link
Contributor Author

1ec5 commented Dec 14, 2015

package.sh now produces a pkg/ folder containing:

  • a dynamically-linked, Bitcode-enabled framework in dynamic/
  • a statically-linked, Bitcode-disabled framework in static/
  • an example Settings.bundle
  • API documentation in documentation/

To minimize our build and test matrix, I’ve omitted options for building a Bitcode-enabled static framework (for deploying back to iOS 7 in Xcode 7) or a Bitcode-disabled dynamic framework (for deploying to iOS 8.x only in Xcode 6.x).

@1ec5 1ec5 removed the ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold label Dec 14, 2015
1ec5 added a commit that referenced this pull request Dec 14, 2015
build/pkg/osx/ probably won’t be used until #3183 lands.
@1ec5 1ec5 force-pushed the 1ec5-ios-framework-828 branch from 937e243 to 38db77c Compare December 14, 2015 08:49
@1ec5 1ec5 force-pushed the 1ec5-ios-framework-828 branch from 38db77c to 495984d Compare December 21, 2015 09:49
@1ec5
Copy link
Contributor Author

1ec5 commented Dec 21, 2015

@friedbunny @incanus @bsudekum (and anyone else interested), I’d like your help with this test plan, in order of priority:

  • CocoaPods (latest version only)
    • Dynamic framework
    • Static library with use_frameworks! (for iOS 7 or Bitcode-less application)
  • Fabric – dynamic framework only
  • Manual drag-and-drop into Xcode
    • Dynamic framework
    • Verify that the framework-stripping script plays nicely with Carthage-installed frameworks (which use a similar stripping mechanism) when exporting
    • Static library (for iOS 7 or Bitcode-less application)
  • react-native-mapbox-gl
    • @bsudekum, this would be a good time for RNMBGL to drop support for iOS 7 so that you only have to distribute a dynamic framework via npm. You’ll need to update the Xcode project to refer to the .framework and remove references to the .a, .bundle, and headers from the project and this script.

Testing one of the workflows above generally involves answering the following questions:

  • Do each of the following scenarios build without warnings or errors:
    • …in both Xcode 6.4 and Xcode 7.2?
    • …whether the application is written in Objective-C or Swift?
    • …whether the MGLMapView is initialized in a storyboard or programmatically (note that -ObjC is no longer required)?
    • …whether the access token is set in the Info.plist or programmatically via -[MGLAccountManager setAccessToken:]?
  • If the MGLMapView is initialized in a storyboard, do inspectables and designables show up? (Xcode 6.4 doesn’t support designables in every case, so it’s fine if it doesn’t work there.)
  • Does the application run without crashing on launch:
    • …in the oldest and newest iOS Simulator versions supported by the Xcode version you’re running?
    • …on at least one device? (For this PR, it probably isn’t particularly important to test on a wide array of devices.)
  • Do assets like the Mapbox logo and default marker image appear?
  • Does also linking CoreTelephony.framework work without crashing (Re-enable CoreTelephony.framework telemetry #3295)?

Let me know if you have any questions about how to test one of these cases. Thanks for your time; hopefully such drastic changes will be a rare occurrence going forward.

@1ec5 1ec5 added ready and removed in progress labels Dec 21, 2015
@friedbunny
Copy link
Contributor

Going to start running through this list today, beginning with CocoaPods.

@friedbunny
Copy link
Contributor

Ran in to #3300, but the post_install fix there works.

@friedbunny
Copy link
Contributor

With CocoaPods and direct install, IBDesignables dies with:

No target found containing the source files defining MGLMapView. The class was found in MGLMapView+IBAdditions.h, MGLMapView.+MGLCustomStyleLayerAdditions.h, and MGLMapView.h. Make sure at least one of these files are in the target.

screen-shot-2015-12-21-at-5 00 44-pm

... the map itself loads as expected in app.

1ec5 added 9 commits January 22, 2016 14:45
Avoid hard-coding the bundle identifier and version string.
The pod now requires iOS 8 and above, since iOS 7 lacks support for dynamic frameworks. iOS 7 support can be obtained by downloading and installing the framework manually. Bumped the version number.
The build output’s readme now explains in full detail the installation process, rather than linking to an online resource that may not match the current version. Also cleaned up the tag-finding code to better handle double-digit situations.
Omit setup instructions for package formats not included in the build output.
CocoaPods dings this pod for not having a separate changelog.
Split API documentation generation into a separate make target that can be run independently of building the SDK.
The API index page serves a different purpose than the readme. It doesn’t need installation instructions, but it does need a brief What’s New section.
@chriszhang4213
Copy link

@1ec5 "The SDK is now distributed as a dynamic framework instead of a static library, resulting in a simpler installation workflow and significantly reduced download size. The framework contains both simulator and device content; due to an Xcode bug, you’ll need to strip out the simulator content before submitting your application to the App Store."

are you guys fix this? or we have to strip out the simulator content for 3.10 framework when submit to app store?

any guide for this?

@1ec5
Copy link
Contributor Author

1ec5 commented Feb 8, 2016

@chriszhang4213, if you follow the installation instructions in the README.md that’s in the ZIP file you download, you’ll be just fine. The last step automatically strips the simulator content for you. Sorry for not making that clear.

@chriszhang4213
Copy link

@1ec5, you mean
"1. In the Build Phases tab, click the + button at the top and select “New Run Script please�. Enter the following code into the script text field:

bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework/strip-frameworks.sh"

"

this step right?

@1ec5
Copy link
Contributor Author

1ec5 commented Feb 9, 2016

Yes, that step will strip out any framework content that doesn’t match the architecture you’re building for. So when you export for the App Store, the script will strip out any simulator content.

@1ec5
Copy link
Contributor Author

1ec5 commented Feb 10, 2016

By the way, if you install using CocoaPods and the use_frameworks! flag, you don’t have to worry about this step at all.

1ec5 added a commit that referenced this pull request Feb 18, 2016
The umbrella header inside the static framework now imports the required iOS SDK frameworks so manual linking is unnecessary. This change corrects a regression introduced in #3183, when the umbrella header used in version 3.0.1 was removed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build iOS Mapbox Maps SDK for iOS refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

explore framework install for iOS dynamically-linked builds for iOS
4 participants