1

I have 2 projects in a workspaces, both are built using Swift.

I want to use one of the project as a sub-project of the other one and the classes, which are in the sub-project, in the parent project. My sub-project is using bridging-header.

I have tried to add one project as a reference to another and imported the class, which is in sub-project, but it didn't work.

Showing me Error: "No such module "

Please help me achieving this?

soumya
  • 3,801
  • 9
  • 35
  • 69
chandvoid
  • 133
  • 1
  • 12
  • Did you add these classes to public classes? – Candost Sep 08 '15 at 13:37
  • Yes. I have made these classes public, but the project is unable to import sub-project framework, which is having bridging-header. – chandvoid Sep 08 '15 at 15:27
  • Did you set your bridging-header in your target's Build Settings? – Candost Sep 08 '15 at 15:30
  • That it is set in the framework project. The framework project is compiling properly, but when i am inducing the framework in my other project, it is throwing error. It says two errors: (1) "Framework name" file not found. When i am trying to import it. and (2) Failed to import bridging header. – chandvoid Sep 08 '15 at 15:54
  • Did you add .framework file to "Linked Frameworks and Libraries"? – Candost Sep 08 '15 at 18:27
  • Yes, it is added in "Linked Frameworks and Libraries" and in "Embedded Binaries". – chandvoid Sep 09 '15 at 03:48
  • 1
    I think you shouldn't directly import your subproject's classes. You should create a public header and add your public classes to there. Then, you should just import this public header when you want to use. – Candost Sep 09 '15 at 06:37
  • Thanx for your effort @CandostDagdeviren. Made it work. – chandvoid Sep 09 '15 at 07:24

1 Answers1

0

Fixed the issue, thing i did was:

  1. Removed bridging header file, which was bridging my objective-C and swift code from my framework and deleted the bridging header file from Build Settings.
  2. Created a file named "Framework-name.h" and copied all the header files, which were there in my bridging header file, into "Framework-name.h" file.
  3. import "Framework-name.h" inside "Framework-name.h" file (this is vey important, it will keep the file at the root level of the framework).
  4. Made "Framework-name.h" and files that were included in Framework-name.h" file public.
  5. Created an aggregate target for my framework. https://medium.com/@syshen/create-an-ios-universal-framework-148eb130a46c
  6. Built the framework.
  7. Drag and drop the created framework into the root level of another sample project.
  8. Test the framework, writing import Framework-name in swift class of the sample project.
  9. Build the project.
  10. Bingo!!!
chandvoid
  • 133
  • 1
  • 12