7

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

a.masri
  • 2,439
  • 1
  • 14
  • 32
Sanad Barjawi
  • 539
  • 4
  • 15
  • Is myproject-swift.h a bridging header that shows up in your project and contains Objective-C declarations for use by Swift? Or is it Xcode-generated interface header (not listed as part of your project) containing declarations for use by Objective-C, so it can make use of your Swift code? If it's the latter, then it should not be called a bridging header. Just trying to understand your use of terminology. – Anatoli P Sep 20 '18 at 03:23
  • its an auto generated interface which contains Objective-C declarations for use by Swift @AnatoliP – Sanad Barjawi Sep 20 '18 at 05:50
  • Where's `ButtonBarPagerTabStripViewController` declared, and how? – Cristik Sep 26 '18 at 05:02
  • @Cristik its from a pod – Sanad Barjawi Sep 26 '18 at 05:59
  • And how about `ParentViewController`? How is that declared in Swift? Please add all the relevant information into the question, this will make it easier for people to understand the problem. – Cristik Sep 26 '18 at 06:02
  • The `ParentViewController` class conform from `ButtonBarPagerTabStripViewController ` ill edit the question right now, please make sure to check it @Cristik – Sanad Barjawi Sep 26 '18 at 06:33

2 Answers2

6

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

a.masri
  • 2,439
  • 1
  • 14
  • 32
  • can you please elaborate on this? – Iustin Ganea Apr 05 '22 at 14:57
  • This didn't work for me with a Swift package, but after adding -fmodules and -fcxx-modules to my build settings, I was able to use "@import MySwiftPackage;" before the -Swift.h bridging header import, and that DID work. – tcobbs May 16 '23 at 20:01
0

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>
Steve Ham
  • 3,067
  • 1
  • 29
  • 36