Skip to content

Unable to build iOS app after modifying pubspec.yaml and running flutter pub get #42956

Closed

Description

@gaaclarke

Error Message: 'Flutter/Flutter.h' file not found

Steps to reproduce:

  1. Create an add 2 app scenario
  2. Edit the module's pubspec.yaml to include a new asset
  3. Inside of the module run flutter build bundle
  4. Go back to your xcode project and build and run, notice that the Flutter headers are no longer able to be found.

You can fix this broken state by going back to your host app and running pod install.

It would be nice if we could automatically fix this erroneous state or communicate back to users that they need to run pod install again.

Activity

  1. added
    platform-iosiOS applications specifically
    a: existing-appsIntegration with existing apps via the add-to-app flow
    on Oct 17, 2019
  2. gaaclarke commented on Oct 17, 2019

    @gaaclarke
    MemberAuthor
  3. gaaclarke commented on Oct 17, 2019

    @gaaclarke
    MemberAuthor

    I've just verified that calling flutter build bundle from the commandline isn't necessary, just editing the pubspec.yaml is enough to create the problem.

    [   +7 ms] [✓] Flutter (Channel master, v1.10.15-pre.136, on Mac OS X 10.14.6 18G95, locale en-US)
    [        ]     • Flutter version 1.10.15-pre.136 at /Users/aaclarke/dev/flutter
    [        ]     • Framework revision 357d02c87b (2 days ago), 2019-10-15 15:33:55 -0700
    [        ]     • Engine revision 540fc977bb
    [        ]     • Dart version 2.6.0 (build 2.6.0-dev.7.0 70a7ef3f58)
    
  4. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Oct 17, 2019
  5. changed the title [-]XCode unable to build after running "build bundle" in module[/-] [+]Unable to build iOS app after modifying pubspec.yaml and running flutter pub get[/+] on Nov 5, 2019
  6. jmagman commented on Nov 5, 2019

    @jmagman
    Member

    flutter pub get seems to the be the command removing the directory .ios/Flutter/engine after pubspec.yaml is modified.

  7. jmagman commented on Nov 5, 2019

    @jmagman
    Member

    Simplified reproduction steps:

    $ flutter create -t module test_module_pubspec
    $ cd test_module_pubspec
    $ flutter build ios
    $ ls -la  .ios/Flutter/engine/
    total 8
    drwxr-xr-x   4 m  primarygroup  128 Nov  4 16:53 .
    drwxr-xr-x  10 m  primarygroup  320 Nov  4 16:53 ..
    drwxr-xr-x   8 m  primarygroup  256 Nov  4 16:53 Flutter.framework
    -rw-r--r--   1 m  primarygroup  758 Nov  4 16:53 Flutter.podspec
    $ open pubspec.yaml
    

    Increment version:

    $ flutter pub get
    $ ls -la  .ios/Flutter/engine/
    ls: .ios/Flutter/engine/: No such file or directory
    
  8. jmagman commented on Nov 5, 2019

    @jmagman
    Member

    When the pubspec changes, the ephemeral directory is deleted and re-created from the template:

    final bool toolingChanged = Cache.instance.isOlderThanToolsStamp(ephemeralDirectory);

  9. jmagman commented on Nov 5, 2019

    @jmagman
    Member

    That framework isn't present when the module is first created, either.

    Whenever the pubspec changes, this will reproduce. The workaround is to:

    1. Run flutter build ios in the module.
    2. Run pod install in the host.
  10. jonahwilliams commented on Dec 2, 2019

    @jonahwilliams
    Contributor

    The simple approach would be to repopulate the framework in .ios/Flutter/engine/ based on whatever existed there previously (perhaps by leaving a record of what mode before deleting it).

    However, these is still the fact that building the module project seems to depend on the last build command run. There should be a better way to do this, though it might require changes in how the module project is generated.

  11. jonahwilliams commented on Dec 2, 2019

    @jonahwilliams
    Contributor

    (I'm also not sure if that fixes having to run pod install)

  12. jmagman commented on Dec 2, 2019

    @jmagman
    Member

    However, these is still the fact that building the module project seems to depend on the last build command run. There should be a better way to do this, though it might require changes in how the module project is generated.

    The framework is only copied during pod install so the plugins have something to link against before xcode_backend script is run, which copies the version of the engine based on the Xcode run's $(CONFIGURATION) build setting (Debug, Profile, Release)
    https://github.com/flutter/flutter/blob/master/packages/flutter_tools/bin/xcode_backend.sh#L65

    So it shouldn't matter what the last build command was because the current configuration is what will be copied and embedded into the app.

  13. jonahwilliams commented on Dec 3, 2019

    @jonahwilliams
    Contributor

    So it shouldn't matter what the last build command was because the current configuration is what will be copied and embedded into the app.

    Good to know. In that case it sounds like we could always copy the debug framework when recreating the ephemeral directory and this would "just work"?

  14. jmagman commented on Dec 3, 2019

    @jmagman
    Member

    So it shouldn't matter what the last build command was because the current configuration is what will be copied and embedded into the app.

    Good to know. In that case it sounds like we could always copy the debug framework when recreating the ephemeral directory and this would "just work"?

    It should, see my PR at #37450. That test didn't pass though and I got distracted with the Xcode rename problem.

  15. github-actions commented on Aug 25, 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.

  16. locked as resolved and limited conversation to collaborators on Aug 25, 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 flowplatform-iosiOS applications specificallytoolAffects 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