Build Flutter app as a framework on iOS (#8971)

**THIS IS A BREAKING CHANGE.** See below for migration steps for
existing projects.

Previously, Flutter app code was built as a raw dylib on iOS.  Dynamic
libraries outside of a framework bundle are not supported on iOS, except
for the system Swift libraries provided by Xcode.

See:
https://developer.apple.com/library/content/technotes/tn2435/_index.html#//apple_ref/doc/uid/DTS40017543-CH1-TROUBLESHOOTING_BUNDLE_ERRORS-EMBEDDED__DYLIB_FILES

* Migrates Xcode build from app.dylib to App.framework
* Migrates flutter create template
* Migrates example projects

Migration steps for existing projects
=====================================

The following steps should be taken from the root of your Flutter
project:

1. Edit `ios/.gitignore`: add `/Flutter/App.framework` on a new line.
2. In the Xcode project navigator, remove `app.dylib` from the Flutter
   folder. Delete this file from the `ios/Flutter` directory in your project.
3. Run a build to generate `ios/Flutter/App.framework`. From the command
   line, run `flutter build ios`. If you have not configured app signing
   in Xcode, an alternative method is to open the simulator, then run
   `flutter run -d iP`.
4. In the Xcode project navigator, select the `Runner` project. In the
   project settings that are displayed in the main view, ensure that the
   `Runner` target is selected. You can verify this by exposing the
   sidebar using the [| ] icon in the upper-left corner of the main
   view.
5. Select the *General* tab in the project settings. Under the
   *Embedded Binaries* section, click '+' to add `App.framework`. In the
   sheet that drops down, click the *Add Other...* button. Navigate to
   the `ios/Flutter` directory and select `App.framework`. Click *Open*.
   In the sheet that drops down, select *Create folder references*, then
   click *Finish*.
6. In the project settings, verify that `App.framework` has been added to the
   *Embedded Binaries* and *Linked Frameworks and Libraries* lists.
7. In the Xcode project navigator, drag `App.framework` under the
   Flutter folder.
8. In the Xcode project navigator, select `Flutter` then from the
   *File* menu, select *Add Files to "Runner"...*. Navigate to the
   `ios/Flutter` directory, select `AppFrameworkInfo.plist` and click
   the *Add* button.
9. From the command line, in your project directory, run
   `flutter build clean`, then `flutter run`.

At this point your project should be fully migrated.
This commit is contained in:
Chris Bracken
2017-03-22 17:41:49 -07:00
committed by GitHub
parent 358e1cd2e1
commit 0ee3f57a10
23 changed files with 317 additions and 58 deletions

View File

@@ -31,8 +31,8 @@ Icon?
.tags*
/Flutter/app.flx
/Flutter/app.dylib
/Flutter/app.zip
/Flutter/App.framework
/Flutter/Flutter.framework
/Flutter/Generated.xcconfig
/ServiceDefinitions.json

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>8.0</string>
</dict>
</plist>

View File

@@ -7,8 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
3B80C3971E832B3200D905FE /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B80C3961E832B3200D905FE /* AppFrameworkInfo.plist */; };
3B80C3991E832BCF00D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3981E832BCF00D905FE /* App.framework */; };
3B80C39A1E832BCF00D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3981E832BCF00D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3BB1DF161E3AC84F00B1AFE2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BB1DF151E3AC84F00B1AFE2 /* AppDelegate.m */; };
9705A1C51CF9049000538489 /* app.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEB81CF902C7004384FC /* app.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9740EEB41CF90195004384FC /* Flutter.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Flutter.xcconfig */; };
@@ -27,7 +29,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
9705A1C51CF9049000538489 /* app.dylib in Embed Frameworks */,
3B80C39A1E832BCF00D905FE /* App.framework in Embed Frameworks */,
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
@@ -36,12 +38,13 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
3B80C3961E832B3200D905FE /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3981E832BCF00D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
3BB1DF141E3AC84F00B1AFE2 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
3BB1DF151E3AC84F00B1AFE2 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Flutter.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Flutter.xcconfig; path = Flutter/Flutter.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEB71CF902C7004384FC /* app.flx */ = {isa = PBXFileReference; lastKnownFileType = file; name = app.flx; path = Flutter/app.flx; sourceTree = "<group>"; };
9740EEB81CF902C7004384FC /* app.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = app.dylib; path = Flutter/app.dylib; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
@@ -56,6 +59,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3B80C3991E832BCF00D905FE /* App.framework in Frameworks */,
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -67,7 +71,8 @@
isa = PBXGroup;
children = (
9740EEB71CF902C7004384FC /* app.flx */,
9740EEB81CF902C7004384FC /* app.dylib */,
3B80C3981E832BCF00D905FE /* App.framework */,
3B80C3961E832B3200D905FE /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Flutter.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
@@ -177,6 +182,7 @@
9740EEBB1CF902C7004384FC /* app.flx in Resources */,
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */,
3B80C3971E832B3200D905FE /* AppFrameworkInfo.plist in Resources */,
9740EEB41CF90195004384FC /* Flutter.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,