Hi community,
I've tried to import modules from external packages.
The two modules have same name bar
.
The MyLib/bar
is a swift module.
The MyLib2/bar
is a systemLibrary module in C language.
So, I tried the module aliases. But it seems that the module aliasing
works differently on systemLibrary than normal swift module. For normal
swift modules with same names, I need to give different aliases to all
the modules. For systemLibrary, its alias name can not be used for import
and its alias can be omitted.
$ tree --charset C
.
|-- MyApp
| |-- Package.swift
| `-- Sources
| `-- MyApp
| `-- MyApp.swift
|-- MyLib
| |-- Package.swift
| `-- Sources
| `-- bar
| `-- bar.swift
`-- MyLib2
|-- Package.swift
`-- Sources
|-- Makefile
|-- MyLib
| `-- MyLib.swift
|-- bar
| |-- Makefile
| |-- bar.c
| |-- bar.h
| `-- module.modulemap
`-- build
`-- bar
|-- bar
|-- bar.d
|-- bar.o
|-- libbar.1.2.3.dylib
|-- libbar.1.dylib -> libbar.1.2.3.dylib
`-- libbar.dylib -> libbar.1.2.3.dylib
$
.executableTarget(
name: "MyApp",
dependencies: [
.product(name: "bar", package: "MyLib", moduleAliases: ["bar": "bar1"]),
.product(name: "bar", package: "MyLib2"),
]
),
// MyLib
.library( name: "bar", targets: ["bar"]),
.target( name: "bar", dependencies: []),
// MyLib2
.library( name: "bar", targets: ["bar"]),
.systemLibrary( name: "bar"),