How to modify SWIFT_MODULE_NAME?

前端 未结 4 1158
灰色年华
灰色年华 2020-11-27 07:14

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

相关标签:
4条回答
  • 2020-11-27 07:21

    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:

    0 讨论(0)
  • 2020-11-27 07:22

    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.

    0 讨论(0)
  • 2020-11-27 07:42

    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.

    By default it is equals to PRODUCT_NAME. (The name matching is a requirement)

    Default values:

    • Product Name : $(TARGET_NAME:c99extidentifier)
    • Product Module Name : $(PRODUCT_NAME:c99extidentifier)

    This value can be changed by .modulemap using Objective-C

    Using:

    //Objective-C
    @import module_name; 
    
    //Swift
    import module_name 
    

    [import and modulemap]

    0 讨论(0)
  • 2020-11-27 07:43

    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:

    ...
    {
        Name = "SWIFT_MODULE_NAME";
        Type = String;
        DefaultValue = "$(PRODUCT_MODULE_NAME)";
        CommandLineArgs = (
            "-module-name",
            "$(value)",
        );
    },
    ...
    
    0 讨论(0)
提交回复
热议问题