You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is it possible to embed flutter into an exsiting iOS project without install flutter environment? #24948
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!
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.
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.
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.
@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.
@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.
@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.
@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
@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.
@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:
the flutter ViewController is empty.
I can't publish my app use debug mode : (
How did you succeed?
@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.
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.
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.
Activity
wouterhardeman commentedon Dec 4, 2018
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.
tkYan commentedon Dec 4, 2018
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.
wouterhardeman commentedon Dec 4, 2018
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.
tkYan commentedon Dec 4, 2018
Configure flutter environment in MacOS is quite complicated, I don't think "include the flutter environment into your git repository" is a good idea.
tkYan commentedon Dec 4, 2018
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
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.
hnvn commentedon Dec 12, 2018
@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.
tkYan commentedon Dec 12, 2018
@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.
hnvn commentedon Dec 13, 2018
There's an App.framework in .ios/Flutter folder, but it's very small and I cannot import it in my Xcode project
tkYan commentedon Dec 17, 2018
@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.
sdaduanbilei commentedon Dec 25, 2018
@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
tkYan commentedon Dec 27, 2018
@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.
wangyutao0424 commentedon Feb 10, 2019
@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:
the flutter ViewController is empty.
I can't publish my app use debug mode : (
How did you succeed?
tkYan commentedon Feb 15, 2019
@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.
tkYan commentedon Feb 15, 2019
@wouterhardeman My problem may not related with your problem, but I hope it could help you.
neiljaywarner commentedon Mar 1, 2019
@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...
github-actions commentedon Aug 14, 2021
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 -vand a minimal reproduction of the issue.