In Swift, how to import a target with dash in its

2020-05-23 02:47发布

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?

标签: ios macos swift
1条回答
▲ chillily
2楼-- · 2020-05-23 03:01

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 .

查看更多
登录 后发表回答