I am trying to add swift 4 file in objective c project on Xcode 9. For that i am following these steps -
step 1: suppose swift class name is ShowAlertSwift.swift
import UIKit
@objc public class ShowAlertSwift: NSObject {
@objc func printSome() {
print("Print line System")
}
@objc func test () {
print("Test swift Class in objective C project")
}
}
step 2 : And the objective -c class first declare @class ShowAlertSwift
In objectiveClass.h I have followed these step
@class ShowAlertSwift
@interface ShowAlertSwift: NSObject
-(void)test;
-(void)printSome;
@end
@interface ViewController : UIViewController
@end
step 3 - In objectiveClass.m
#import "myproject-swift.h"
@interface UIViewController ()
{
}
@implementation
- (void)viewDidLoad
{
ShowAlertSwift *alertObj = [[ShowAlertSwift alloc]init];
[alertObj test];
}
I also set the following properties
Defines modules - Yes
Embedded_Content_Contains_Swift - Yes
Install Objective-C compatibility header - Yes
Objective C bridging header - $(SRCROOT)/Sources/SwiftBridging.h
Product Module Name - projectName
After all these stuff I am getting errors like
1. myproject-swift.h file not found
2. Consecutive statement on a line must be seprated by ';'
3. failed to emit precompiled header '/Users/xyz/pqr/Trunk/build/SharedPrecompiledHeaders/myproject-Bridging-Header-swift_1CBSOZ0HA1Z9R-clang_UESSBOJR5CSH.pch' for bridging header '/Users/xyz/pqr/Trunk/OpenPage2/com/myProject/login/Login_iPad/myProject-Bridging-Header.h'
Can any one has any idea how to resolve the issue on Xcode 9 in Swift 4 ?