10

Currently I am working in a framework project to distribute to a client we have. The Framework has SPM dependencies and I wanted to create an XCFramework from it. I found the scripts to archive and generate the XCFramework with the xcodebuild tool. The problem is that the generation is not working and I get the following error Failed to build module 'XXX' from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced. I don't know if it is possible to build a framework with SPM dependencies as an XCFramework I was trying to distribute it as binary framework to protect our source code. I previously looked for this but couldn't found any information in the matter. Can somebody help me?

Otto Cheley
  • 552
  • 9
  • 20
  • I'm facing the same problems. Have you found a solution? If so I would be very interested in some informations. – Martin Mar 10 '21 at 15:48

1 Answers1

9

One solution seems to add @_implementationOnly import for the modules from the third-party SDKs. This should fix your XCframework error if you aren't using anything from that SDK as part of your module's public interface.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Martin
  • 843
  • 8
  • 17
  • I would like to write this comment to thank you for saving me. Is there some documentation explaining why I need to use `@_implementationOnly` in this case and what are the other cases I should use it? – alobaili Mar 31 '21 at 12:31
  • @alobaili: you can find a few discussion about this topic on the swift forums. [implementation](https://forums.swift.org/t/update-on-implementation-only-imports/26996). [Issue with third party](https://forums.swift.org/t/issue-with-third-party-dependencies-inside-a-xcframework-through-spm/41977) – Martin Jun 16 '21 at 18:51
  • My xcframework does not depend on any third party dependency. I am still getting the error shown in question. – Rohan Sanap Oct 25 '21 at 06:34