Skip to content

Is it possible to embed flutter into an exsiting iOS project without install flutter environment? #24948

Closed

Description

@tkYan

I am trying to integrating Flutter into our current iOS project.
However, we have a lot of members in our team, it is really hard to push all of them install flutter environment.
So I tried to embed only App.framework, Flutter.framework and flutter_assets in the project, and it seems work fine in other people's machine without any flutter tools installed.
However there is no document illustrate this workflow. I do wonder if there is any side effect to follow the process described above. And if it is fine to ignore Generated.xcconfig after framework is generated.
Thanks for any help!

Activity

  1. wouterhardeman commented on Dec 4, 2018

    @wouterhardeman

    That should work just fine. The only downside is that you have to manually add / replace the files every time the Flutter app is changed.

    I think the Generated.xcconfig can be ignored if you just load in the .framework files and flutter_assets, but I'm not sure.

  2. added
    d: api docsIssues with https://api.flutter.dev/
    a: existing-appsIntegration with existing apps via the add-to-app flow
    toolAffects the "flutter" command-line tool. See also t: labels.
    engineflutter/engine related. See also e: labels.
    on Dec 4, 2018
  3. added this to the milestone on Dec 4, 2018
  4. tkYan commented on Dec 4, 2018

    @tkYan
    Author

    That should work just fine. The only downside is that you have to manually add / replace the files every time the Flutter app is changed.

    I think the Generated.xcconfig can be ignored if you just load in the .framework files and flutter_assets, but I'm not sure.

    Thanks for your reply.
    I just read "xcode_backend.sh", it seems we should do more things than just embed the frameworks.
    Flutter would generate different frameworks in debug or release build.
    So Only embed frameworks seems not enough, I also need to write a script to replace frameworks in different release types.
    That seems not friendly enough.....
    Now I wonder is it possible to only embed release frameworks regardless actual release types, since I don't want to debug.

  5. wouterhardeman commented on Dec 4, 2018

    @wouterhardeman

    It's an option to include the flutter environment into your git repository, maybe using git submodules. Then you could use refer to that Flutter environment to build in XCode and other developers don't need to install it globally themselves.

  6. tkYan commented on Dec 4, 2018

    @tkYan
    Author

    Configure flutter environment in MacOS is quite complicated, I don't think "include the flutter environment into your git repository" is a good idea.

  7. tkYan commented on Dec 4, 2018

    @tkYan
    Author

    Update: I just build a release frameworks and used it in a demo project. A release framework is just a half smaller than a debug framework. It works fine in debug build configuration.
    However I noticed, in "xcode_backend.sh", it is said

     "========================================================================"
          EchoError "ERROR: Flutter does not support running in profile or release mode on"
          EchoError "the Simulator (this build was: '$build_mode')."
          EchoError "You can ensure Flutter runs in Debug mode with your host app in release"
          EchoError "mode by setting FLUTTER_BUILD_MODE=debug in the .xcconfig associated"
          EchoError "with the ${CONFIGURATION} build configuration."
          EchoError "========================================================================"
    

    I do success run a release build with release type Flutter Framework in simulator. All function seems work well, which makes me a little confused.

  8. hnvn commented on Dec 12, 2018

    @hnvn

    @tkYan , Could you give more information about how you build your Flutter module into a framework? I'm stuck in this case. in Android, I can pack my Flutter module into .aar file and an existing Android project can use it easily.

  9. tkYan commented on Dec 12, 2018

    @tkYan
    Author

    @hnvn , I just follow official guide to configure and build Flutter module.
    The framework would be generated automatically, all I need to do is find these frameworks and copy them.
    FYI, in iOS, The framework can be found under "modulePath/.ios/Flutter".
    I noticed that there is an equivalent folder under modulePath, which named ".android". You may find the files you want there.
    Read the scripts and understand the build process, could be very helpful.

  10. hnvn commented on Dec 13, 2018

    @hnvn

    There's an App.framework in .ios/Flutter folder, but it's very small and I cannot import it in my Xcode project

  11. tkYan commented on Dec 17, 2018

    @tkYan
    Author

    @hnvn you can import App.framework as embed binary but not as linked framework. And you should also import Flutter.framework. For Plugins, you should do more things than that. BTW, I have successed submit my app into iTunes Connect.

  12. sdaduanbilei commented on Dec 25, 2018

    @sdaduanbilei

    @tkYan @hnvn Is there a demo, the idea is not to publish Flutter.framework and App.framework flutter_assets products through Pod, then the new project to get flutter business through pod install, can see your podspec file

  13. tkYan commented on Dec 27, 2018

    @tkYan
    Author

    @sdaduanbilei The idea is use two project to finish this job. One project configured as the document said, it will generate the frameworks you need. Then your product project should import these frameworks. You don't really need to use cocoapods in your product project.
    I tried to use cocoapods to maintain these frameworks in my product project. But it seems to have problem with locating "flutter_assets", I suppose we may need to modify flutter engine to solve this problem. But as I said, you can just import these frameworks and flutter_assets in your product project, and don't really need to configure cocoapods.

  14. wangyutao0424 commented on Feb 10, 2019

    @wangyutao0424

    @tkYan I tried to do this. The steps:
    1, Use 'flutter build ios' build my flutter module
    2, Create a podspec in this module, and refrence App.framework, Flutter.framwork and flutter_assets
    3, Create an iOS project, and use podfile to integrated into the project
    4, Run the project

    When I used --debug to build, it run.
    But I got something wrong when I used --release:
    image
    the flutter ViewController is empty.
    I can't publish my app use debug mode : (
    How did you succeed?

  15. tkYan commented on Feb 15, 2019

    @tkYan
    Author

    @wouterhardeman I have encounter a similiar problem before.
    It seems Flutter engine cannot locate flutter_assets, and failed to run.
    You should import flutter_assets fold as a whole, and cannot just import files inside it.
    I cannot figure a way to achieve this goal with cocoapods.
    Another problem to import flutter assets with cocoapods is your flutter asset would be in your pod bundle but not main bundle, and may lead to an locating error.
    So I did not use cocoapods to import flutter frameworks and assets.
    I use two project, one project with flutter code, and generate App.framework, Flutter.framwork and flutter_assets, another project import framework as binary and import flutter_assets as resource.
    The only problem in this way is you should use different frameworks in debug and release mode.
    But this work could be finished by a script automatically.
    My app is already in app store, so it should work.

  16. tkYan commented on Feb 15, 2019

    @tkYan
    Author

    @wouterhardeman My problem may not related with your problem, but I hope it could help you.

  17. neiljaywarner commented on Mar 1, 2019

    @neiljaywarner

    It's an option to include the flutter environment into your git repository, maybe using git submodules. Then you could use refer to that Flutter environment to build in XCode and other developers don't need to install it globally themselves.

    @wouterhardeman I am thinking about doing this but I could use a little guidance please. I am not expert at submodules I made a submodule for the flutter module that seems to be working pretty good. if we were to use flutter SDK as a submodule would it be better to
    a) keep our own private copy of flutter SDK on our own servers, in our own repo, a fork?
    b) Go ahead and point to Flutter's gitub repo - I think this is what i want to do, but i was a bit nervous about knowing how to emulate stable channel.

    Do i just point to the hash 06b979c b/c it is marked as 1.2 in
    https://github.com/flutter/flutter/releases and then manually look at the page again when 1.4 comes out?L

    c) the installation bundle pages says 'compile the flutter tool'... if i pull down that repo how do i build the engine?

    I guess this is related to 'simplify installation process' in a way, but i think this is very important...

  18. github-actions commented on Aug 14, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  19. locked as resolved and limited conversation to collaborators on Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: existing-appsIntegration with existing apps via the add-to-app flowd: api docsIssues with https://api.flutter.dev/engineflutter/engine related. See also e: labels.toolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions