3

Recently I created a iOS Framework called "MLKit Framework" that uses MLKit Face Detection library. In order to achieve that, I just imported the library in Podfile according to documentation.

As expected, that created a xcworkspace called MLKit Framework. In order to test that new framework, I created an app called MLKitApp and added that app to the same workspace. Then I added the framework MLKitFramework to that app and tried to build it but I get the error statement: "Missing required module 'MLKit'" as the image below.

Error statement: Missing required module 'MLKit'

Why Am I getting that error? What I'm doing wrong?

Reproducible Example

I created a Reproducible Example here. In order to execute that example execute the following:

  1. Execute pod install for MLKitFramework;
  2. Add MLKitApp to MLKitFramework.xcworkspace;
  3. Add MLKitFramework.framework as a MLKitApp Frameworks, Libraries and Embedded Content;
  4. Try to build MLKitApp.

And voilà

  • I am having this issue too, I have made an iOS framework that uses MLKit, so MLKit has been added to the pod file for the framework. I build the framework and add it to my app, the app then errors saying I don't have MLKit (how I thought it would work because the framework uses MLKit and the pod file should be adding it as a dynamic link, ie consumer is dependant on it). So I add MLKit to my apps pod file because the app needs it. Then I get 100s of errors about how there is now duplicate files for ML Kit. I Don't understand how MLKit is been compiled into the framework and also depends on it. – AngryDuck May 04 '21 at 14:04
  • Please let me know if you find a solution to this, from what I can figure out it must be MLKits pod not working properly or something, as its compiling into the framework and also somehow dependant on it at the same time, I can't do anything to get it to not compile in, or compile in and not be dependant on it, its driving me mad! im trying everything and there is basically no advice anywhere on what to do to use it in a framework... – AngryDuck May 04 '21 at 14:05
  • @AngryDuck that's exactly what I think. I opened that same question as an [issue](https://github.com/googlesamples/mlkit/issues/278) on MLKit official samples repository. If possible, comment there that you have been having that same issue too. – Gabriel Marcondes May 04 '21 at 16:04

2 Answers2

0

Have you checked out the ML Kit Vision Quickstart? Please note it contains two apps: one for swift and another for objective-c. You check check out the swift app for your purpose - it contains face detection feature. The Vision Quickstart is similar to your MLKitApp and shows you an example how to integrate with ML Kit cocoapods directly without needing to introduce an "MLKitFramework" or manually manage dependency configuration. Instead, you should let CocoaPods manage that. You can use this Quickstart as a template for implementing your own app.

Dong Chen
  • 564
  • 2
  • 6
-1

You can't do this because your's "MLKitFramework" have dependency to MLKit.

You should add MLKit framework to MLKitApp additionally.

  • _You can't do this because your's "MLKitFramework" have dependency to MLKit._ That's why I added the MLKitFramework Podfile, so that doesn’t clearly explain the reason for the error. Besides that, it is odd to need to import the MLKit in the user's app, since this usually does not happen in other dependency libraries. Why does this behavior occur exclusively in the MLKit library? – Gabriel Marcondes May 03 '21 at 12:11
  • Because if made your's library as Pod with dependency configuration, then CocoaPods resolve these dependencies. You added your's framework manually, then your resolve dependencies manually. – Dmytro Hrebeniuk May 03 '21 at 21:03
  • Thanks for being supportive. I added MLKit as a Podfile dependency to MLKitApp too, then I started to receiving multiple errors by build the library twice, so I think thats not the way to go. Can u please help me to resolve these dependencies manually? – Gabriel Marcondes May 03 '21 at 23:55
  • I can propose 2 ways: * Create Application target and Framework target in one project, then add MLKit as for both targets. * Or setup MLKitFramework as Pod as add to it MLKit as dependency. – Dmytro Hrebeniuk May 04 '21 at 14:23
  • I tried both approaches, neither solved the MLKit problem. Thank you anyway. – Gabriel Marcondes May 04 '21 at 15:55
  • No, I attached to your's GitHub project correct way to resolve decencies via CocoaPods in third party frameworks. [link](https://github.com/marcondes-io/MLKitIssue/issues/1) link to sample – Dmytro Hrebeniuk May 04 '21 at 16:41