This might be something very basic yet I just can't find the answer...
Say I have two targets in my Xcode project: foo-bar and foo-barTests
now if I want to make an identifier from foo-bar visible in foo-barTests, how do I import it?
To import a set of Objective-C files into Swift code within the same app target, you rely on an Objective-C bridging header file to expose those files to Swift. Xcode offers to create this header when you add a Swift file to an existing Objective-C app, or an Objective-C file to an existing Swift app.
When importing Foundation (or anything else like Cocoa or UIKit that will import it implicitly) Swift automatically converts some Objective-C types to Swift types, and some Swift types to Objective-C types, and a number of data types in Swift and Objective-C can be used interchangeably.
Product Module Name(PRODUCT_MODULE_NAME) determines how the import statement will look like. For example when you are creating a Library or a Framework . Using: //Objective-C @import module_name; //Swift import module_name. Product Name(PRODUCT_NAME) determines the name of binary.
Okay it was very basic:
Naming Your Product Module
The name of the Xcode-generated header for Swift code, and the name of the Objective-C bridging header that Xcode creates for you, are generated from your product module name. By default, your product module name is the same as your product name. However, if your product name has any non-alphanumeric characters, such as a period (.), they are replaced with an underscore (_) in your product module name. If the name begins with a number, the first number is replaced with an underscore.
You can also provide a custom name for the product module name, and Xcode will use this when naming the bridging and generated headers. To do this, change the Product Module Name build setting.
so import foo-bar
becomes import foo_bar
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With