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

[webview_flutter_wkwebview] 'Flutter/Flutter.h' file not found Xcode 15 #135099

Closed
Auramel opened this issue Sep 20, 2023 · 26 comments
Closed

[webview_flutter_wkwebview] 'Flutter/Flutter.h' file not found Xcode 15 #135099

Auramel opened this issue Sep 20, 2023 · 26 comments
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@Auramel
Copy link

Auramel commented Sep 20, 2023

I'm upgraded on Xcode 15 and has this problem on build
image

I update Podfile before because I have error on build
DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

Podfile
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if config.base_configuration_reference
        xcconfig_path = config.base_configuration_reference.real_path
        xcconfig = File.read(xcconfig_path)
        xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
        File.open(xcconfig_path, "w") { |file| file << xcconfig_mod } 
      end
    end
  end
end

I make flutter flutter pub get and flutter pub upgrade
I use mac os on m1, Ventura 13.5.2

flutter doctor -v
[✓] Flutter (Channel stable, 3.13.4, on macOS 13.5.2 22G91 darwin-arm64, locale
    ru-RU)
    • Flutter version 3.13.4 on channel stable at
      /opt/homebrew/Caskroom/flutter/3.10.3/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 367f9ea16b (7 дней назад), 2023-09-12 23:27:53 -0500
    • Engine revision 9064459a8b
    • Dart version 3.1.2
    • DevTools version 2.25.0

[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from:
https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK
components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup
for detailed instructions).
If the Android SDK has been installed to a custom location, please use
flutter config --android-sdk to update to that location.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A240d
• CocoaPods version 1.12.1

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup
for detailed instructions).

[✓] VS Code (version 1.82.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.72.0

[✓] Connected device (3 available)
• iPhone 15 Pro (mobile) • F2DFADF7-4A62-4EA8-8293-85735B8CABBB • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.5.2 22G91 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 116.0.5845.187

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 2 categories.

@Auramel Auramel changed the title 'Flutter/Flutter.h' file not found Xcode 15 [webview_flutter_wkwebview] 'Flutter/Flutter.h' file not found Xcode 15 Sep 20, 2023
@dam-ease dam-ease added the in triage Presently being triaged by the triage team label Sep 20, 2023
@dam-ease
Copy link

Hi @Auramel. Thanks for filing this. Can you try out the suggested solution in this thread to see if it works in your case?

@dam-ease dam-ease added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 20, 2023
@Auramel
Copy link
Author

Auramel commented Sep 20, 2023

@dam-ease Hello. Yes, I did it. It is not solved my problem. I found this thread and it not help me too.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 20, 2023
@Auramel
Copy link
Author

Auramel commented Sep 20, 2023

I have same problem with url_laucnher package. After flutter pub upgrade it disappeared

@Auramel
Copy link
Author

Auramel commented Sep 20, 2023

I think the problem is in my Podfile. Here guy has same problem

@chanjungkim
Copy link

chanjungkim commented Sep 20, 2023

I did all the things on the internet and nothing worked!

I even downgraded to xcode 14.3.1 but didn't work.

@Auramel
Copy link
Author

Auramel commented Sep 21, 2023

@chanjungkim I'm downgraded to Xcode 14.3.1, then deleted:

  • ios/Pods
  • ios/Podfile.lock
  • ios/.symlinks
  • pubspec.lock

Removed all Xcode files from my computer (Caches, Virtual devices and other)

run:

  • flutter clean
  • flutter pub get
  • flutter pub upgrade
    and it worked.

@stoppimyse
Copy link

stoppimyse commented Sep 21, 2023

hi, i receive this error flutter.h not found, xcode15 ios 17

#import <Flutter/Flutter.h>
#import <Foundation/Foundation.h>
#import <WebKit/WebKit.h>

NS_ASSUME_NONNULL_BEGIN

/**
 * App and package facing native API provided by the `webview_flutter_wkwebview` plugin.
 *
 * This class follows the convention of breaking changes of the Dart API, which means that any
 * changes to the class that are not backwards compatible will only be made with a major version
 * change of the plugin. Native code other than this external API does not follow breaking change
 * conventions, so app or plugin clients should not use any other native APIs.
 */
@interface FWFWebViewFlutterWKWebViewExternalAPI : NSObject
/**
 * Retrieves the `WKWebView` that is associated with `identifier`.
 *
 * See the Dart method `WebKitWebViewController.webViewIdentifier` to get the identifier of an
 * underlying `WKWebView`.
 *
 * @param identifier The associated identifier of the `WebView`.
 * @param registry The plugin registry the `FLTWebViewFlutterPlugin` should belong to. If
 *        the registry doesn't contain an attached instance of `FLTWebViewFlutterPlugin`,
 *        this method returns nil.
 * @return The `WKWebView` associated with `identifier` or nil if a `WKWebView` instance associated
 * with `identifier` could not be found.
 */
+ (nullable WKWebView *)webViewForIdentifier:(long)identifier
                          withPluginRegistry:(id<FlutterPluginRegistry>)registry;
@end

NS_ASSUME_NONNULL_END`

my podfile:

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

#post_install do |installer|
#  installer.pods_project.targets.each do |target|
#    flutter_additional_ios_build_settings(target)
#  end
#end

post_install do |installer|
  installer.aggregate_targets.each do |target|
    target.xcconfigs.each do |variant, xcconfig|
      xcconfig_path = target.client_root + target.xcconfig_relative_path(variant)
      IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
    end
  end
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if config.base_configuration_reference.is_a? Xcodeproj::Project::Object::PBXFileReference
        xcconfig_path = config.base_configuration_reference.real_path
        IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
      end
    end
  end
end

@huycozy
Copy link
Member

huycozy commented Sep 21, 2023

I also use XCode 15 Build 15A240d and run below sample code on iPhone 14 Pro, iOS 17.0 but can't reproduce this issue.

Minimal sample code
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() => runApp(const MaterialApp(home: WebViewExample()));

class WebViewExample extends StatefulWidget {
  const WebViewExample({super.key});

  @override
  State<WebViewExample> createState() => _WebViewExampleState();
}

class _WebViewExampleState extends State<WebViewExample> {
  late final WebViewController controller;

  @override
  void initState() {
    super.initState();

    // #docregion webview_controller
    controller = WebViewController()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..setBackgroundColor(const Color(0x00000000))
      ..setNavigationDelegate(
        NavigationDelegate(
          onProgress: (int progress) {
            // Update loading bar.
          },
          onPageStarted: (String url) {},
          onPageFinished: (String url) {},
          onWebResourceError: (WebResourceError error) {},
          onNavigationRequest: (NavigationRequest request) {
            if (request.url.startsWith('https://www.youtube.com/')) {
              return NavigationDecision.prevent;
            }
            return NavigationDecision.navigate;
          },
        ),
      )
      ..loadRequest(Uri.parse('https://google.com/'));
    // #enddocregion webview_controller
  }

  // #docregion webview_widget
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Flutter Simple Example')),
      body: WebViewWidget(controller: controller),
    );
  }
// #enddocregion webview_widget
}

Can you try running this sample on new project or plugin example to see if you can replicate the issue?

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 21, 2023
@stoppimyse
Copy link

@Auramel have you resolve?

@stoppimyse
Copy link

@huycozy hi, for firebase we have chenge the podfile for the bug DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead. I think the problem is here, can you try to add firebase and change the podfile.

@Auramel
Copy link
Author

Auramel commented Sep 21, 2023

@stoppimyse no, I deleted Xcode 15 and installed Xcode 14.3.1

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 21, 2023
@stoppimyse
Copy link

i've resolve usinng this podfile configuration

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    # shim for CocoaPods issue, should remove when 1.13.0 is released
    # more info: https://github.com/CocoaPods/CocoaPods/issues/12012#issuecomment-1659803356
    target.build_configurations.each do |config|
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end

@Auramel
Copy link
Author

Auramel commented Sep 21, 2023

@huycozy yes, I create new project and it running on Xcode 15. But! I replaced my ios folder from new flutter project and it not working.

@huycozy
Copy link
Member

huycozy commented Sep 21, 2023

@Auramel I can reproduce this issue with your initial Podfile configuration but I notice it's missing flutter_additional_ios_build_settings(target) when comparing it with @stoppimyse's comment above. And it indeed works after I added the line back (it's the default when creating a project). Can you try adding it back and confirm?

Also, regarding #135099 (comment), there is a related topic at flutterfire repository: firebase/flutterfire#11614. It's cocoapods issue and looks like you are attempting to solve it with workaround, right?

@Auramel @chanjungkim Please try the podfile configuration above and confirm this.

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 21, 2023
@TiluWeb
Copy link

TiluWeb commented Sep 21, 2023

i've resolve usinng this podfile configuration

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    # shim for CocoaPods issue, should remove when 1.13.0 is released
    # more info: https://github.com/CocoaPods/CocoaPods/issues/12012#issuecomment-1659803356
    target.build_configurations.each do |config|
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end

With this, I got :
Error (Xcode): SDK does not contain 'libarclite' at the path '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a'; try increasing the minimum deployment target

@Auramel
Copy link
Author

Auramel commented Sep 21, 2023

@Auramel I can reproduce this issue with your initial Podfile configuration but I notice it's missing flutter_additional_ios_build_settings(target) when comparing it with @stoppimyse's comment above. And it indeed works after I added the line back (it's the default when creating a project). Can you try adding it back and confirm?

Also, regarding #135099 (comment), there is a related topic at flutterfire repository: firebase/flutterfire#11614. It's cocoapods issue and looks like you are attempting to solve it with workaround, right?

@Auramel @chanjungkim Please try the podfile configuration above and confirm this.

My Podfile configuration I found in Google. Ok, I will try. I deleted Xcode 15, I'll have to download it again.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 21, 2023
@stuartmorgan
Copy link
Contributor

Flutter should inject a workaround for the DT_TOOLCHAIN_DIR issue the first time you run, so manually changing your Podfile to do that should not be necessary unless you already had a custom Podfile.

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 22, 2023
@Auramel
Copy link
Author

Auramel commented Sep 26, 2023

image

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 26, 2023
@stuartmorgan
Copy link
Contributor

@Auramel Please do not post pictures of text; they are much harder to read, and they aren't searchable.

It's also not clear to me how that is related to this issue. It's not the same error, and it's not even from a Flutter-team-provided plugin. Does this mean you no longer have an issue with webkit_flutter?

@stuartmorgan stuartmorgan added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 26, 2023
@MasonKomo
Copy link

i've resolve usinng this podfile configuration

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    # shim for CocoaPods issue, should remove when 1.13.0 is released
    # more info: https://github.com/CocoaPods/CocoaPods/issues/12012#issuecomment-1659803356
    target.build_configurations.each do |config|
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end

With this, I got : Error (Xcode): SDK does not contain 'libarclite' at the path '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a'; try increasing the minimum deployment target

were you able to resolve this? I updated my podfile and am getting the same error that you mentioned.

@Mortando
Copy link

Mortando commented Oct 4, 2023

Issue is still open.

Upgraded Cocoapods to v1.13.0 and the fix mentioned above is not needed anymore.

Then with pod install there is the error 'Flutter/Flutter.h' file not found on all pods.

Below is Podfile:

`# Uncomment this line to define a global platform for your project
platform :ios, '13.0'

CocoaPods analytics sends network stats synchronously affecting flutter build latency.

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), FILE)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(FILE))
#target 'RunnerTests' do

inherit! :search_paths

#end
end

post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
end
end
end
`

@TiluWeb
Copy link

TiluWeb commented Oct 13, 2023

Solution:
Delete Xcode 15.
Download Xcode 14.3 : https://developer.apple.com/download/all/?q=Xcode%2014 & its command tools.

@Mortando
Copy link

In my case the issue was actually related to Cocoapods being installed via brew & older version via gem also.

Completely deleted brew and updated to the latest fix via gem and Flutter/Flutter.h was there to be imported again.

@fishofeyes
Copy link

我调整build phases 配置顺序解决了“'Flutter/Flutter.h' file not found”image

调整后:

buildPhases = (
		87B419743B513AB9E3637B1D /* [CP] Check Pods Manifest.lock */,
		9740EEB61CF901F6004384FC /* Run Script */,
		97C146EA1CF9000F007C117D /* Sources */,
		97C146EB1CF9000F007C117D /* Frameworks */,
		97C146EC1CF9000F007C117D /* Resources */,
		9705A1C41CF9048500538489 /* Embed Frameworks */,
		E583813125B0628A003E7508 /* Embed Watch Content */,
		35565F8214D07D71E5076AFE /* [CP] Embed Pods Frameworks */,
		89FFCF69F1320183F0FA1830 /* [CP] Copy Pods Resources */,
		3B06AD1E1E4923F5004D2608 /* Thin Binary */,
	);

@github-actions
Copy link

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

10 participants