[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to specify targets in add-to-app host apps #7772

Closed
ngminhduong opened this issue Apr 8, 2020 · 18 comments
Closed

Document how to specify targets in add-to-app host apps #7772

ngminhduong opened this issue Apr 8, 2020 · 18 comments
Labels
cl.fixed Issue is closed as fixed co.support Community ask for support dev.existing-apps Relates to integrating Flutter into existing apps from.flutter-sdk Reported via move from flutter/flutter p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. t.add-to-app Relates to adding Flutter components to native app t.framework Relates to Flutter framework target.iOS Target apps on the iOS Platform

Comments

@ngminhduong
Copy link

I tried to integrate flutter module into our existing project.
I have some update some file in .ios folder ex: podfile.
Sometime it was regenerate when i run flutter packages get. So that my configurations was override.
Have anyway to stop it?
Thanks,

@VladyslavBondarenko VladyslavBondarenko added dev.existing-apps Relates to integrating Flutter into existing apps d.new-feature Adds new Flutter content t.dev-tools Relates to DevTools and CLI labels Apr 8, 2020
@jmagman
Copy link
Member
jmagman commented Apr 8, 2020

See documentation.
https://flutter.dev/docs/development/add-to-app/ios/project-setup#module-organization

Add custom iOS code to your own existing application’s project or to a plugin, not to the module’s .ios/ directory. Changes made in your module’s .ios/ directory do not appear in your existing iOS project using the module, and may be overwritten by Flutter.

@jmagman jmagman closed this as completed Apr 8, 2020
@ngminhduong
Copy link
Author

@jmagman I need run flutter Module standalone for testing.
So that I need update Podfile.
I also need update Generated.xcconfig for running for specific target.
But it also alway override.
Any solution for this?
Thanks,

@jmagman
Copy link
Member
jmagman commented Apr 9, 2020

So that I need update Podfile.

What do you need to update in the Podfile?

I also need update Generated.xcconfig for running for specific target.

Do you mean FLUTTER_TARGET? You can specify that with the -t flag
flutter run -t path/to/target.dart

$ flutter run -h
...
-t, --target=<path>                                   The main entry-point file of the application, as run on the device.
                                                      If the --target option is omitted, but a file name is provided on the command line, then that is used instead.
                                                      (defaults to "lib/main.dart")

@ngminhduong
Copy link
Author

Hi @jmagman

What do you need to update in the Podfile?

I need add some local pod dependency to podfile.

Do you mean FLUTTER_TARGET? You can specify that with the -t flag
flutter run -t path/to/target.dart

Yes. That help me with this command. But as you known, with this solution I must always run this command before build native app to in case it was regenerated.

It seem flutter project don't auto regenerate these file. Is that right?. Have anyway to make flutter module work the same with flutter project

Thanks,

@jmagman
Copy link
Member
jmagman commented Apr 9, 2020

But as you known, with this solution I must always run this command before build native app to in case it was regenerated.

@xster I think we need a more comprehensive runWithEntrypoint: example in the documentation.

What do you need to update in the Podfile?

I need add some local pod dependency to podfile.

Can you give us more details about this? Since the module doesn't contain any custom platform code, I'm curious what would need additional dependencies outside Flutter plugins.

@jmagman jmagman reopened this Apr 9, 2020
@jmagman jmagman changed the title Stop regenerate files inside .ios and .android folder in flutter Module Document how to specify targets in add-to-app host apps Apr 9, 2020
@jmagman jmagman added documentation and removed d.new-feature Adds new Flutter content labels Apr 9, 2020
@ngminhduong
Copy link
Author
ngminhduong commented Apr 9, 2020

Can you give us more details about this? Since the module doesn't contain any custom platform code, I'm curious what would need additional dependencies outside Flutter plugins.

Yup. This maybe not a best practices.
But I need add some local dependency pod to podFile and that's pod used by my own flutter plugin.

@jmagman
Copy link
Member
jmagman commented Apr 9, 2020

But I need add some local dependency pod to podFile and that's pod used by my own flutter plugin.

The way to do this is to update your plugin's ios/{plugin}.podspec, not your generated test app Podfile.

@ngminhduong
Copy link
Author

Hi,
I need to add to podfile because this is local development pod. (PKLog_Internal)
This is example of my podfile:

platform :ios, '10.0'
use_frameworks!
inhibit_all_warnings!

flutter_application_path = '../'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
pod 'PKLog_Internal', :path => flutter_application_path + '../../LocalPods/'

And in my plugin podspec:

  s.source_files = 'Classes/**/*'
  s.dependency 'Flutter'
  s.dependency 'PKLog_Internal'
  s.platform = :ios, '10.0'

Because this is local development pod. So I must define it in podfile.
That help plugin can find my local pod.

@ngminhduong
Copy link
Author

Hi @jmagman
We have many other issues when .ios and .android continue regenerate.
I would like it work like flutter project.
Can you suggest us quick way to stop regenerate it from my local environments?

Thanks,

@ngminhduong
Copy link
Author

Another issues with localization.
For debug i need support localization in flutterModule when we run it standalone.
So we add localized string to .ios folder. When .ios folder was regenerated.
Our configs also reset.

@jmagman
Copy link
Member
jmagman commented Apr 10, 2020

The .ios and .android directories are meant to be little bootstrap apps for quick prototype and testing. They are themselves simple add-to-app host apps that do nothing but show a single view. You can create as many of your own little add-to-app host apps that exercise different testing scenarios as you need. The .ios and .android directories will be regenerated on every flutter clean and are really there to get you started, and to bootstrap creation of embeddedable frameworks with flutter build ios-framework

One way to implement your example local development pod would be to make a PKLog_Internal Flutter plugin with an ios/PKLog_Internal.podspec, and reference the path in your module's pubspec.yaml (which doesn't get regenerated) and not your Podfile (which does). Or, again, make your own simple host app where you have total control over the Podfile.

You can implement localization in dart, in the host app, or your own Flutter plugin/CocoaPods (see https://guides.cocoapods.org/syntax/podspec.html#resource_bundles). There are also Flutter plugins that allow sharing native bundle resources over method channels so your dart code can access them. Or, as above, make your own simple host app where you have total control over the Xcode project.

@xster
Copy link
Member
xster commented Apr 10, 2020

@jmagman re: runWithEntrypoint, is https://flutter.dev/docs/development/add-to-app/ios/add-flutter-screen?tab=engine-objective-c-tab#dart-entrypoint what you had in mind? We could cross-reference it higher in the doc.

@jmagman
Copy link
Member
jmagman commented Apr 10, 2020

@xster I guess? I couldn't find anywhere what the definition of "entrypoint" was versus target versus flavor, and I couldn't tell looking at the code, either.

@ngminhduong
Copy link
Author
ngminhduong commented Apr 10, 2020

You can implement localization in dart, in the host app, or your own Flutter plugin/CocoaPods (see https://guides.cocoapods.org/syntax/podspec.html#resource_bundles). There are also Flutter plugins that allow sharing native bundle resources over method channels so your dart code can access them. Or, as above, make your own simple host app where you have total control over the Xcode project.

Yes. I see. But problem is we want run flutter module standalone. That help us easy to debug and implement new feature.
If we make my own simple host app. We cannot use host reload and debug feature. I think host reload and debug very useful with us while developing.
Does stop regenerate .ios and .android folder is impossible?
Can we ask a technical problem:
Why Flutter project can do but flutter module doesn't?

Thanks,

@jmagman
Copy link
Member
jmagman commented Apr 11, 2020

You can connect to the flutter module observatory with flutter attach to hot reload.

@jmagman jmagman removed the t.dev-tools Relates to DevTools and CLI label Apr 11, 2020
@jmagman
Copy link
Member
jmagman commented Apr 11, 2020

When you embed a Flutter module into an iOS app, ONLY the compiled dart code and Flutter plugins and their dependencies get embedded. You can make a great app with custom iOS views and other platform code in .ios, but your Podfile changes and one-off localization strings (that aren't codified in the pubspec, Flutter plugin, etc) won't come over to any host app you embed it in. .ios and .android are little convenience bootstrap apps, any changes you make in there won't persist because no changes you make in there will be embedded into a real host app, and it's not a good test of anything.

@ngminhduong
Copy link
Author

When you embed a Flutter module into an iOS app, ONLY the compiled dart code and Flutter plugins and their dependencies get embedded. You can make a great app with custom iOS views and other platform code in .ios, but your Podfile changes and one-off localization strings (that aren't codified in the pubspec, Flutter plugin, etc) won't come over to any host app you embed it in. .ios and .android are little convenience bootstrap apps, any changes you make in there won't persist because no changes you make in there will be embedded into a real host app, and it's not a good test of anything.

Yup. Got it. We just try to find the best solution when we run flutter module standalone.
We are considering to create a flutter project a copy all source code from flutter module with all config (including podfile, localization strings) for developing.
Maybe that is not a good solution but at least it support us run standalone without a host app while developing.

@darshankawar darshankawar added the t.framework Relates to Flutter framework label Jan 27, 2022
@goderbauer goderbauer added the P4 label Sep 20, 2022
@atsansone atsansone transferred this issue from flutter/flutter Nov 11, 2022
@atsansone atsansone added from.flutter-sdk Reported via move from flutter/flutter and removed documentation labels Nov 11, 2022
@atsansone atsansone added t.add-to-app Relates to adding Flutter components to native app co.support Community ask for support labels Jun 1, 2023
@atsansone
Copy link
Contributor

This has been documented. Closing this issue.

@atsansone atsansone added cl.fixed Issue is closed as fixed ltw-triage target.iOS Target apps on the iOS Platform p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. and removed P4 labels Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cl.fixed Issue is closed as fixed co.support Community ask for support dev.existing-apps Relates to integrating Flutter into existing apps from.flutter-sdk Reported via move from flutter/flutter p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. t.add-to-app Relates to adding Flutter components to native app t.framework Relates to Flutter framework target.iOS Target apps on the iOS Platform
Projects
None yet
Development

No branches or pull requests

8 participants