Claudio Claudio - 4 months ago 147
Swift Question

Error message 'Expected ; after top level declarator ' 'Unknown type name import' with the bridge to use Swift in Objective-C

I Have a message error when I try to add a bridge to use Swift in Objective-C.

Here is my code :

import UIKit

@objc class ScanViewController : UIViewController, IRLScannerViewControllerDelegate
var scan: Int = 0 //FIXME:delegate to put in swift
var category: String = "" //FIXME:delegate to put in swift

Here is my bridge in Swift :

// Bridging.swift
// Created by OlostA on 10/06/2016.

import Foundation
import UIKit

@objc class Hello: NSObject {
func sayHello() {
print("Hi there!")

Here is my Objective-C file :

#import "CategoryViewController.h"
#import "ScanViewController.swift"
#import "GoFact-Swift.h"
@interface CategoryViewController ()
@implementation CategoryViewController

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
if ([[segue identifier] isEqualToString:@"yourSegueIdentifier"])
ScanViewController *destViewController = segue.destinationViewController;
destViewController.category = sender;

Any idea?


You have to remove

#import "ScanViewController.swift"

It should be ok then.