webview_cef icon indicating copy to clipboard operation
webview_cef copied to clipboard

error in macos Android Studio and temporary fix

Open okiabrian123 opened this issue 2 years ago • 9 comments

after read https://github.com/hlwhl/webview_cef/issues/11, i will update this, update 30 nov 2022, error :

clang: error: no such file or directory: 'Embedded' clang: error: no such file or directory: 'Framework'

u must clear "other linker flags" in Runner.xcodeproj

  1. open project folder, open macos folder
  2. open Runner.xcodeproj, click Runner, open "Build Settings"
  3. scroll and looking for "Lingking"
  4. clearing "Other Linker Flags"

Screenshot 2022-11-30 at 02 36 36

okiabrian123 avatar Nov 17 '22 20:11 okiabrian123

I have tested with s.vendored_frameworks = '"third/cef/Chromium Embedded Framework.framework"'. It is the reason caused the error2 you mentioned above.

Leave s.vendored_frameworks = 'third/cef/Chromium Embedded Framework.framework' as it is, delete 'Podfile.lock' and execute flutter clean in example folder, it works as intended. The framework file will be copy to app bundle automatically.

hlwhl avatar Nov 29 '22 10:11 hlwhl

i got this error "clang: error: no such file or directory: 'Embedded' clang: error: no such file or directory: 'Framework' Command Ld failed with a nonzero exit code"

but when i run the new example there is no error. I don't know what's different in my example and my project.

okiabrian123 avatar Nov 29 '22 17:11 okiabrian123

after read this clearing "other linker flag" and then its working. thank you i will edit my text on above, maybe someone need this on english Screenshot 2022-11-30 at 02 36 36

okiabrian123 avatar Nov 29 '22 19:11 okiabrian123

Clearing Other Linker Flags is causing problems with some plugins, for example with firebase_analytics:

Launching lib/app/main.dart on macOS in debug mode...
Running pod install...
Building macOS application...
ld: warning: ignoring duplicate library '-lc++'
ld: warning: duplicate -rpath '/usr/lib/swift' ignored
ld: warning: duplicate -rpath '@executable_path/../Frameworks' ignored
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
ld: Undefined symbols:
  _FIRConsentStatusDenied, referenced from:
      -[FLTFirebaseAnalyticsPlugin setConsent:withMethodCallResult:] in firebase_analytics[4](FLTFirebaseAnalyticsPlugin.o)
      -[FLTFirebaseAnalyticsPlugin setConsent:withMethodCallResult:] in firebase_analytics[4](FLTFirebaseAnalyticsPlugin.o)
  _FIRConsentStatusGranted, referenced from:
      -[FLTFirebaseAnalyticsPlugin setConsent:withMethodCallResult:] in firebase_analytics[4](FLTFirebaseAnalyticsPlugin.o)
      -[FLTFirebaseAnalyticsPlugin setConsent:withMethodCallResult:] in firebase_analytics[4](FLTFirebaseAnalyticsPlugin.o)
  _FIRConsentTypeAdStorage, referenced from:
      -[FLTFirebaseAnalyticsPlugin setConsent:withMethodCallResult:] in firebase_analytics[4](FLTFirebaseAnalyticsPlugin.o)
  _FIRConsentTypeAnalyticsStorage, referenced from:
      -[FLTFirebaseAnalyticsPlugin setConsent:withMethodCallResult:] in firebase_analytics[4](FLTFirebaseAnalyticsPlugin.o)
  _OBJC_CLASS_$_FIRAnalytics, referenced from:
       in firebase_analytics[4](FLTFirebaseAnalyticsPlugin.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **

Exception: Build process failed

adrianjagielak avatar Aug 17 '23 10:08 adrianjagielak

I've fixed it locally without clearing Other Linker Flags using this quick and dirty Dart script:

import 'dart:io';

// Fix for package:webview_cef, see https://github.com/hlwhl/webview_cef/issues/27
void main() {
  const List paths = [
    'macos/Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig',
    'macos/Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig',
    'macos/Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig',
  ];

  for (final path in paths) {
    File(path).writeAsStringSync(
      File(path)
          .readAsStringSync()
          .replaceAll('-ObjC Embedded Framework ', '')
          .replaceAll('-framework "Chromium"', '-framework "Chromium Embedded Framework"'),
    );
  }
}

Assuming you will put this in tool/webview_cef_linker_fix.dart just run dart tool/webview_cef_linker_fix.dart in terminal when the build fails (probably only needed after each flutter pub get).

adrianjagielak avatar Aug 29 '23 23:08 adrianjagielak

I've fixed it locally without clearing Other Linker Flags using this quick and dirty Dart script:

import 'dart:io';

// Fix for package:webview_cef, see https://github.com/hlwhl/webview_cef/issues/27
void main() {
  const List paths = [
    'macos/Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig',
    'macos/Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig',
    'macos/Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig',
  ];

  for (final path in paths) {
    File(path).writeAsStringSync(
      File(path)
          .readAsStringSync()
          .replaceAll('-ObjC Embedded Framework ', '')
          .replaceAll('-framework "Chromium"', '-framework "Chromium Embedded Framework"'),
    );
  }
}

Assuming you will put this in tool/webview_cef_linker_fix.dart just run dart tool/webview_cef_linker_fix.dart in terminal when the build fails (probably only needed after each flutter pub get).

Did not work for me, do you have any solutions or possible reasons? I checked manually and did not see any of the replaced values in those files. @adrianjagielak

bahricanyesil avatar Dec 11 '23 13:12 bahricanyesil

Did not work for me, do you have any solutions or possible reasons? I checked manually and did not see any of the replaced values in those files. @adrianjagielak

What is your current content of macos/Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig?

adrianjagielak avatar Dec 11 '23 15:12 adrianjagielak

Did not work for me, do you have any solutions or possible reasons? I checked manually and did not see any of the replaced values in those files. @adrianjagielak

What is your current content of macos/Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig?

I'm sorry for the late late response but I just wanted to write this to clear up any doubts that may arise in the minds of those who will read it. I do not know what was the problem at that time but currently, I do not have any problem. Replacing the following (just as you did in your dart script) works without any problem for me also:

  1. .replaceAll('-ObjC Embedded Framework ', '')
  2. .replaceAll('-framework "Chromium"', '-framework "Chromium Embedded Framework"')

bahricanyesil avatar Aug 15 '24 11:08 bahricanyesil