在Swift中,如何导入名称中带有破折号的目标? [英] In Swift, how to import a target with dash in its name?

查看:137
本文介绍了在Swift中,如何导入名称中带有破折号的目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是非常基本的东西,但我只是找不到答案...

This might be something very basic yet I just can't find the answer...

假设我的Xcode项目中有两个目标:foo-bar和foo-barTests

Say I have two targets in my Xcode project: foo-bar and foo-barTests

现在,如果我想使foo-barTests中的foo-bar标识符可见,如何导入它?

now if I want to make an identifier from foo-bar visible in foo-barTests, how do I import it?

推荐答案

非常

命名您的产品模块

Xcode生成的Swift代码标头的名称,以及Xcode为您创建的Objective-C桥接标头的名称,都是从您的产品模块名称生成的.默认情况下,您的产品模块名称与您的产品名称相同. 但是,如果您的产品名称包含任何非字母数字字符,例如句点(.),则会在产品模块名称中将其替换为下划线(_).如果名称以数字开头,则第一个数字将替换为下划线.

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.

您还可以为产品模块名称提供自定义名称,Xcode在命名桥接和生成的标头时将使用该名称.为此,请更改产品模块名称"构建设置.

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.

因此import foo-bar变为import foo_bar.

这篇关于在Swift中,如何导入名称中带有破折号的目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆