How to Modify Swift_Module_Name

How to modify SWIFT_MODULE_NAME?

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)",
);
},
...

iOS changing target name

Manage Schemes

Set Name

Just Click on your target Name beside stop button > Manage Schemes > Select and change name

Altered Name

Conversion to Swift 5 produces 'Multiple commands produce x86_64.swiftmodule' error

I was able to partly solve this issue by adjusting SWIFT_MODULE_NAME property in Test target.

My test's target SWIFT_MODULE_NAME was same as main target name, so i changed it

How to get the compiler to prefer my function over a Swift general function?

With function overloads, the compiler always prefers the most specialised version. If your function isn't more specialised than the built in one, but simply adds more input parameter with default input arguments, the compiler cannot distinguish it from the Swift standard library one.

You need to use names-acing and call your function with your own module name, like

MyModule.assert(1 == 2)

Objective C to Swift header file with multiple targets

It is also possible to set the Product Module Name setting in Build Settings to be the same across your modules (I set it to $(PROJECT_NAME)), so that the -Swift.h file that is generated has the same name across all modules. This eliminates the need for adding/checking preprocessor macros.

Static Library and Swift

As of Xcode 9 beta 4, Xcode natively supports static libraries with Swift sources.

Static Library and Swift

As of Xcode 9 beta 4, Xcode natively supports static libraries with Swift sources.

Adding Swift file to my project causes invalid module error

Since you're retrofitting Swift, please check:
SWIFT_MODULE_NAME under build settings in the target (and additionally at the project level perhaps if you have more targets).

It should be SOMETHING (versus blank), usually ${BUNDLE_DISPLAY_NAME} but you can hard-code it for starters.

There may be other settings like default module name for XIB also.



Related Topics



Leave a reply



Submit