Hi .. I have created dynamic library in swift . After inspecting dynamic library by following command
nm -u filename.dylib
Name of the function in .dylib is different from the .swift file for example
In swift file it is like
swiftfun
In dynamic lib file
5tswiftfunYjsdbfhsdf
Swift uses mangled names as they are a full representation of the resolved name of a symbol (which include module, namespaces, name, arguments, etc). You might want to read about its rules here.
Yes, @_cdecl is the way to do this today. Be aware that, as with any underscored attribute, there is no guarantee that it will continue to be supported in the future (it may be renamed or removed, or its semantics may change in a future version of Swift; renaming is by far the most likely possibility), so any code using it is not source-stable.