Search code examples
swiftuiviewios9mbprogresshudbridging-header

Cannot find interface declaration for 'UIView' in iOS Swift Project


I have a swift project which I'm making use of MBProgressHUD in through a Bridging header file. The issue I'm having is that UIView doesn't appear to be recognised as type and I don't know why.

In my bridging header I have:

#import "MBProgressHUD.h"

The errors I get when I try to build are all along the same lines:

Cannot find interface declaration for 'UIView', superclass of MBProgressHUD.

I have checked the MBProgressHUD file and I can see that it definitely imports the following:

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>

#import "MBProgressHUD.h"
#import "CSNotificationView.h"

Has anyone else seen a similar issue? If so do you know what the issue is and how can I fix it?


Solution

  • I also come across the same issue and thats what i did to use MBProgressHud with swift 2

    1) Specify use_frameworks! in your Podfile to use frameworks.

    2) Add #import in your bridging header, use angle brackets instead of double quotes e.g -

    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
    #import <CoreGraphics/CoreGraphics.h>
    #import <MBProgressHUD/MBProgressHUD.h>
    

    3) in your swift file also import MBProgressHUD e.g.

    import UIKit
    import MBProgressHUD
    

    Now you can use MBProgressHud like -

    MBProgressHUD.showHUDAddedTo(self.view, animated: true);
    

    Hope it will help.