Search code examples
iosiphoneswiftswift2subproject

Adding sub-project in swift


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?


Solution

  • 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!!!