xcode 如何修改 SWIFT_MODULE_NAME?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36611724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to modify SWIFT_MODULE_NAME?
提问by Sheamus
The title says it all. I've searched in the build settings for SWIFT_MODULE_NAME, and nothing came up. I've also searched online, and there are references to this name, but there is no information on how it is defined. Furthermore, I couldn't find any mention of SWIFT_MODULE_NAME in the Apple Docs.
标题说明了一切。我在构建设置中搜索了SWIFT_MODULE_NAME,但没有任何结果。我也在网上搜索过,有提到这个名字,但是没有关于它是如何定义的信息。此外,我在 Apple 文档中找不到任何提及 SWIFT_MODULE_NAME 的内容。
I do know this: it is used in the "Objective-C Generated Interface Header Name" build setting, and can be viewed by double-clicking on the settings value:
我知道这一点:它用于“Objective-C Generated Interface Header Name”构建设置,可以通过双击设置值来查看:
$(SWIFT_MODULE_NAME)-Swift.h
$(SWIFT_MODULE_NAME)-Swift.h
It is used to bridge the gap between Objective-C and Swift, and appears only for projects that include Swift files, (along with Objective-C files I presume). As of this posting, Xcode 7.3 is the latest and greatest.
它用于弥合 Objective-C 和 Swift 之间的差距,并且仅出现在包含 Swift 文件的项目中(以及我认为的 Objective-C 文件)。在这篇文章中,Xcode 7.3 是最新和最棒的。
But, where is this value defined, and how do I modify it?
但是,这个值在哪里定义,我该如何修改它?
回答by jtbandes
The module name comes from the Product Module Name build setting:
模块名称来自产品模块名称构建设置:
The SWIFT_MODULE_NAME
setting is apparently hidden, but you can see its derivation by looking at Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/XCLanguageSupport.xcplugin/Contents/Resources/Swift.xcspec
:
该SWIFT_MODULE_NAME
设置显然是隐藏的,但您可以通过查看以下内容来了解其派生Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/XCLanguageSupport.xcplugin/Contents/Resources/Swift.xcspec
:
...
{
Name = "SWIFT_MODULE_NAME";
Type = String;
DefaultValue = "$(PRODUCT_MODULE_NAME)";
CommandLineArgs = (
"-module-name",
"$(value)",
);
},
...
回答by Anton Tropashko
Go to build Settings and click + next to 'Levels'. See :
转到构建设置并单击“级别”旁边的 +。看 :
replace NEW_SETTING as SWIFT_MODULE_NAME for the name of the setting, and whatever is the module name for .h file (No spaces, please) goes on the right.
将 NEW_SETTING 替换为 SWIFT_MODULE_NAME 作为设置的名称,无论 .h 文件的模块名称是什么(请不要空格)在右边。
回答by yoAlex5
Build Settings
contains Product Module Name
that determines what the import
statement will look like when used. For example when you are creating a Library
or a Framework
.
Build Settings
包含Product Module Name
决定import
语句在使用时的样子。例如,当您创建一个Library
或一个Framework
.
By default it is equals to PRODUCT_NAME
. (The name matching is a requirement)
默认情况下它等于PRODUCT_NAME
。(姓名匹配为必填项)
Default values:
默认值:
Product Name
:$(TARGET_NAME:c99extidentifier)
Product Module Name
:$(PRODUCT_NAME:c99extidentifier)
Product Name
:$(TARGET_NAME:c99extidentifier)
Product Module Name
:$(PRODUCT_NAME:c99extidentifier)
This value can be changed by .modulemap
using Objective-C
这个值可以通过.modulemap
使用 Objective-C来改变
Using:
使用:
//Objective-C
@import module_name;
//Swift
import module_name
回答by Zhao
Have you checked out this doc: developer.apple.com/library/ios/documentation/Swift/Conceptual/… ? usually it is your product name. You can set change the value in "Product Bundle Identifier" in Build Settings. Note you can not override a product name in a Framework
您是否查看过此文档:developer.apple.com/library/ios/documentation/Swift/Conceptual/...?通常是您的产品名称。您可以在 Build Settings 的“Product Bundle Identifier”中设置更改值。请注意,您不能覆盖框架中的产品名称
See the screenshot:
看截图: