34

I have a small proof-of-concept app, where I am trying to embed (and sign) a framework (Alamofire) inside of my framework (AequumPOCFramework.framework), however, when I try to deploy to my device, it keeps giving me the error

....not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.

If I just try to deploy my own framework, without having Alamofire embedded in it, everything works fine.

The complete error at deploy to my iphone is:

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire Referenced from: /private/var/containers/Bundle/Application/EDB697EB-EA15-4301-B4B6-A8FE1F0212BE/PocIOS.app/Frameworks/AequumPOCFramework.framework/AequumPOCFramework Reason: no suitable image found. Did find: /private/var/containers/Bundle/Application/EDB697EB-EA15-4301-B4B6-A8FE1F0212BE/PocIOS.app/Frameworks/AequumPOCFramework.framework/Frameworks/Alamofire.framework/Alamofire: code signature in (/private/var/containers/Bundle/Application/EDB697EB-EA15-4301-B4B6-A8FE1F0212BE/PocIOS.app/Frameworks/AequumPOCFramework.framework/Frameworks/Alamofire.framework/Alamofire) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.

What am I doing wrong?

enter image description here

enter image description here

enter image description here

enter image description here

Top-Master
  • 7,611
  • 5
  • 39
  • 71
geekyaleks
  • 1,281
  • 3
  • 18
  • 29
  • 3
    Having the same problem here. Currently digging into this problem. Keep me posted if you already found a solution! – makle Nov 13 '19 at 23:26
  • 2
    So glad to see that i am not the only one.... If I find out, I will let you know. Also, please let me know if you make any headway. – geekyaleks Nov 14 '19 at 12:05
  • I can already tell you that it has to do with the signing process of the framework. So the problem is that Xcode says that the embedded framework's signing is wrong or not the same like your own framework ones. I'm currently digging deeper. Check this article for a good intro to the topic: https://medium.com/@tally_b/more-unfolding-on-ios-signings-b6886236d7fc – makle Nov 14 '19 at 18:17
  • 3
    Yes, something is wrong with this signing process... For now, I am including my Alamofire framework to my own framework, sign and embed it there, AND sign and embed it in the App itself. I know this kind of sucks, but this will let me at least keep coding, and hopefully a real fix comes out sometime soon. – geekyaleks Nov 15 '19 at 20:10
  • (1/2) To give you a quick update: So my own situation was that we have a private cocoapod (a closed source SDK) that we distribute that is reliant on another private cocoapod. Our partner now decided to stop using cocoapods as distribution, so therefore forcing us to either directly integrate or host the SDK ourselves. If we directly integrate it, we will create a so called umbrella framework, which is not recommended by apple. See: https://developer.apple.com/library/archive/technotes/tn2435/_index.html#//apple_ref/doc/uid/DTS40017543-CH1-PROJ_CONFIG-APPS_WITH_DEPENDENCIES_BETWEEN_FRAMEWORKS – makle Nov 16 '19 at 21:21
  • (2/2) We now decided to host the private cocoapod ourselves to avoid the above signing problem for the short time being. The long term solution is now to either figure out the signing problem above or move towards a so called XCFramework (https://appspector.com/blog/xcframeworks ) which was recently introduced by Apple during ther WWDC. We assume that this could fix our problems. We tried that already but weren't successful with our approach yet. If you are please let me know, since I want to find a solution here. In the meantime maybealso look at XCFramework if this fixes your problems! – makle Nov 16 '19 at 21:23
  • 1
    Thank you for a very comprehensive answer... I have decided that for now, I will just sign the "embedded/embedded" framework in the app itself, hopefully another answer will show up in the near future... – geekyaleks Nov 19 '19 at 15:31
  • There is also this answer https://stackoverflow.com/questions/7365578/why-are-umbrella-frameworks-discouraged – geekyaleks Nov 19 '19 at 16:10
  • How do you "sign the "embedded/embedded" framework in the app itself" @geekyaleks – DàChún Jun 02 '21 at 15:29

4 Answers4

33

Nested frameworks are not supported on iOS (see technotes). The only legit solution at the moment is to link "embedded" frameworks directly to a hosting app.

*XCFramework is mainly an aggregation of platform specific binaries and has nothing to do with embedding frameworks unfortunately.

berec
  • 775
  • 10
  • 19
  • 5
    Any news about the issue? I'm facing the same problem: my framework A is using my framework B and I need the final app to only include framework A and not to be able to access framework B – Silvia Apr 07 '20 at 10:03
  • @Silvia If you absolutely need to hide B, then I believe you can turn it into Static Library. – berec Apr 10 '20 at 12:17
  • I had to copy the embedded framework into the frameworks directory of the client app - thank you for the answer – dazza5000 Sep 22 '20 at 21:04
  • Thanks for Saving my day. Now, I have a clear understanding how to handle umbrella frameworks in iOS – Avinash B Apr 29 '21 at 14:26
1

You gotta embed Alamofire to your project, too.

For example, you are using Carthage and the Cartfile of your framework has Alamofire library. You gotta use the same Carfile for your main app, too. Also, you gotta perform other Carthage actions(linking library, adding run script) for the main app.

Yusuf
  • 851
  • 6
  • 14
  • 1
    Yes, I found that out as well, however, it was not my goal to have all my Frameworks exposed to the end-developer. I was hoping to have everything nicely bundled inside of one framework (my framework). Thanks.. – geekyaleks Dec 24 '19 at 15:11
0

In case anyone looking solution for dylib for this error:

dylib not valid for use in process: mapped file has no cdhash

Check Code sign on copy in Build Phases -> Copy to $(BUILT_PRODUCTS_DIR)/$FRAMEWORKS_FOLDER_PATH

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Anbu
  • 91
  • 7
0

As Berec pointed out embedding frameworks in a framework is not supported. But there is an other way. You can statically link all the dependencies of your library, so in the final framework the binary will also contain the code of its dependencies.

If you are using CocoaPods and the name of the framework is aFramework you can do:

  target 'aFramework' do
    pod 'Alamofire', :linkage => :static
  end

Then you can use the created aFramework.framework in a application target that does not have the Alamofire framework, since the code will be "embedded" in the aFramework's binary.

Christos Koninis
  • 1,499
  • 1
  • 15
  • 28