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

feat: Add Flutter Target for ios app #239

Open
2 tasks
ysavr opened this issue Jan 3, 2025 · 3 comments
Open
2 tasks

feat: Add Flutter Target for ios app #239

ysavr opened this issue Jan 3, 2025 · 3 comments
Labels
feature A new feature or request

Comments

@ysavr
Copy link

ysavr commented Jan 3, 2025

Description

when I want to build flutter ios for example main_development.dart from xcode I have to change the path in FLUTTER_TARGET in Build Settings Xcode, how do I declare the path /Users/abstract/core_flutter/ through the brick.yaml prompt?

Requirements

  • All CI/CD checks are passing.
  • There is no drop in the test coverage percentage.

Additional Context

No response

@mrverdant13
Copy link

Hey, @ysavr 👋🏼

The FLUTTER_TARGET variable is automatically generated by the Flutter tool when the app is built (which means it is dynamically updated).
Its value can be found within some of the files contained in the ios/Flutter folder.

Since this value is managed by the Flutter tool, its manipulation is not expected.

Can you describe in which context are you facing this requirement?


As a side note, it may be helpful to be aware of the fact that the FLUTTER_TARGET variable is computed with the value provided with the --target CLI option when running or building your app.

@ysavr
Copy link
Author

ysavr commented Jan 6, 2025

Screenshot 2025-01-06 at 08 08 32

When building ios from xcode i need to define dart main entry for every environment on FLUTTER_TARGET how to make it automatically refer to dart main entry for every environment (e.g development, staging and production)

@mrverdant13
Copy link

Unfortunately, the way Flutter works for iOS does not allow devs to run a project directly from Xcode.

As I mentioned before, there are some variables that are generated by the Flutter tool.

One of those generated variables are the following (Generated.xcconfig file):

// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=<absolute path to the Flutter SDK>
FLUTTER_APPLICATION_PATH=<absolute path to your app>
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=<relative path to the Flutter entry point>
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=<build name defined in your pubspec.yaml>
FLUTTER_BUILD_NUMBER=<build number defined in your pubspec.yaml>
EXCLUDED_ARCHS[sdk=iphonesimulator*]=...
EXCLUDED_ARCHS[sdk=iphoneos*]=...
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.dart_tool/package_config.json

As you can see, several of them are computed and provided by the Flutter CLI and Flutter tool. And then they are imported in the other ~.xcconfig sibling files.

These values are generated when executing flutter pub get ... and flutter run/build ..., and each command result in quite different values.

You can test this out by your own:

  1. Run flutter pub get for your project.
  2. Open the ios/Flutter/Generated.xcconfig file, and you will see the FLUTTER_TARGET=lib/main.dart declaration.
  3. Run flutter bulid/run --target=<some other entry point>.
  4. Open the ios/Flutter/Generated.xcconfig file, and you will see the FLUTTER_TARGET=<the provided entry point> declaration.

Finally, you can enforce the definition of the FLUTTER_TARGET variable through Xcode, but that is just one single variable required for the Flutter project to build. If you run the project, you may encounter other unexpected results while launching or using the app.


What you can do, then, is to execute flutter pub get and flutter run/build ... before running your app through Xcode.
A cumbersome workaround, I know, but it is necessary. You SHOULD NOT override these values, as that may lead to undesired and hard-to-track results.

You can find more details in the source code for these generation steps: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/ios/xcode_build_settings.dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature or request
Projects
Status: Needs Triage
Development

No branches or pull requests

2 participants