3

I made a custom Swift framework to reuse the same code across different projects. However, when I import the framework in other projects, the classes are not available for use.

Things I already did

  1. To create the framework, I picked a Cocoa Touch Framework project. The structure of the project: framework project structure

  2. I marked the classes public class AVSManager {} and the init() functions as public.

  3. Copied the .framework file to the root of the other projects

  4. In the projects, I added the framework as embedded binary

  5. Imported the framework in the ViewController.swift class of a project: import AVSCMDI

When I then try to call AVSManager() it produces the following error: AVSManager is unavailable: cannot find Swift declaration for this class

Does anybody have an idea what i'm missing here?

Thanks in advance!

tomwyckhuys
  • 111
  • 5

1 Answers1

7

I found the solution to my problem!

It turned out that I needed to build my framework with a real device as target.

tomwyckhuys
  • 111
  • 5
  • Ughh had the same issue. Thanks. – Baran Mar 11 '18 at 10:26
  • Is there any workaround to use the framework when running the application on simulator (except building the framework for an simulator and importing it then into project)? – Baran Mar 11 '18 at 10:33
  • Can anyone explain/understand this? I can't manage to compile the project (when I add a custom library) for a simulator.. – alasker May 18 '18 at 14:50
  • You need to create a "fat" framework, for both architectures (simulator and real device). Take a look at this thread. https://stackoverflow.com/questions/29634466/how-to-export-fat-cocoa-touch-framework-for-simulator-and-device/29650369#29650369 – Leonardo Cardoso Jul 19 '18 at 16:25
  • had the same issue, Thanks !! – Parth Barot Mar 18 '19 at 07:58