Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift & Objective-C project - generated -Swift.h error - Cannot find interface declaration for UIViewController

I've got a project using the Swift generated Bridging Header and have the project set up correctly (no spaces in Names, Uses Modules, pre-declaring Swift classes in my .mm file, Deleting derived data, doing a clean rebuild etc...). The Bridging Header is being generated fine, but the automatically generated -Swift.h has errors in it. What's even worse, those errors are on the generated (in project creation - Swift) versions of AppDelegate and ViewController which would normally compile fine. The errors in the -Swift.h are:

  • @interface AppDelegate : UIResponder <UIApplicationDelegate>
    >> Cannot find interface declaration for 'UIResponder', superclass of 'AppDelegate'
    >> Cannot find protocol declaration for 'UIApplicationDelegate'
  • @interface ViewController : UIViewController
    >> Cannot find interface declaration for 'UIViewController', superclass of 'ViewController'

I've searched Stack Overflow and the net and can't find any answer that addresses this particular issue. Has anyone else had this? Or, is there a way I can mark my AppDelegate and ViewController classes so Xcode doesn't try and create Objective-C stubs for those Swift classes as I don't actually need them?

like image 479
Richard West Avatar asked Mar 26 '15 18:03

Richard West


People also ask

What SWIFT means?

SWIFT is an acronym for the Society for Worldwide Interbank Financial Telecommunications and may also be referred to as a CIC code.

Which country owns SWIFT?

SWIFT is a cooperative company under Belgian law and is owned and controlled by its shareholders (financial institutions) representing approximately 2,400 Shareholders from across the world.

What is SWIFT system in banking?

SWIFT – or the Society for Worldwide International Financial Telecommunications – is a system that banks use to securely send messages to each other. It is one of the key pillars of the financial world, connecting more than 11,000 member banks in some 200 countries and territories globally.

What is SWIFT and how does it work?

The SWIFT payment network allows individuals and businesses to accept/send international money via electronic or credit card payments. This can be done even if the customer or vendor uses a different bank than the payee. The network is a place for secure financial messaging.

What is swift?

Swift is a powerful and intuitive programming language for macOS, iOS, watchOS, tvOS and beyond.

What is Swift language used for?

Swift is a powerful and intuitive programming language for macOS, iOS, watchOS and tvOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and Swift includes modern features developers love. Swift code is safe by design, yet also produces software that runs lightning-fast.

What is swift code ISO 9362?

Swift Code, BIC Code, ISO 9362. BIC sometimes also refers to “Bank Identifier Code”. Swift Code or BIC Code is a unique code to identify financial and non-financial institutions. These codes are mostly used when transferring money between banks, especially for international wire transfers or telegraphic transfer (“TT”).

Why write Swift code?

Writing Swift code is interactive and fun, the syntax is concise yet expressive, and Swift includes modern features developers love. Swift code is safe by design, yet also produces software that runs lightning-fast.


2 Answers

Just add

#import <UIKit/UIKit.h>

before

#import <YourProject-Swift.h>

in .mm file. for me it helps.

like image 149
Timofey Konshin Avatar answered Sep 22 '22 05:09

Timofey Konshin


I had same problem and discovered that..

-Swift.h only work best with Objective-C, not Objective-C++ (.mm)

So I use the Objective-C class to connect with the Swift class. Also You can always load your Objective-C++ class in your Objective-C class.

like image 25
Paul Sweeney Avatar answered Sep 23 '22 05:09

Paul Sweeney