skip to Main Content

I have an Xcode project, with a nested Framework.
The nested framework contains a Swift class I would like to use, that uses the @objcMembers public class.

@objcMembers public class SPDetailedStringPicker : UIViewController {

}

I want to use this Swift class in my base project.
I’ve tried many import methods such as using:

#import "MyNestedFramework/MyNestedFramework-Swift.h"

also tried:

#import "MyNestedFramework-Swift.h"

but no luck.
The project structure looks like this:

- MyProject
  - MyNestedFramework.xcodeproj
    - Classes
      - The Swift class I want to use
  - MyProject
    - Classes
      - The Objective c class I want to use that swift class in

2

Answers


  1. Chosen as BEST ANSWER

    Thanks to @arturdev 's suggestions - I managed to fix the issue.
    It was suggested to check the compiled frameworks headers under:

    - MyProject
      - MyNestedFramework
        - Products
          - MyNestedFramework.framework
    

    The MyNestedFramework-Swift.h header file was being generated. I then opened up the build phases tab under MyNestedFramework and opened the Headers section, then added the actual MyNestedFramework.Framework to the project.

    I am now able to use the Swift files from MyNestedFramework in my base project by importing:

    #import <MyNestedFramework/MyNestedFramework-Swift.h>
    

  2. Use <> instead of "

    #import <MyNestedFramework/MyNestedFramework-Swift.h>

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search