Commit graph

499 commits

Author SHA1 Message Date
Victoria Ashworth 98685a099f
Replace CocoaPods deprecated exists? with exist? (#147056)
Fixes https://github.com/flutter/flutter/issues/147041.
2024-04-19 15:21:04 +00:00
Victoria Ashworth 6d19fa3bfa
Add Swift Package Manager as new opt-in feature for iOS and macOS (#146256)
This PR adds initial support for Swift Package Manager (SPM). Users must opt in. Only compatible with Xcode 15+.

Fixes https://github.com/flutter/flutter/issues/146369.

## Included Features

This PR includes the following features:
* Enabling SPM via config 
`flutter config --enable-swift-package-manager`
* Disabling SPM via config (will disable for all projects) 
`flutter config --no-enable-swift-package-manager`
* Disabling SPM via pubspec.yaml (will disable for the specific project)
```
flutter:
  disable-swift-package-manager: true
```
* Migrating existing apps to add SPM integration if using a Flutter plugin with a Package.swift
  * Generates a Swift Package (named `FlutterGeneratedPluginSwiftPackage`) that handles Flutter SPM-compatible plugin dependencies. Generated package is added to the Xcode project.
* Error parsing of common errors that may occur due to using CocoaPods and Swift Package Manager together
* Tool will print warnings when using all Swift Package plugins and encourage you to remove CocoaPods

This PR also converts `integration_test` and `integration_test_macos` plugins to be both Swift Packages and CocoaPod Pods.

## How it Works
The Flutter CLI will generate a Swift Package called `FlutterGeneratedPluginSwiftPackage`, which will have local dependencies on all Swift Package compatible Flutter plugins.  

The `FlutterGeneratedPluginSwiftPackage` package will be added to the Xcode project via altering of the `project.pbxproj`. 

In addition, a "Pre-action" script will be added via altering of the `Runner.xcscheme`. This script will invoke the flutter tool to copy the Flutter/FlutterMacOS framework to the `BUILT_PRODUCTS_DIR` directory before the build starts. This is needed because plugins need to be linked to the Flutter framework and fortunately Swift Package Manager automatically uses `BUILT_PRODUCTS_DIR` as a framework search path.

CocoaPods will continue to run and be used to support non-Swift Package compatible Flutter plugins.

## Not Included Features

It does not include the following (will be added in future PRs):
* Create plugin template
* Create app template
* Add-to-App integration
2024-04-18 21:12:36 +00:00
Victoria Ashworth 39a13539e0
Reland "Add FlutterMacOS.xcframework artifact (#143244)" (#144275)
Reland https://github.com/flutter/flutter/pull/143244. It was reverted due to https://github.com/flutter/flutter/issues/144251, which is fixed by https://github.com/flutter/engine/pull/51023.
2024-02-28 20:09:54 +00:00
auto-submit[bot] 7f2b238c55
Reverts "Add FlutterMacOS.xcframework artifact (#143244)" (#144253)
Reverts flutter/flutter#143244

Initiated by: vashworth

Reason for reverting: Increased `flutter_framework_uncompressed_bytes` - see https://github.com/flutter/flutter/issues/144251

Original PR Author: vashworth

Reviewed By: {jmagman}

This change reverts the following previous change:
Original Description:
Replace `FlutterMacOS.framework` cached artifact with `FlutterMacOS.xcframework`. Also, update usage of `FlutterMacOS.framework` to use `FlutterMacOS.xcframework`.

Part of https://github.com/flutter/flutter/issues/126016.
2024-02-27 20:47:26 +00:00
Victoria Ashworth 42252cd4c6
Add FlutterMacOS.xcframework artifact (#143244)
Replace `FlutterMacOS.framework` cached artifact with `FlutterMacOS.xcframework`. Also, update usage of `FlutterMacOS.framework` to use `FlutterMacOS.xcframework`.

Part of https://github.com/flutter/flutter/issues/126016.
2024-02-27 16:47:53 +00:00
Daco Harkes 4e70bfae2b
Reland "Move native assets to isolated/ directory" (#143055)
Reland of https://github.com/flutter/flutter/pull/142709.

The revert of the revert is in the first commit, the fix in the commit on top.

The move of the fakes for packages/flutter_tools/test/general.shard/resident_runner_test.dart was erroneous before, as it was trying to use setters instead of a private field. This PR changes the private `_devFS` field in the fake to be a public `fakeDevFS` in line with other fakes.

## Original PR description

Native assets in other build systems are not built with `package:native_assets_builder` invoking `build.dart` scripts. Instead all packages have their own blaze rules. Therefore we'd like to not depend on `package:native_assets_builder` from flutter tools in g3 at all.

This PR aims to move the imports of `native_assets_builder` and `native_assets_cli` into the `isolated/` directory and into the files with a `main` function that are not used in with other build systems.

In order to be able to remove all imports in files used by other build systems, two new interfaces are added `HotRunnerNativeAssetsBuilder` and `TestCompilerNativeAssetsBuilder`. New parameters are then piped all the way through from the entry points:

* bin/fuchsia_tester.dart
* lib/executable.dart

The build_system/targets dir is already excluded in other build systems.

So, after this PR only the two above files and build_system/targets import from `isolated/native_assets/` and only `isolated/native_assets/` import `package:native_assets_cli` and `package:native_assets_builder`.

Context:

* https://github.com/flutter/flutter/issues/142041
2024-02-08 17:49:48 +00:00
auto-submit[bot] ceca606662
Reverts "Move native assets to isolated/ directory" (#143027)
Reverts flutter/flutter#142709

Initiated by: vashworth

Reason for reverting: `Mac tool_tests_general` started failing on this commit: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20tool_tests_general/15552/overview

Original PR Author: dcharkes

Reviewed By: {christopherfujino, chingjun, reidbaker}

This change reverts the following previous change:
Original Description:
Native assets in other build systems are not built with `package:native_assets_builder` invoking `build.dart` scripts. Instead all packages have their own blaze rules. Therefore we'd like to not depend on `package:native_assets_builder` from flutter tools in g3 at all.

This PR aims to move the imports of `native_assets_builder` and `native_assets_cli` into the `isolated/` directory and into the files with a `main` function that are not used in with other build systems.

In order to be able to remove all imports in files used by other build systems, two new interfaces are added `HotRunnerNativeAssetsBuilder` and `TestCompilerNativeAssetsBuilder`. New parameters are then piped all the way through from the entry points:

* bin/fuchsia_tester.dart
* lib/executable.dart

The build_system/targets dir is already excluded in other build systems.

So, after this PR only the two above files and build_system/targets import from `isolated/native_assets/` and only `isolated/native_assets/` import `package:native_assets_cli` and `package:native_assets_builder`.

Context:

* https://github.com/flutter/flutter/issues/142041
2024-02-07 00:01:18 +00:00
Daco Harkes a069e62e8a
Move native assets to isolated/ directory (#142709)
Native assets in other build systems are not built with `package:native_assets_builder` invoking `build.dart` scripts. Instead all packages have their own blaze rules. Therefore we'd like to not depend on `package:native_assets_builder` from flutter tools in g3 at all.

This PR aims to move the imports of `native_assets_builder` and `native_assets_cli` into the `isolated/` directory and into the files with a `main` function that are not used in with other build systems.

In order to be able to remove all imports in files used by other build systems, two new interfaces are added `HotRunnerNativeAssetsBuilder` and `TestCompilerNativeAssetsBuilder`. New parameters are then piped all the way through from the entry points:

* bin/fuchsia_tester.dart
* lib/executable.dart

The build_system/targets dir is already excluded in other build systems.

So, after this PR only the two above files and build_system/targets import from `isolated/native_assets/` and only `isolated/native_assets/` import `package:native_assets_cli` and `package:native_assets_builder`.

Context:

* https://github.com/flutter/flutter/issues/142041
2024-02-06 20:59:49 +00:00
Pierrick Bouvier 37c3978b34
Enable native compilation for windows-arm64 (#141930)
It's now possible to natively compile a flutter app for windows-arm64. Cross-compilation is not yet implemented.

Uses arm64 artifacts now available for Dart/Flutter. Platform detection is based on Abi class, provided by Dart. Depending if Dart is an arm64 or x64 binary, the Abi is set accordingly. Initial bootstrap of dart artifacts (update_dart_sdk.ps1) is checking PROCESSOR_ARCHITECTURE environment variable, which is the way to detect host architecture on Windows.

This is available only for master channel (on other channels, it fallbacks to windows-x64).

On windows-x64, it produces an x64 app. On windows-arm64, it produces an arm64 app.
2024-01-26 00:08:20 +00:00
Andrew Kolos cbe0ceafe2
consolidate AssetBundle::entries and AssetBundle::entryKinds into a new type, AssetBundleEntry (#142029)
Part of work on https://github.com/flutter/flutter/pull/141194

The [`AssetBundle`](0833929c99/packages/flutter_tools/lib/src/asset.dart (L80)) class contains two members, `entries` and `entryKinds`. `entries` contains asset data indexed by asset key. `entryKinds` contains the "kinds" of these assets, again indexed by asset key.

**Change.** Rather than have two separate maps, this PR proposes combining these maps into one by wrapping the asset data and kind into a single data type `AssetBundleEntry`.

**Purpose.** In https://github.com/flutter/flutter/pull/141194, I am considering associating more information with an asset. In particular, what transformers are meant to be applied to it when copying it to the build output. Rather than adding another map member onto `AssetBundle` (e.g. `entryTransformers`), I decided to make things neater by introducing the `AssetBundleEntry` type.
2024-01-23 22:00:46 +00:00
auto-submit[bot] 1901d6fa10
Reverts "Enable native compilation for windows-arm64 " (#141809)
Reverts flutter/flutter#137618
Initiated by: Jasguerrero
This change reverts the following previous change:
Original Description:
It's now possible to natively compile a flutter app for
windows-arm64. Cross-compilation is not yet implemented.

Uses arm64 artifacts now available for Dart/Flutter.
Platform detection is based on Abi class, provided by Dart. Depending if
Dart is an arm64 or x64 binary, the Abi is set accordingly.
Initial bootstrap of dart artifacts (update_dart_sdk.ps1) is checking
PROCESSOR_ARCHITECTURE environment variable, which is the way to detect
host architecture on Windows.

This is available only for master channel (on other channels, it
fallbacks to windows-x64).

On windows-x64, it produces an x64 app. On windows-arm64, it produces an
arm64 app.
2024-01-18 22:48:16 +00:00
Pierrick Bouvier 540559204e
Enable native compilation for windows-arm64 (#137618)
It's now possible to natively compile a flutter app for
windows-arm64. Cross-compilation is not yet implemented.

Uses arm64 artifacts now available for Dart/Flutter.
Platform detection is based on Abi class, provided by Dart. Depending if
Dart is an arm64 or x64 binary, the Abi is set accordingly.
Initial bootstrap of dart artifacts (update_dart_sdk.ps1) is checking
PROCESSOR_ARCHITECTURE environment variable, which is the way to detect
host architecture on Windows.

This is available only for master channel (on other channels, it
fallbacks to windows-x64).

On windows-x64, it produces an x64 app. On windows-arm64, it produces an
arm64 app.
2024-01-18 19:15:23 +00:00
Spt 3d112429cc
Solve the problem that <Flutter/Flutter.h> cannot be imported when a pod transitive depends on Flutter (#125610)
![image](https://user-images.githubusercontent.com/8318578/234780282-89b18d27-df49-4b4e-88b5-c9d17cf3334f.png)
![image](https://user-images.githubusercontent.com/8318578/234780668-901ab816-5b6b-4d87-a6f4-120b5852580c.png)
If a pod transitive depends on a pod containing a framework, cocoapods will add the path of the framework to its FRAMEWORK_SEARCH_PATHS.
So I modified the relevant logic in podhelper, hoping to be consistent with the behavior of cocoapods.

Fixes https://github.com/flutter/flutter/issues/126251.
2024-01-16 15:36:38 +00:00
stuartmorgan 32fd2cbf73
Replace deprecated exists in podhelper.rb (#141169)
The recently landed https://github.com/flutter/flutter/pull/140222 accidentally used the deprecated `exists?` instead of the non-deprecated `exist?` (which other code in this file is already, correctly, using).

Fixes https://github.com/flutter/flutter/issues/141167
2024-01-09 22:25:57 +00:00
stuartmorgan 24e06232a7
Fix local engine use in macOS plugins (#140222)
Currently podhelper.rb will always point plugin builds at the cached engine artifacts, even when using `--local-engine`. In most cases this is fine, since when the final build actually runs it will be using the engine bundled into the app build, which will be the correct local engine build. When trying to test a local engine build with API additions against a local plugin modified to use those additions to ensure that they are working as expected, however, compilation will fail, because the new APIs won't be present in the plugin build.

This fixes that for macOS, and adds a TODO for iOS (which is more complicated to fix due to the host vs target build distinction).

macOS portion of https://github.com/flutter/flutter/issues/132228
2024-01-04 15:40:08 +00:00
Jenn Magder b08fc60024
Set template and migrate apps to iOS 12 minimum (#140823)
Reland https://github.com/flutter/flutter/pull/140478 with `ios_content_validation_test` test fix.
```
[ios_content_validation_test] Process terminated with exit code 0.
Task result:
{
  "success": true,
  "data": null,
  "detailFiles": [],
  "benchmarkScoreKeys": [],
  "reason": "success"
}

```

__________

1. Change templates to `IPHONEOS_DEPLOYMENT_TARGET`, `MinimumOSVersion`, and Podfile `platform :ios` to 12.0.
2. Add migrator for Podfile part to migrate `platform :ios, '11.0'` -> `platform :ios, '12.0'`
3. Compile with `-miphoneos-version-min=12.0`
4. Run the migrator on all example apps and integration tests.

See also https://github.com/flutter/flutter/pull/62902 and https://github.com/flutter/flutter/pull/85174 and https://github.com/flutter/flutter/pull/101963

Fixes https://github.com/flutter/flutter/issues/136060
2024-01-03 00:47:40 +00:00
auto-submit[bot] bd634f3298
Reverts "Set template and migrate apps to iOS 12 minimum" (#140822)
Reverts flutter/flutter#140478
Initiated by: loic-sharma
This change reverts the following previous change:
Original Description:
1. Change templates to `IPHONEOS_DEPLOYMENT_TARGET`, `MinimumOSVersion`, and Podfile `platform :ios` to 12.0.
2. Add migrator for Podfile part to migrate `platform :ios, '11.0'` -> `platform :ios, '12.0'`
3. Compile with `-miphoneos-version-min=12.0`
4. Run the migrator on all example apps and integration tests.

See also https://github.com/flutter/flutter/pull/62902 and https://github.com/flutter/flutter/pull/85174 and https://github.com/flutter/flutter/pull/101963

Fixes https://github.com/flutter/flutter/issues/136060
2024-01-02 20:49:19 +00:00
Jenn Magder acdbcadb9e
Set template and migrate apps to iOS 12 minimum (#140478)
1. Change templates to `IPHONEOS_DEPLOYMENT_TARGET`, `MinimumOSVersion`, and Podfile `platform :ios` to 12.0.
2. Add migrator for Podfile part to migrate `platform :ios, '11.0'` -> `platform :ios, '12.0'`
3. Compile with `-miphoneos-version-min=12.0`
4. Run the migrator on all example apps and integration tests.

See also https://github.com/flutter/flutter/pull/62902 and https://github.com/flutter/flutter/pull/85174 and https://github.com/flutter/flutter/pull/101963

Fixes https://github.com/flutter/flutter/issues/136060
2024-01-02 19:42:13 +00:00
Andrew Kolos 9e104eb7c8
Fix flavor conditional asset bundling for macos (#140433)
Fixes https://github.com/flutter/flutter/issues/140430
Fixes https://github.com/flutter/flutter/issues/140432 while we are at it
2023-12-21 20:30:21 +00:00
Andrew Kolos 935775cb74
[reland] Support conditional bundling of assets based on --flavor (#139834)
Reland of https://github.com/flutter/flutter/pull/132985. Fixes the path to AssetManifest.bin in flavors_test_ios
2023-12-14 05:30:10 +00:00
auto-submit[bot] 21766a4f9f
Reverts "Support conditional bundling of assets based on --flavor" (#139787)
Reverts flutter/flutter#132985
Initiated by: christopherfujino
This change reverts the following previous change:
Original Description:
Provides support for conditional bundling of assets through the existing `--flavor` option for `flutter build` and `flutter run`. Closes https://github.com/flutter/flutter/issues/21682. Resolves https://github.com/flutter/flutter/issues/136092

## Change
Within the `assets` section pubspec.yaml, the user can now specify one or more `flavors` that an asset belongs to. Consider this example:

```yaml
# pubspec.yaml
flutter:
  assets:
    - assets/normal-asset.png
    - path: assets/vanilla/ice-cream.png
      flavors: 
        - vanilla
    - path: assets/strawberry/ice-cream.png
      flavors:
        - strawberry
```

With this pubspec,
* `flutter run --flavor vanilla` will not include `assets/strawberry/ice-cream.png` in the build output.
* `flutter run --flavor strawberry` will not include `assets/vanilla/ice-cream.png`.
* `flutter run` will only include `assets/normal-asset.png`.

## Open questions

* Should this be supported for all platforms, or should this change be limited to ones with documented `--flavor` support (Android, iOS, and (implicitly) MacOS)? This PR currently only enables this feature for officially supported platforms.

## Design thoughts, what this PR does not do, etc.

### This does not provide an automatic mapping/resolution of asset keys/paths to others based on flavor at runtime.

The implementation in this PR represents a simplest approach. Notably, it does not give Flutter the ability to dynamically choose an asset based on flavor using a single asset key. For example, one can't use `Image.asset('config.json')` to dynamically choose between different "flavors" of `config.json` (such as `dev-flavor/config.json` or `prod-flavor/config.json`). However, a user could always implement such a mechanism in their project or in a library by examining the flavor at runtime.

### When multiple entries affect the same file and 1) at least one of these entries have a `flavors` list provided and 2) these lists are not equivalent, we always consider the manifest to be ambiguous and will throw a `ToolExit`. 

<details>
For example, these manifests would all be considered ambiguous:

```yaml
assets:
  - assets/
  - path: assets/vanilla.png
    flavors: 
      - vanilla

assets:
  - path: assets/vanilla/
    flavors: 
      - vanilla
  - path: assets/vanilla/cherry.png
     flavor:
      - cherry

# Thinking towards the future where we might add glob/regex support and more conditions other than flavor:
assets:
  - path: assets/vanilla/**
    flavors:
      - vanilla
  - path: assets/**/ios/**
    platforms: 
       - ios

# Ambiguous in the case of assets like "assets/vanilla/ios/icon.svg" since we 
# don't know if flavor `vanilla` and platform `ios` should be combined using or-logic or and-logic.
```

See [this review comment thread](https://github.com/flutter/flutter/pull/132985#discussion_r1381909942) for the full story on how I arrived at this decision.
</details>

### This does not support Android's multidimensional flavors feature (in an intuitive way)

<details>

Conder this excerpt from a Flutter project's android/app/build.gradle file:

```groovy
android {
    // ...

    flavorDimensions "mode", "api"

    productFlavors {
        free {
            dimension "mode"
            applicationIdSuffix ".free"
        }

        premium {
            dimension "mode"
            applicationIdSuffix ".premium"
        }

        minApi23 {
            dimension "api"
            versionNameSuffix "-minApi23"
        }

        minApi21 {
            dimension "api"
            versionNameSuffix "-minApi21"
        }
    }
}
```

In this setup, the following values are valid `--flavor` are valid `freeMinApi21`, `freeMinApi23`, `premiumMinApi21`, and `premiumMinApi23`. We call these values "flavor combinations". Consider the following from the Android documentation[^1]:

> In addition to the source set directories you can create for each individual product flavor and build variant, you can also create source set directories for each combination of product flavors. For example, you can create and add Java sources to the src/demoMinApi24/java/ directory, and Gradle uses those sources only when building a variant that combines those two product flavors.
> 
> Source sets you create for product flavor combinations have a higher priority than source sets that belong to each individual product flavor. To learn more about source sets and how Gradle merges resources, read the section about how to [create source sets](https://developer.android.com/build/build-variants#sourcesets).

This feature will not behave in this way. If a user utilizes this feature and also Android's multidimensional flavors feature, they will have to list out all flavor combinations that contain the flavor they want to limit an asset to:

```yaml
assets:
  - assets/free/
    flavors:
      - freeMinApi21
      - freeMinApi23
```

This is mostly due to a technical limitation in the hot-reload feature of `flutter run`. During a hot reload, the tool will try to update the asset bundle on the device, but the tool does not know the flavors contained within the flavor combination (that the user passes to `--flavor`). Gradle is the source of truth of what flavors were involved in the build, and `flutter run` currently does not access to that information since it's an implementation detail of the build process. We could bubble up this information, but it would require a nontrivial amount of engineering work, and it's unclear how desired this functionality is. It might not be worth implementing.

</details>

See https://flutter.dev/go/flavor-specific-assets for the (outdated) design document. 

<summary>Pre-launch Checklist</summary>

</details>

[^1]: https://developer.android.com/build/build-variants#flavor-dimensions
2023-12-08 06:40:28 +00:00
Andrew Kolos 016eb85177
Support conditional bundling of assets based on --flavor (#132985)
Provides support for conditional bundling of assets through the existing `--flavor` option for `flutter build` and `flutter run`. Closes https://github.com/flutter/flutter/issues/21682. Resolves https://github.com/flutter/flutter/issues/136092

## Change
Within the `assets` section pubspec.yaml, the user can now specify one or more `flavors` that an asset belongs to. Consider this example:

```yaml
# pubspec.yaml
flutter:
  assets:
    - assets/normal-asset.png
    - path: assets/vanilla/ice-cream.png
      flavors: 
        - vanilla
    - path: assets/strawberry/ice-cream.png
      flavors:
        - strawberry
```

With this pubspec,
* `flutter run --flavor vanilla` will not include `assets/strawberry/ice-cream.png` in the build output.
* `flutter run --flavor strawberry` will not include `assets/vanilla/ice-cream.png`.
* `flutter run` will only include `assets/normal-asset.png`.

## Open questions

* Should this be supported for all platforms, or should this change be limited to ones with documented `--flavor` support (Android, iOS, and (implicitly) MacOS)? This PR currently only enables this feature for officially supported platforms.

## Design thoughts, what this PR does not do, etc.

### This does not provide an automatic mapping/resolution of asset keys/paths to others based on flavor at runtime.

The implementation in this PR represents a simplest approach. Notably, it does not give Flutter the ability to dynamically choose an asset based on flavor using a single asset key. For example, one can't use `Image.asset('config.json')` to dynamically choose between different "flavors" of `config.json` (such as `dev-flavor/config.json` or `prod-flavor/config.json`). However, a user could always implement such a mechanism in their project or in a library by examining the flavor at runtime.

### When multiple entries affect the same file and 1) at least one of these entries have a `flavors` list provided and 2) these lists are not equivalent, we always consider the manifest to be ambiguous and will throw a `ToolExit`. 

<details>
For example, these manifests would all be considered ambiguous:

```yaml
assets:
  - assets/
  - path: assets/vanilla.png
    flavors: 
      - vanilla

assets:
  - path: assets/vanilla/
    flavors: 
      - vanilla
  - path: assets/vanilla/cherry.png
     flavor:
      - cherry

# Thinking towards the future where we might add glob/regex support and more conditions other than flavor:
assets:
  - path: assets/vanilla/**
    flavors:
      - vanilla
  - path: assets/**/ios/**
    platforms: 
       - ios

# Ambiguous in the case of assets like "assets/vanilla/ios/icon.svg" since we 
# don't know if flavor `vanilla` and platform `ios` should be combined using or-logic or and-logic.
```

See [this review comment thread](https://github.com/flutter/flutter/pull/132985#discussion_r1381909942) for the full story on how I arrived at this decision.
</details>

### This does not support Android's multidimensional flavors feature (in an intuitive way)

<details>

Conder this excerpt from a Flutter project's android/app/build.gradle file:

```groovy
android {
    // ...

    flavorDimensions "mode", "api"

    productFlavors {
        free {
            dimension "mode"
            applicationIdSuffix ".free"
        }

        premium {
            dimension "mode"
            applicationIdSuffix ".premium"
        }

        minApi23 {
            dimension "api"
            versionNameSuffix "-minApi23"
        }

        minApi21 {
            dimension "api"
            versionNameSuffix "-minApi21"
        }
    }
}
```

In this setup, the following values are valid `--flavor` are valid `freeMinApi21`, `freeMinApi23`, `premiumMinApi21`, and `premiumMinApi23`. We call these values "flavor combinations". Consider the following from the Android documentation[^1]:

> In addition to the source set directories you can create for each individual product flavor and build variant, you can also create source set directories for each combination of product flavors. For example, you can create and add Java sources to the src/demoMinApi24/java/ directory, and Gradle uses those sources only when building a variant that combines those two product flavors.
> 
> Source sets you create for product flavor combinations have a higher priority than source sets that belong to each individual product flavor. To learn more about source sets and how Gradle merges resources, read the section about how to [create source sets](https://developer.android.com/build/build-variants#sourcesets).

This feature will not behave in this way. If a user utilizes this feature and also Android's multidimensional flavors feature, they will have to list out all flavor combinations that contain the flavor they want to limit an asset to:

```yaml
assets:
  - assets/free/
    flavors:
      - freeMinApi21
      - freeMinApi23
```

This is mostly due to a technical limitation in the hot-reload feature of `flutter run`. During a hot reload, the tool will try to update the asset bundle on the device, but the tool does not know the flavors contained within the flavor combination (that the user passes to `--flavor`). Gradle is the source of truth of what flavors were involved in the build, and `flutter run` currently does not access to that information since it's an implementation detail of the build process. We could bubble up this information, but it would require a nontrivial amount of engineering work, and it's unclear how desired this functionality is. It might not be worth implementing.

</details>

See https://flutter.dev/go/flavor-specific-assets for the (outdated) design document. 

<summary>Pre-launch Checklist</summary>

</details>

[^1]: https://developer.android.com/build/build-variants#flavor-dimensions
2023-12-07 23:50:00 +00:00
Victoria Ashworth 3c3d414e7c
[Reland] Skip injecting Bonjour settings when port publication is disabled (#136842)
Reland https://github.com/flutter/flutter/pull/136751 with fixes.
2023-10-19 17:38:52 +00:00
auto-submit[bot] c32ffa65c9
Reverts "[Reland] Skip injecting Bonjour settings when port publication is disabled" (#136839)
Reverts flutter/flutter#136751
Initiated by: vashworth
This change reverts the following previous change:
Original Description:
Reland of https://github.com/flutter/flutter/pull/136562 with fixes.
2023-10-18 20:33:17 +00:00
Victoria Ashworth 1599cbebc3
[Reland] Skip injecting Bonjour settings when port publication is disabled (#136751)
Reland of https://github.com/flutter/flutter/pull/136562 with fixes.
2023-10-18 20:08:19 +00:00
auto-submit[bot] 54c0a350dd
Reverts "Skip injecting Bonjour settings when port publication is disabled" (#136750)
Reverts flutter/flutter#136562
Initiated by: vashworth
This change reverts the following previous change:
Original Description:
Some of our tests in CI are triggering the `NSLocalNetworkUsageDescription` dialog when they're not supposed to (https://github.com/flutter/flutter/issues/129836) since it's disabled via flags (`--no-publish-port` for flutter/flutter and `--disable-vm-service-publication` for flutter/engine).

Normally, we inject `NSLocalNetworkUsageDescription` (and other bonjour settings) to the Info.plist during the project build for debug and profile mode since by default they will publish the VM Service port over mDNS.

To help diagnose the issue, though, this PR changes it so that we don't inject `NSLocalNetworkUsageDescription` (and other bonjour settings) when port publication is disabled since it shouldn't be needed. Hopefully, this will give us better error messages or cause the app to crash and end the test early (rather than timeout after 30 minutes).
2023-10-17 19:27:19 +00:00
Victoria Ashworth 0383d8ba9e
Skip injecting Bonjour settings when port publication is disabled (#136562)
Some of our tests in CI are triggering the `NSLocalNetworkUsageDescription` dialog when they're not supposed to (https://github.com/flutter/flutter/issues/129836) since it's disabled via flags (`--no-publish-port` for flutter/flutter and `--disable-vm-service-publication` for flutter/engine).

Normally, we inject `NSLocalNetworkUsageDescription` (and other bonjour settings) to the Info.plist during the project build for debug and profile mode since by default they will publish the VM Service port over mDNS.

To help diagnose the issue, though, this PR changes it so that we don't inject `NSLocalNetworkUsageDescription` (and other bonjour settings) when port publication is disabled since it shouldn't be needed. Hopefully, this will give us better error messages or cause the app to crash and end the test early (rather than timeout after 30 minutes).
2023-10-17 19:09:08 +00:00
Victoria Ashworth 3cfe3720d6
Wait for CONFIGURATION_BUILD_DIR to update when debugging with Xcode (#135444)
So there appears to be a race situation between the flutter CLI and Xcode. In the CLI, we update the `CONFIGURATION_BUILD_DIR` in the Xcode build settings and then tell Xcode to install, launch, and debug the app. When Xcode installs the app, it should use the `CONFIGURATION_BUILD_DIR` to find the bundle. However, it appears that sometimes Xcode hasn't processed the change to the build settings before the install happens, which causes it to not be able to find the bundle.

Fixes https://github.com/flutter/flutter/issues/135442

--- 

Since it's a timing issue, there's not really a consistent way to test it.

I was able to confirm that it works, though, by using the following steps:
1. Create a flutter project
2. Open the project in Xcode
3. `flutter clean`
4. `flutter run --profile -v`

If I saw a print line `stderr: CONFIGURATION_BUILD_DIR: build/Debug-iphoneos`, that means it first found the old and incorrect `CONFIGURATION_BUILD_DIR` before updating to the the new, so I was able to confirm that it would wait until it updated.
2023-09-26 17:48:19 +00:00
Derek Xu c627dbfbc6
Add --frontend-server-starter-path option to flutter run and flutter test (#135038) 2023-09-21 14:32:35 -04:00
Daco Harkes aa36db1d29
Native assets support for MacOS and iOS (#130494)
Support for FFI calls with `@Native external` functions through Native assets on MacOS and iOS. This enables bundling native code without any build-system boilerplate code.

For more info see:

* https://github.com/flutter/flutter/issues/129757

### Implementation details for MacOS and iOS.

Dylibs are bundled by (1) making them fat binaries if multiple architectures are targeted, (2) code signing these, and (3) copying them to the frameworks folder. These steps are done manual rather than via CocoaPods. CocoaPods would have done the same steps, but (a) needs the dylibs to be there before the `xcodebuild` invocation (we could trick it, by having a minimal dylib in the place and replace it during the build process, that works), and (b) can't deal with having no dylibs to be bundled (we'd have to bundle a dummy dylib or include some dummy C code in the build file).

The dylibs are build as a new target inside flutter assemble, as that is the moment we know what build-mode and architecture to target.

The mapping from asset id to dylib-path is passed in to every kernel compilation path. The interesting case is hot-restart where the initial kernel file is compiled by the "inner" flutter assemble, while after hot restart the "outer" flutter run compiled kernel file is pushed to the device. Both kernel files need to contain the mapping. The "inner" flutter assemble gets its mapping from the NativeAssets target which builds the native assets. The "outer" flutter run get its mapping from a dry-run invocation. Since this hot restart can be used for multiple target devices (`flutter run -d all`) it contains the mapping for all known targets.

### Example vs template

The PR includes a new template that uses the new native assets in a package and has an app importing that. Separate discussion in: https://github.com/flutter/flutter/issues/131209.

### Tests

This PR adds new tests to cover the various use cases.

* dev/devicelab/bin/tasks/native_assets_ios.dart
  * Runs an example app with native assets in all build modes, doing hot reload and hot restart in debug mode.
* dev/devicelab/bin/tasks/native_assets_ios_simulator.dart
  * Runs an example app with native assets, doing hot reload and hot restart.
* packages/flutter_tools/test/integration.shard/native_assets_test.dart
  * Runs (incl hot reload/hot restart), builds, builds frameworks for iOS, MacOS and flutter-tester.
* packages/flutter_tools/test/general.shard/build_system/targets/native_assets_test.dart
  * Unit tests the new Target in the backend.
* packages/flutter_tools/test/general.shard/ios/native_assets_test.dart
* packages/flutter_tools/test/general.shard/macos/native_assets_test.dart
  * Unit tests the native assets being packaged on a iOS/MacOS build.

It also extends various existing tests:

* dev/devicelab/bin/tasks/module_test_ios.dart
   * Exercises the add2app scenario.
* packages/flutter_tools/test/general.shard/features_test.dart
   * Unit test the new feature flag.
2023-09-10 08:07:13 +00:00
Mustafa Ateş Uzun 6875827f46
doc: add flag params (#132485)
*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*

*List which issues are fixed by this PR. You must list at least one issue.*

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
2023-08-18 17:48:05 +00:00
Matan Lurey b4d5c8f425
Update flutter_tools/bin/*.(dart|sh) to provide, if set, --local-engine-host. (#132336)
Partial work towards https://github.com/flutter/flutter/issues/132245.

Other than updating error messages, and passing `$LOCAL_ENGINE_HOST`
downwards, this PR should not change the behavior of any existing
workflows or code (i.e. it's purely additive).
2023-08-10 15:25:57 -07:00
Victoria Ashworth d631b26285
New tooling for iOS 17 physical devices (#131865)
This PR includes the following changes. These changes only apply to iOS 17 physical devices.

| Command | Change Description  | Changes to User Experience |
| ------------- | ------------- | ------------- |
| `flutter run --release` | Uses `devicectl` to install and launch application in release mode.  | No change.  |
| `flutter run`  | Uses Xcode via automation scripting to run application in debug and profile mode. | Xcode will be opened in the background. Errors/crashes may be caught in Xcode and therefore may not show in terminal. |
| `flutter run --use-application-binary=xxxx` | Creates temporary empty Xcode project and use Xcode to run via automation scripting in debug and profile. | Xcode will be opened in the background. Errors/crashes may be caught in Xcode and therefore may not show in terminal.  |
| `flutter install` | Uses `devicectl` to check installed apps, install app, uninstall app.  | No change.  |
| `flutter screenshot` | Will return error.  | Will return error.  |

Other changes include:
* Using `devicectl` to get information about the device
* Using `idevicesyslog` and Dart VM logging for device logs

Note:
Xcode automation scripting (used in `flutter run` for debug and profile) does not work in a headless (without a UI) interface. No known workaround.

Fixes https://github.com/flutter/flutter/issues/128827, https://github.com/flutter/flutter/issues/128531.
2023-08-09 19:25:12 +00:00
Michael Goderbauer 55b6f049a6
Enable unreachable_from_main lint - it is stable now!!1 (#129854)
PLUS: clean-up of all the unreachable stuff.
2023-07-06 00:09:01 +00:00
Jenn Magder c60f202308
Force plugin transitive dependencies to an ARC compatible version (#124349)
Force plugin transitive dependencies to an ARC compatible version
2023-04-07 18:07:23 +00:00
Michael Goderbauer fda9ecfef7
Remove 1745 decorative breaks (#123259)
Remove 1745 decorative breaks
2023-03-22 21:12:22 +00:00
Ben Konyi ecd7518df5
Reland "Remove references to Observatory (#118577)" (#121606)
This reverts commit 275ab9c69b.
2023-02-28 11:57:04 -05:00
Michael Goderbauer 275ab9c69b
Revert "Reland "Remove references to Observatory (#118577)" (#121215)" (#121555)
Revert "Reland "Remove references to Observatory (#118577)""
2023-02-27 23:46:53 +00:00
Danny Tuppeny 06952ba254
[flutter_tools] Add support for URI formats like ?line=x for "flutter test" (#119740)
* [flutter_tools] Add support for URI formats like ?line=x for "flutter test"

* Remove unnecessary function

* Handle parsing absolute paths on Windows

* Use Windows-style paths when running on Windows

* Fix paths in isFile

* Remove unnecessary clear
2023-02-27 19:13:00 +00:00
Ben Konyi fbae472fc3
Reland "Remove references to Observatory (#118577)" (#121215)
This reverts commit 298d8c76ba.
2023-02-27 09:26:43 -05:00
Ian Hickson 6205c110d6
Remove "note that" in our documentation (as per style guide) (#120842)
* lerp documentation

* Remove Note, Note That from repo

* Improve BorderSide documentation.

* apply review comments
2023-02-17 22:27:33 +00:00
Casey Hillers 298d8c76ba
Revert "Remove references to Observatory (#118577)" (#120929)
This reverts commit 2df140f40d.
2023-02-16 21:28:30 -08:00
Ben Konyi 2df140f40d
Remove references to Observatory (#118577)
Observatory is being deprecated for Dart 3.0 so it should no longer be
referenced in tooling messaging / flags.

See https://github.com/dart-lang/sdk/issues/50233
2023-02-13 14:29:30 -05:00
Chris Bracken d272a3ab80
Reland: [macos] add flavor options to tool commands (#119564)
* Reland: [macos] add flavor options to tool commands

Adds --flavor option to flutter run and flutter build. Running against
preexisting devicelab flavor tests for feature parity between macOS,
iOS, and Android.

This relands #118421 by alex-wallen which was reverted in #118858 due to
the following test failures:

The bail-out with "Host and target are the same. Nothing to install."
added in `packages/flutter_tools/lib/src/commands/install.dart`
triggered failures in the following tests, which unconditionally attempt
to install the built app, which is unsupported on desktop since the
host and target are the same:

* https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8791495589540422465/+/u/run_flutter_view_macos__start_up/test_stdout
* https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8791496218824259121/+/u/run_complex_layout_win_desktop__start_up/test_stdout
* https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8791496218165602641/+/u/run_flutter_gallery_win_desktop__start_up/test_stdout

Fixes #64088

* Partial revert: eliminate install check on desktop

The original flavour support patch included a check that triggered a
failure when flutter install is run on desktop OSes. This was
intentional, since the host and target devices are the same and
installation is unnecessary to launch the app on currently-supported
desktop OSes.

Note that Windows UWP apps *do* require installation to run, and we used
to have an install command for those apps, though UWP is no longer
supported.

Since that part of the change was orthogonal to flavour support itself,
I'm reverting that component of the change and we can deal with it
separately if so desired.
2023-01-31 17:37:46 +00:00
Jenn Magder 030288d33b
Revert "[macos] add flavor options to commands in the flutter_tool (#118421)" (#118858)
This reverts commit 73096fd96e.
2023-01-20 03:46:45 +00:00
Alex Wallen 73096fd96e
[macos] add flavor options to commands in the flutter_tool (#118421)
* Add new macos target configured for flavors

* Rename Free App copy-Info.plist to Free App Info.plist

* Remove bogus entitlements

* Remove Generated.xcconfig

* Audit project.pbxproj

* Remove unused configs

* share one info.plist

* Modify scheme so that paid app works

* Codesign automatic

* Pipe flavor as scheme into xcodebuild

* Ignore incoming flavor string

* pipe flavor for flutter run to work

* Add devicelab tests

* Error if host and target device are same for flutter install desktop

* Avoid bang (!) by promoting a local.

Co-authored-by: Jenn Magder <magder@google.com>

* Add supportsInstall property

* Override  in test classes

* Add install test on macOS

* Refactor application_package and add tests for package directory

Co-authored-by: a-wallen <stephenwallen@google.com>
Co-authored-by: Jenn Magder <magder@google.com>
2023-01-19 23:52:16 +00:00
Jenn Magder eaaacdcba9
Allow iOS and macOS plugins to share darwin directory (#115337) 2023-01-09 10:33:03 -08:00
Chris Bracken 3c9288c6d3
Increase minimum supported macOS version from 10.13 to 10.14 (#114713)
Increases the minimum macOS deployment target from macOS 10.13 (High Sierra) to 10.14 (Mojave) in the macOS app templates.

Includes:
* Update migration for macOS 10.11 apps to upgrade to 10.14
* Adds migration for macOS 10.13 apps to upgrade to 10.14
* Apply migration to all examples, and integration tests

This does not increase version in the plugin templates since those will need to wait until the 10.14 framework rolls to stable channel, so new plugins can build with apps created with `flutter create` on stable channel.

Issue: https://github.com/flutter/flutter/issues/114445
See RFC: http://flutter.dev/go/flutter-drop-macOS-10.13-2022-q4
See previous patch: https://github.com/flutter/flutter/pull/107689
2022-11-07 11:32:42 +01:00
Jenn Magder f059dd40ea
Show Xcode compilation errors at end of build, suppress stdout and stderr from Xcode (#113302) 2022-10-17 17:47:25 +00:00
Jenn Magder 35afe1bdac
Stop embedding bitcode for iOS in tool (#112831) 2022-10-04 01:41:23 +00:00