flutter_tflite icon indicating copy to clipboard operation
flutter_tflite copied to clipboard

IOS Xcode Build error : 'metal_delegate.h' file not found

Open sjc1117 opened this issue 3 years ago • 29 comments

'metal_delegate.h' file not found error occurred when building with XCode.

sjc1117 avatar Jul 30 '20 08:07 sjc1117

Same issue with the latest version, when trying to build the application in XCode I just get .../tflite-1.1.1/ios/Classes/TflitePlugin.mm:21:9: 'metal_delegate.h' file not found

DonC83 avatar Jul 30 '20 10:07 DonC83

What's the version of TensorFlowLiteC? The plugin is tested with TensorFlowLiteC (2.2.0). Can you open the project in XCode, then go to Pods > TensorFlowLiteC > Frameworks > TensorFlowLiteC.framework > Headers and see if it contains metal_delegate.h?

Thanks, Qian

shaqian avatar Aug 02 '20 13:08 shaqian

Hi, Thanks a lot I have same problem. There is no metal_delegate.h file.

Do you have any solution for it?

스크린샷 2020-08-03 오후 6 06 37

cnovice avatar Aug 03 '20 09:08 cnovice

Downgrading TensorFlowLiteC to 2.2.0 worked for me

  1. Downgrade your TensorFlowLiteC in /ios/Podfile.lock to 2.2.0
  2. run pod install in your /ios folder

sladomic avatar Aug 03 '20 21:08 sladomic

Downgrading TensorFlowLiteC to 2.2.0 worked for me

  1. Downgrade your TensorFlowLiteC in /ios/Podfile.lock to 2.2.0
  2. run pod install in your /ios folder

This also worked for me. Looks like the GPU delegate is no longer included in the pod from 2.3.0 on: https://www.tensorflow.org/lite/performance/gpu#step_2_modify_the_podfile_to_use_the_tensorflow_lite_gpu_cocoapod

stpch avatar Aug 04 '20 01:08 stpch

Thanks downgrading to 2.2.0 worked. @shaqian tensorflow version in Podfile.lock was 2.3.0.

DonC83 avatar Aug 04 '20 03:08 DonC83

After downgrading. Its working well. Thanks a lot! 👍

cnovice avatar Aug 04 '20 15:08 cnovice

Thanks every one, its working downgrade to 2.2.0 for me

sjc1117 avatar Aug 24 '20 06:08 sjc1117

If I downgrade in the Podfile.lock to 2.2.0 it tells me that tflite 1.1.1 depends on 2.3.0 and it fails to run pod install.

JoseGeorges8 avatar Sep 04 '20 13:09 JoseGeorges8

@JoseGeorges8 try flutter clean & flutter pub get first then do a pod install. My Podfile.lock looks like this:

- TensorFlowLiteC (2.2.0)
  - tflite (1.1.1):
    - Flutter
    - TensorFlowLiteC

DonC83 avatar Sep 07 '20 04:09 DonC83

If we are running CI/CD pipeline, we should not make changes respective to podfile.lock one. So, is there any alternative ?

Harshdeep4295 avatar Sep 11 '20 12:09 Harshdeep4295

@Harshdeep4295 you can download the plugin and use it locally, make the changes in the tflite.podspec file instead of podfile.lock

mirrorlink avatar Feb 25 '21 23:02 mirrorlink

@mirrorlink The thing is I can do that locally, but in case of any CI/CD pipeline, we need to write some script for it.

Harshdeep4295 avatar Feb 26 '21 17:02 Harshdeep4295

@Harshdeep4295 But I mean downloading the whole plugin. So the pipeline should use a local instance of the plugin instead of the github repository. Cant the CI/CD pipeline do that? I usually make the building scripts myself in node instead of using tools

mirrorlink avatar Feb 26 '21 18:02 mirrorlink

ummm actually it can work, but i haven't tried it yet.

On Fri, 26 Feb, 2021, 23:58 mirrorlink, [email protected] wrote:

@Harshdeep4295 https://github.com/Harshdeep4295 But I mean downloading the whole plugin. So the pipeline should use a local instance of the plugin instead of the github repository. Cant the CI/CD pipeline do that? I usually make the building scripts myself in node instead of using tools

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shaqian/flutter_tflite/issues/139#issuecomment-786818166, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGETABICG6BZUIMDGLJVFJDTA7R6PANCNFSM4PNHHWKQ .

Harshdeep4295 avatar Feb 26 '21 18:02 Harshdeep4295

It works, im doing exactly that :D the downside is that you end up with a version of the plugin that needs to be updated manually

mirrorlink avatar Feb 26 '21 19:02 mirrorlink

Cool... I'll try this though..

On Sat, 27 Feb, 2021, 00:42 mirrorlink, [email protected] wrote:

It works, im doing exactly that :D

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shaqian/flutter_tflite/issues/139#issuecomment-786840461, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGETABIAJWIBOFZH2NZOT23TA7XBDANCNFSM4PNHHWKQ .

Harshdeep4295 avatar Feb 26 '21 19:02 Harshdeep4295

I'm running into the same problem. I tried several ways to downgrade to TensorflowLiteC 2.2.0. I did a flutter clean, a flutter pub get and a pod install but it always throws errors. This is what I have originally in my podfile.lock:

  • TensorFlowLiteC (2.3.0):
    • TensorFlowLiteC/Core (= 2.3.0)
  • TensorFlowLiteC/Core (2.3.0)
  • TensorFlowLiteObjC (2.3.0):
    • TensorFlowLiteC (= 2.3.0)
  • tflite (1.1.1):
    • Flutter
    • TensorFlowLiteC

How should this look like?

JoergPf avatar Mar 29 '21 07:03 JoergPf

@JoergPf This is how my Podfile.lock, application is working on iOS

 - TensorFlowLiteC (2.2.0)
  - tflite (1.1.1):
    - Flutter
    - TensorFlowLiteC

Note I do not run my build in a pipeline.

DonC83 avatar Mar 29 '21 07:03 DonC83

See, if you are building via pipeline you have to add a script to change the TensorFlowLite after flutter pub get to change the version TensorFlowLite for pod install. If not building and working on the local system you can change things manually in the Podflie.lock file @JoergPf

Harshdeep4295 avatar Mar 29 '21 08:03 Harshdeep4295

Thanks for the quick replies.

 - TensorFlowLiteC (2.2.0)
  - tflite (1.1.1):
    - Flutter
    - TensorFlowLiteC

This throws me an error unfortunately.

I tried these possibilities (showing also the packages before and after the TensorFlowLite section):

....

  • PromisesObjC (1.2.12)
  • Protobuf (3.14.0)
  • TensorFlowLiteC (2.2.0)
    • tflite (1.1.1):
      • Flutter
      • TensorFlowLiteC
  • video_player (0.0.1):
    • Flutter

This gives me a parsing error when running pod install.

I also tried ...

  • PromisesObjC (1.2.12)
  • Protobuf (3.14.0)
  • TensorFlowLiteC (2.2.0)
  • tflite (1.1.1):
    • Flutter
    • TensorFlowLiteC
  • video_player (0.0.1):
    • Flutter

This gives me the error

"ICocoaPods could not find compatible versions for pod "TensorFlowLiteObjC":
  In snapshot (Podfile.lock):
    TensorFlowLiteObjC (= 2.2.0, ~> 2.3.0)
  In Podfile:
    firebase_ml_custom (from `.symlinks/plugins/firebase_ml_custom/ios`) was resolved to 0.0.1, which depends on
      Firebase/MLModelInterpreter (= 6.33.0) was resolved to 6.33.0, which depends on
        FirebaseMLModelInterpreter (~> 0.22.0) was resolved to 0.22.0, which depends on
          TensorFlowLiteObjC (~> 2.3.0)
You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `TensorFlowLiteObjC` inside your development pod `firebase_ml_custom`.
   You should run `pod update TensorFlowLiteObjC` to apply changes you've made."

I did a pod repo update but get the same result.

And I tried to set TensorFlowLiteC in my original Podfile.lock to 2.2.0

  • PromisesObjC (1.2.12)
  • Protobuf (3.14.0)
  • TensorFlowLiteC (2.2.0):
    • TensorFlowLiteC/Core (= 2.2.0)
  • TensorFlowLiteC/Core (2.2.0)
  • TensorFlowLiteObjC (2.2.0):
    • TensorFlowLiteC (= 2.2.0)
  • tflite (1.1.1):
    • Flutter
    • TensorFlowLiteC
  • video_player (0.0.1):
    • Flutter

I'm getting the same error:

"CocoaPods could not find compatible versions for pod "TensorFlowLiteObjC":
  In snapshot (Podfile.lock):
    TensorFlowLiteObjC (= 2.2.0, ~> 2.3.0) .... "

I'm still new to flutter and I think I'm not building via pipeline if you mean CICD workflows. We are trying CICD in a different test project but now in this one.

JoergPf avatar Mar 29 '21 08:03 JoergPf

Did you try do a pod install --repo-update ?

DonC83 avatar Mar 29 '21 08:03 DonC83

I just did a pod install --repo-update and get the same error:

"[!] CocoaPods could not find compatible versions for pod "TensorFlowLiteC":
  In snapshot (Podfile.lock):
    TensorFlowLiteC (= 2.2.0)

  In Podfile:
    firebase_ml_custom (from `.symlinks/plugins/firebase_ml_custom/ios`) was resolved to 0.0.1, which depends on
      Firebase/MLModelInterpreter (= 6.33.0) was resolved to 6.33.0, which depends on
        FirebaseMLModelInterpreter (~> 0.22.0) was resolved to 0.22.0, which depends on
          TensorFlowLiteObjC (~> 2.3.0) was resolved to 2.3.0, which depends on
            TensorFlowLiteC (= 2.3.0)

    tflite (from `.symlinks/plugins/tflite/ios`) was resolved to 1.1.1, which depends on
      TensorFlowLiteC


You have either:
 * changed the constraints of dependency `TensorFlowLiteC` inside your development pod `firebase_ml_custom`.
   You should run `pod update TensorFlowLiteC` to apply changes you've made."

Then I did a pod update TensorFlowLiteC

This rewrites my Podfile.lock to

  - Protobuf (3.14.0)
  - TensorFlowLiteC (2.3.0):
    - TensorFlowLiteC/Core (= 2.3.0)
  - TensorFlowLiteC/Core (2.3.0)
  - TensorFlowLiteObjC (2.3.0):
    - TensorFlowLiteC (= 2.3.0)
  - tflite (1.1.1):
    - Flutter
    - TensorFlowLiteC
  - video_player (0.0.1):
    - Flutter

JoergPf avatar Mar 29 '21 08:03 JoergPf

Are using firebase_ml_custom: ^0.2.0 ? It looks like you have a transitive dependency clash, FirebaseMLModelInterpreter requires TensorFlowLiteObjC 2.3.0

DonC83 avatar Mar 29 '21 08:03 DonC83

Yes, this is what I have:

firebase_core: ^0.7.0 #firebase_core: ^0.5.3
firebase_ml_custom: ^0.2.0
tflite: ^1.1.1

JoergPf avatar Mar 29 '21 09:03 JoergPf

Running the example app now and getting fatal error: 'metal_delegate.h' file not found #import "metal_delegate.h"

Is there a way to get pass this without downgrading?

Theunodb avatar Apr 29 '21 10:04 Theunodb

Running the example app now and getting fatal error: 'metal_delegate.h' file not found #import "metal_delegate.h"

Is there a way to get pass this without downgrading?

yes, just comment it and the lines that depend on it. ypu will miss just the gpu delegate

dganzella avatar Apr 29 '21 10:04 dganzella

This plugin needs updating to explicitly include the metal subspec, since it uses it in the implementation; https://www.tensorflow.org/lite/performance/gpu#ios_with_xcode

Since the podspec on this plugin doesn't specify a version range https://github.com/shaqian/flutter_tflite/blob/master/ios/tflite.podspec#L18 new users installing this plugin will get the latest version of TensorFlowLiteC of which Metal doesn't exist in the main spec anymore. Modifying the Podfile.lock isn't a solution

Salakar avatar May 10 '21 11:05 Salakar

This worked for me:

https://github.com/shaqian/flutter_tflite/pull/243

swarmidentity avatar Mar 01 '22 21:03 swarmidentity