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

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

Open
sjc1117 opened this issue Jul 30, 2020 · 29 comments
Open

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

sjc1117 opened this issue Jul 30, 2020 · 29 comments

Comments

@sjc1117
Copy link

sjc1117 commented Jul 30, 2020

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

@DonC83
Copy link

DonC83 commented Jul 30, 2020

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

@shaqian
Copy link
Owner

shaqian commented Aug 2, 2020

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

@cnovice
Copy link

cnovice commented Aug 3, 2020

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

@sladomic
Copy link

sladomic commented Aug 3, 2020

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

@stpch
Copy link

stpch commented Aug 4, 2020

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

@DonC83
Copy link

DonC83 commented Aug 4, 2020

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

@cnovice
Copy link

cnovice commented Aug 4, 2020

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

@sjc1117
Copy link
Author

sjc1117 commented Aug 24, 2020

Thanks every one,
its working downgrade to 2.2.0 for me

@JoseGeorges8
Copy link

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.

@DonC83
Copy link

DonC83 commented Sep 7, 2020

@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

@Harshdeep4295
Copy link

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

@mirrorlink
Copy link

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

@Harshdeep4295
Copy link

@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.

@mirrorlink
Copy link

@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

@Harshdeep4295
Copy link

Harshdeep4295 commented Feb 26, 2021 via email

@mirrorlink
Copy link

mirrorlink commented Feb 26, 2021

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

@Harshdeep4295
Copy link

Harshdeep4295 commented Feb 26, 2021 via email

@JoergPf
Copy link

JoergPf commented Mar 29, 2021

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?

@DonC83
Copy link

DonC83 commented Mar 29, 2021

@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.

@Harshdeep4295
Copy link

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

@JoergPf
Copy link

JoergPf commented Mar 29, 2021

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.

@DonC83
Copy link

DonC83 commented Mar 29, 2021

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

@JoergPf
Copy link

JoergPf commented Mar 29, 2021

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

@DonC83
Copy link

DonC83 commented Mar 29, 2021

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

@JoergPf
Copy link

JoergPf commented Mar 29, 2021

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

@Theunodb
Copy link

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?

@dganzella
Copy link

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

@Salakar
Copy link

Salakar commented May 10, 2021

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

@swarmidentity
Copy link

This worked for me:

#243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.