Skip to content

Update iOS add-to-app project setup instructions#3317

Merged
jmagman merged 6 commits into
flutter:staging-add-to-app-do-not-delete-until-2020from
jmagman:ios-setup
Dec 5, 2019
Merged

Update iOS add-to-app project setup instructions#3317
jmagman merged 6 commits into
flutter:staging-add-to-app-do-not-delete-until-2020from
jmagman:ios-setup

Conversation

@jmagman

@jmagman jmagman commented Nov 28, 2019

Copy link
Copy Markdown
Member

First part of flutter/flutter#45224.

@jmagman jmagman requested review from sfshaza2 and xster November 28, 2019 01:30
@jmagman jmagman self-assigned this Nov 28, 2019
@googlebot googlebot added the cla: yes Contributor has signed the Contributor License Agreement label Nov 28, 2019
@jmagman

jmagman commented Nov 28, 2019

Copy link
Copy Markdown
Member Author

I need to figure out how to deploy this to see how it looks.

Comment thread src/docs/development/add-to-app/ios/project-setup.md
You can also run in [Android Studio/IntelliJ][] or [VS Code][] with the Flutter and Dart plugins.
This will run a single-view example version of your module without being
embedded in your existing application. This can be useful for testing
quick, incremental changes with hot reload.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes it sound like you can't hot reload if you embedded into your existing app

in any other Flutter project, like `flutter run --debug` or `flutter build ios`.
You can also run in [Android Studio/IntelliJ][] or [VS Code][] with the Flutter and Dart plugins.
This will run a single-view example version of your module without being
embedded in your existing application. This can be useful for testing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing flutter only parts


There is a `.ios/` hidden subfolder which contains a Xcode workspace where you can
run a stand-alone version of your module. It also contains helper scripts to embed
the module into your existing application with [CocoaPods][].

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or build frameworks from

{{site.alert.note}}
Custom iOS code should be added to your existing application or a plugin, not
the module in `.ios/`. Changes made in `.ios/` will not be embedded in your existing application.
The directory can be regenerated by running `flutter clean` in the `my_flutter` directory.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't everything get overwritten too each time flutter packages get is run too? flutter/flutter#28135

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/docs/development/add-to-app/ios/project-setup.md
CocoaPods as a vendored framework. This has to match up with the release type
(debug/profile/release) as well as the architecture for your app (arm*,
x86_64, etc.).
- `App.framework` (your Flutter application binary) is being embedded into your

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Flutter framework is in there too

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use "*" to indicate a bulleted list, rather than minus? (I know this was there before...)

Also, I am not sure what the point of this section is. It seems like it's there to just tell the user what's going on, but you've deleted the introductory sentence explaining that it's there just to let you know what's going on. Can you add that back (or something similar)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's useful, the contents are almost untouched from what was there before. I'm happy to remove the entire section if you don't think it's useful. I removed the intro because I didn't want to imply anything would go wrong following these steps.

with the Dart code that's actually in the folder. It also uses your Xcode build configuration (Debug, Profile, Release) to embed the matching
release type of `Flutter.framework` and `App.framework`. No newline at end of file
- `Flutter.framework` (the Engine library) is being embedded into your application by
CocoaPods as a vendored framework. This has to match up with the release type

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to match sounds like you're telling the user to do something, but not what or how

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can you make this sentence more active? ->
"CocoaPods embeds the engine library (Flutter.framework) into your app as a vendored framework.

If you are using the above [Embed with CocoaPods and Flutter tools](#embed-with-CocoaPods-and-Flutter-tools)
method, you can skip these instructions.

Let's assume you want to generate the frameworks to `some/path/MyApp/Flutter/`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to double take to realize that this is a future path you want to put things into

Comment thread src/docs/development/add-to-app/ios/project-setup.md
---

TODO(jmagman): add the pre-built framework alternative and review.
Flutter can be embedded into your existing iOS application in a piecemeal fashion as

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably delete "in a piecemeal fashion", which might confuse some. Also, I'd change "as frameworks or libraries" to "as a framework or library." But, I have to ask, does it really make sense to add a "Flutter framework" to an iOS app? Finally, I'd change the passive voice to active. So:

"You can embed a Flutter library into your existing iOS application."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it really make sense to add a "Flutter framework" to an iOS app

Yup, that's the feature! The user has an existing Flutter-free iOS app, and they want to add Flutter bits to it without migrating to Flutter wholesale or starting over as a Flutter app. These bits are generated as "libraries" or "frameworks" (Apple's wording, not ours) and then embedded into the existing iOS app.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably delete "in a piecemeal fashion", which might confuse some

Sounds good, though I copied this from https://github.com/flutter/website/blob/staging-add-to-app-do-not-delete-until-2020/src/docs/development/add-to-app/index.md

## Create a Flutter module

To integrate a Flutter module into your app, use the following steps:
In order to embed Flutter into your existing application, first create a Flutter module.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete "in order". -> "To embed Flutter..."

In order to embed Flutter as a library, use the Flutter module template.
Executing `flutter create -t module xxx` produces a Flutter project with a
CocoaPods pod designed for consumption by your existing host app.
In that directory you can run the same `flutter` commands you would

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which directory is "that directory"? Do you mean the top of the project? It's not clear to me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some/path/my_flutter/ from the previous sentence. I'll combine.

In that directory you can run the same `flutter` commands you would
in any other Flutter project, like `flutter run --debug` or `flutter build ios`.
You can also run in [Android Studio/IntelliJ][] or [VS Code][] with the Flutter and Dart plugins.
This will run a single-view example version of your module without being

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid future tense. "This will run..." -> "This runs..."

CocoaPods pod designed for consumption by your existing host app.
In that directory you can run the same `flutter` commands you would
in any other Flutter project, like `flutter run --debug` or `flutter build ios`.
You can also run in [Android Studio/IntelliJ][] or [VS Code][] with the Flutter and Dart plugins.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, are they running the iOS app from AS/IntelliJ, VS Code?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way to run normal iOS apps is from Xcode, but you can run the Flutter module part from any Flutter IDEs.

(debug/profile/release) as well as the architecture for your app (arm*,
x86_64, etc.).
- `App.framework` (your Flutter application binary) is being embedded into your
application by CocoaPods as a vendored framework.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto (make the sentence more active): ->
Cocoapods embeds your Flutter application binary (App.framework) into your app as a vendored framework.

x86_64, etc.).
- `App.framework` (your Flutter application binary) is being embedded into your
application by CocoaPods as a vendored framework.
- Flutter plugins with iOS platform code are added as CocoaPod pods.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this accurate? (I'm trying to make it more active): ->
CocoaPods adds the Flutter plugins with iOS platform code.

- A build script is added to the Podfile targets that call `install_all_flutter_pods`
to ensure that the binaries you build stay up to date with the Dart code in
the Flutter module. It also uses your Xcode build configuration (Debug, Profile, Release)
to embed the matching build mode type of `Flutter.framework` and `App.framework`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accurate?
The framework adds a build script to each Podfile target that calls install_all_flutter_pods.
This ensures that the binary stays up to date with the Dart code in the Flutter module.

Comment thread src/docs/development/add-to-app/ios/project-setup.md Outdated
You should now be able to build the project using `⌘B`.

### Under the hood
- The frameworks are added to the target's Link Binary with Libraries and Embed Frameworks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much passive voice! And non-asterisk bullets. It would be nice if all items in this list used active voice, as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the "Under the hood" sections.

@xster xster left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Comment thread src/docs/development/add-to-app/ios/project-setup.md
Comment thread src/docs/development/add-to-app/ios/project-setup.md
### Embed frameworks in Xcode

Alternatively, you can generate the necessary frameworks and embed them in your application
by manually editing your existing Xcode project.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a sentence for why you might want to do this

@sfshaza2 sfshaza2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to get this into the hands of my editor, so LGTM.


### Embed with CocoaPods and the Flutter SDK

This method requires every developer working on your project to have a locally installed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some pros and cons. e.g. you can just click run in xcode and not have to build 2 things when you're rapidly iterating.

of plugins read by the `podhelper.rb` script. Then run `pod install` again from
`some/path/MyApp`.
in your application at`some/path/MyApp`.
{{site.alert.end}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have to do this if you flutter upgrade or flutter channel too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think upgrade or channel would alter anything in .flutter-plugins, but I can add it if you know something I don't.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just guessing. Wouldn't this change the engine framework which gets copied over to your .ios folder if you ran flutter packages get? Don't know if you need a subsequent pod install to make things match.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The right version of the Flutter.framework should get copied the next time they run their app via the xcode_backend script.

Alternatively, you can generate the necessary frameworks and embed them in your application
by manually editing your existing Xcode project. You may choose to do this if members of your
team cannot locally install Flutter SDK and CocoaPods, or if you do not wish to use CocoaPods
as a dependency manager in your existing applications.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention that the downside is that you have to run flutter build ios-framework each time you change things in Flutter

the flags `--xcframework --no-universal`.
{{site.alert.end}}

Open your existing project in Xcode and drag the frameworks from `some/path/MyApp/Flutter/Release/` in Finder

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Say that this is just one arbitrary way of integrating we're using as an example. You don't have to do this and you can integrate in whichever way you prefer.

following to integrate with your `my_flutter` app:
If your existing application (`MyApp`) does not already have a Podfile, follow the
[CocoaPods getting started guide][] to add a `Podfile` to your project.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I suspect a non-trivial amount of people might fall into the i-opened-the-xcodeproj-file-instead-of-the-xcworkspace-file and will run into an error. Perhaps spell that out as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned it. Fortunately pod on its own has a better log about using xcworkspace than flutter does, so hopefully they see it.

@jmagman jmagman merged commit cc9280b into flutter:staging-add-to-app-do-not-delete-until-2020 Dec 5, 2019
@jmagman jmagman deleted the ios-setup branch December 5, 2019 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Contributor has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants