# Import Foundation failed

**URL:** <https://forums.swift.org/t/import-foundation-failed/80461>\
**Category:** Using Swift\
**Tags:** foundation, embedded\
**Created:** [June 14, 2025, 8:05am UTC](https://forums.swift.org/t/import-foundation-failed/80461 "2025-06-14T08:05:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![typoland](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/typoland/32/3982_2.png) [@typoland](https://forums.swift.org/u/typoland)\
**Post date:** [June 14, 2025, 8:05am UTC](https://forums.swift.org/t/import-foundation-failed/80461/1 "2025-06-14T08:05:42Z")

</div>

I try to go thru Baremetal example ([Documentation](https://docs.swift.org/embedded/documentation/embedded/stm32baremetalguide)) and after some not so smooth digging, almost at the end of setup process and few minutes of compiling I got an error (!):

```swift
Building for production...
/Users/lukasz/Documents/STM32/STM32BlinkLed/.build/checkouts/swift-mmio/Sources/MMIO/FixedWidthInteger+Bits.swift:12:8: error: no such module 'Foundation'
10 | //===----------------------------------------------------------------------===//
11 | 
12 | import Foundation
   | `- error: no such module 'Foundation'
13 | 
14 | extension FixedWidthInteger {

```

How it's even possible?

I have a fresh:

```swift
% swift --version
Apple Swift version 6.2-dev (LLVM d266fd9f80a7945, Swift 665515c781999a8)
Target: arm64-apple-macosx15.0
Build config: +assertions

```

I have no idea where to dig now.

---

<div class="post-metadata">

**Author:** ![filip-sakel](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/filip-sakel/32/8697_2.png) [@filip-sakel](https://forums.swift.org/u/filip-sakel)\
**Post date:** [June 14, 2025, 4:27pm UTC](https://forums.swift.org/t/import-foundation-failed/80461/2 "2025-06-14T16:27:46Z")

</div>

I don't think Foundation currently supports Embedded mode. You can definitely use the swift standard library (implicitly imported `Swift` module), including parts of the Concurrency module. However, last time I checked, Foundation wasn't supported. That's because Foundation relies on several system APIs that don't come out of the box with Embedded environments, not to mention the use of features like existential `any` for protocols.

---

<div class="post-metadata">

**Author:** ![typoland](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/typoland/32/3982_2.png) [@typoland](https://forums.swift.org/u/typoland)\
**Post date:** [June 14, 2025, 5:31pm UTC](https://forums.swift.org/t/import-foundation-failed/80461/3 "2025-06-14T17:31:43Z")

</div>

Error comes from MMIO package, it's hard to avoid it...

---

<div class="post-metadata">

**Author:** ![rauhul](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rauhul/32/35207_2.png) [@rauhul](https://forums.swift.org/u/rauhul)\
**Post date:** [June 14, 2025, 6:07pm UTC](https://forums.swift.org/t/import-foundation-failed/80461/4 "2025-06-14T18:07:15Z")

</div>

@typoland Apologies for this, I recently refactored that code out of a different file and Xcode "helpfully" added `import Foundation` when I created the file. Removing the import is the correct solution and I'll put up a PR to resolve this right now.

I'm also looking into a general solution for embedded CI testing for swiftlang repos to avoid breaks like this in the future.

edit: [Remove spurious foundation import by rauhul · Pull Request #168 · apple/swift-mmio · GitHub](https://github.com/apple/swift-mmio/pull/168)

edit 2: merged
