# Swift module support

**URL:** https://discourse.cmake.org/t/swift-module-support/5195
**Category:** Usage
**Tags:** os:macos, gen:xcode
**Created:** [March 9, 2022, 2:29pm UTC](https://discourse.cmake.org/t/swift-module-support/5195 "2022-03-09T14:29:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Lectem](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lectem/32/380_2.png) [@Lectem](https://discourse.cmake.org/u/Lectem)
#### Post date: [March 9, 2022, 2:29pm UTC](https://discourse.cmake.org/t/swift-module-support/5195/1 "2022-03-09T14:29:11Z")

</div>

I’m trying to build a project using Swift with the Xcode generator, but I can not get it to import a class from another target (that is correctly linked).

I also tried this example [swift-cmake-examples/HelloWorld at main · compnerd/swift-cmake-examples · GitHub](https://github.com/compnerd/swift-cmake-examples/tree/main/HelloWorld) which suggests that it should be working, but they are using Ninja.

When using Xcode I get the following error:

> dev/swift-cmake-examples/HelloWorld/Source/HelloWorld/HelloWorld.swift:2:8: error: no such module ‘HelloWorldCore’  
> import HelloWorldCore  
> ^

Is this a bug in the generator ?  
If not, how does one import a module created by CMake ?

EDIT: I managed to make it build by adding the build directory in Build Settings \> Swift Compiler - Search Paths \> Import Paths. So it is probably a bug that this is not properly set by CMake? This is the `SWIFT_INCLUDE_PATHS` Xcode attribute

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [November 3, 2022, 12:16pm UTC](https://discourse.cmake.org/t/swift-module-support/5195/2 "2022-11-03T12:16:44Z")

</div>

I just added generation of `SWIFT_INCLUDE_PATHS` as part of the fix in [CMake MR 7858](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7858). It will be in CMake 3.25.0.
