How to modify SWIFT_MODULE_NAME?

2019-04-25 19:08发布

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.

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:

$(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.

But, where is this value defined, and how do I modify it?

3条回答
做个烂人
2楼-- · 2019-04-25 19:18

Go to build Settings and click + next to 'Levels'. See :

enter image description here

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.

查看更多
smile是对你的礼貌
3楼-- · 2019-04-25 19:23

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

See the screenshot:

enter image description here

查看更多
老娘就宠你
4楼-- · 2019-04-25 19:34

The module name comes from the Product Module Name build setting:

build settings screenshot

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:

...
{
    Name = "SWIFT_MODULE_NAME";
    Type = String;
    DefaultValue = "$(PRODUCT_MODULE_NAME)";
    CommandLineArgs = (
        "-module-name",
        "$(value)",
    );
},
...
查看更多
登录 后发表回答