Adding Swift Unit Tests to a Mixed Language Xcode Project
Answer provided by https://twitter.com/UINT_MIN
In my case the both targets (the application and the tests) had the same module name in the build settings. Changing the module name of the test target resolved the issue.
Call an Objective-C class from a Swift test file
You need to create bridging header and add Objective-C file in to that.
Create a bridging header YourProductName-Bridging-Header.h
and then import HomeViewController
in bridging header.
To import Objective-C code into Swift from the same target
In your Objective-C bridging header file, import every Objective-C
header you want to expose to Swift. For example:#import "XYZCustomCell.h"
#import "XYZCustomView.h"
#import "XYZCustomViewController.h"In Build Settings, in Swift Compiler - Code Generation, make sure the Objective-C Bridging Header
build setting under has a path to the bridging header file. The path
should be relative to your project, similar to the way your Info.plist
path is specified in Build Settings. In most cases, you should not
need to modify this setting.
Below are some resources which can help you
- Using Swift with Objective-C
- Answer to another stack overflow qustion
- How to use Objective-C in swift
Related Topics
Info.Plist Utility Error: "Info.Plist Couldn't Be Opened Because There Is No Such File"
Cllocationmanager Responsiveness
Restkit and Saving to Coredata as Nsmanagedobject
Is the Current Location/Compass Heading Button Available in the iOS Sdk
Alphabetical Sections in Table Table View in Swift
iPhone Opengl Es 2.0 - Pixel Perfect Textures
"This App Is Not Allowed to Query for Scheme Cydia" iOS9 Error
How to Convert a Kcvpixelformattype_420Ypcbcr8Biplanarfullrange Buffer to Uiimage in iOS
How to Properly Use Class Extensions in Swift
How to Customize Uirefreshcontrol with Different Image and Position
How to Import Existing Objective C Classes in Swift
iOS 11+ How to Migrate Existing Core Data to Shared App Group for Use in Extension
iOS Uicollectionview - Default Flow, Fill Rows from Right to Left
Detect Uiimageview Touch in Swift
Opening Testflight App from Another App and Deep Link to Specific App
How to Draw a Non-Rectangle Uitextview
Uilabel: Background Dependent Color
Is It Just the iPhone Simulator That Is Restricted to Intel Only MAC'S