Cannot find interface declaration in myproject-swift.h

3.6k views Asked by At

I' m using XLPagerTabStrip pod in my project,

i have a bridging header for other purposes to integrate from swift to objective c myproject-swift.h

i cant build the project and this error always pops:

Cannot find interface declaration for 'ButtonBarPagerTabStripViewController', superclass of 'ParentViewController'

enter image description here

This is my Controller

import Foundation
import UIKit
import XLPagerTabStrip

class ParentViewController: ButtonBarPagerTabStripViewController {

    override func viewDidLoad() {
        tabStripStyle()
        super.viewDidLoad()
        containerView.isScrollEnabled = false
    }
   } 

I have seen this issue everywhere posted but its not yet answered here: 'Cannot find interface declaration' in auto-generated Swift bridging header

Bugs in swift SR-805 SR-5398

2

There are 2 answers

2
a.masri On BEST ANSWER

You needed to import the -Swift.h for for both the framework and the app target

For Example :

    #import <UIKit/UIKit.h>
    #import <AVFoundation/AVFoundation.h>
    #import <Foundation/Foundation.h>
    #import "XLPagerTabStrip-Swift.h"
    #import "RealmSwift-Swift.h"
    ...... // Add all frameworks, subclasses, and dependance ios frameworks
    #import  "MyProject-Swift.h"

You can read this article How to import file header and check paths

0
Steve Ham On

I had error "Cannot find interface declaration for 'CLLocation', superclass of 'MYLocation' for below code

@interface MYLocation : CLLocation // code in MyProject-Swift.h

when I just imported

#import <MyProject/MyProject-Swift.h>

after importing below both, the error is gone.

#import <CoreLocation/CoreLocation.h>
#import <MyProject/MyProject-Swift.h>