I'm working on a flutter app, as part of a team, and we recently decided to add Share Extension to our app to allow iOS users to share media from outside the app.
After adding the Share Extension, I was able to compile the app and run it. But sometime after that (switching to different git branches) I started getting this error persistently:
Writing result bundle at path:
/var/folders/m4/2cb6zdx138q5z5x0ljnvmygm0000gn/T/flutter_tools.VWykU0/flutter_ios_build_temp_dirylPO5Z/temporary_xcresult_bundle
/Users/jyotiproy/IdeaProjects/krew_app/ios/Runner/Runner-Bridging-Header.h:1:9: note: in file included from /Users/jyotiproy/IdeaProjects/krew_app/ios/Runner/Runner-Bridging-Header.h:1:
#import "GeneratedPluginRegistrant.h"
^
/Users/jyotiproy/IdeaProjects/krew_app/ios/Runner/GeneratedPluginRegistrant.h:10:9: error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
^
1 error generated.
<unknown>:0: error: failed to emit precompiled header '/Users/jyotiproy/Library/Developer/Xcode/DerivedData/Runner-bgkxbehdnpdmkjfwhnujcqssvqjc/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_2R9KITIRJQAWU-clang_13QX7MSDXGS1W.pch' for bridging header '/Users/jyotiproy/IdeaProjects/krew_app/ios/Runner/Runner-Bridging-Header.h'
/Users/jyotiproy/IdeaProjects/krew_app/ios/Runner/Runner-Bridging-Header.h:1:9: note: in file included from /Users/jyotiproy/IdeaProjects/krew_app/ios/Runner/Runner-Bridging-Header.h:1:
#import "GeneratedPluginRegistrant.h"
^
2 errors generated.
error: generate-pch command failed with exit code 1 (use -v to see invocation)
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
/Users/jyotiproy/IdeaProjects/krew_app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.4.99. (in target 'TOCropViewController' from project 'Pods')
/Users/jyotiproy/IdeaProjects/krew_app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.4.99. (in target 'Reachability' from project 'Pods')
/Users/jyotiproy/IdeaProjects/krew_app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.4.99. (in target 'OrderedSet' from project 'Pods')
/Users/jyotiproy/IdeaProjects/krew_app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.4.99. (in target 'FMDB' from project 'Pods')
/Users/jyotiproy/IdeaProjects/krew_app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.4.99. (in target 'TOCropViewController-TOCropViewControllerBundle' from project 'Pods')
Result bundle written to path:
/var/folders/m4/2cb6zdx138q5z5x0ljnvmygm0000gn/T/flutter_tools.VWykU0/flutter_ios_build_temp_dirylPO5Z/temporary_xcresult_bundle
Could not build the precompiled application for the device.
Error (Xcode): 'Flutter/Flutter.h' file not found
/Users/jyotiproy/IdeaProjects/krew_app/ios/Runner/GeneratedPluginRegistrant.h:9:8
Error (Xcode): failed to emit precompiled header '/Users/jyotiproy/Library/Developer/Xcode/DerivedData/Runner-bgkxbehdnpdmkjfwhnujcqssvqjc/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_2R9KITIRJQAWU-clang_13QX7MSDXGS1W.pch' for bridging header '/Users/jyotiproy/IdeaProjects/krew_app/ios/Runner/Runner-Bridging-Header.h'
Error launching application on Krew iPhone.
I've tried some solutions to this error that I found here on SO, like: This one, that suggests removing the ios folder and recreating the project and this one
I've found success once with the first solution (deleting the ios folder), but when I recently tried it again, it didn't work.
I am currently on Xcode 13.3 and below is the output of flutter doctor.
❯ flutter doctor -v
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.2 21D49 darwin-x64, locale en-GB)
• Flutter version 3.0.0 at /Volumes/macOS_Ext/Library/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ee4e09cce0 (6 weeks ago), 2022-05-09 16:45:18 -0700
• Engine revision d1b9a6938a
• Dart version 2.17.0
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Volumes/macOS_Ext/Library/Android
• Platform android-31, build-tools 30.0.3
• Java binary at: /Library/Java/JavaVirtualMachines/corretto-11.0.13/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment Corretto-11.0.13.8.1 (build 11.0.13+8-LTS)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Volumes/macOS_Ext/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] IntelliJ IDEA Community Edition (version 2022.1.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 68.1.4
• Dart plugin version 221.5787.37
[✓] VS Code (version 1.68.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.42.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 12.2 21D49 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.115
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I'm adding a link to our project's Podfile (as requested in the comments). It can be found here.