# Swift6 private import and transitive dependencies

**URL:** <https://forums.swift.org/t/swift6-private-import-and-transitive-dependencies/78122>\
**Category:** Using Swift\
**Tags:** swift, swift6\
**Created:** [February 26, 2025, 8:00am UTC](https://forums.swift.org/t/swift6-private-import-and-transitive-dependencies/78122 "2025-02-26T08:00:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulTaykalo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/paultaykalo/32/23677_2.png) [@PaulTaykalo](https://forums.swift.org/u/PaulTaykalo)\
**Post date:** [February 26, 2025, 8:00am UTC](https://forums.swift.org/t/swift6-private-import-and-transitive-dependencies/78122/1 "2025-02-26T08:00:04Z")

</div>

It looks like in Swift6, `FRAMEWORK_SEARCH_PATHS` are required to point to all transitive dependencies

Long story short.

`Framework A` depends on `Framework B` dependes on `Framework P(private)`.  
`Framework P` is pre-build framework, which is located at some external directory, and can be found by adding `FRAMEWORK_SEARCH_PATHS` to the `Framework B` settings

We want to hide information about the existance of framework P.

In swift 5.9 with (`enable-experimental-feature AccessLevelOnImport`), and `private import P` in `Framework B`, `Framework A` was buliding successfully.  
Note: While everything was building just fine, it was clearly visible in generated module interface that `framework B` is using `framework P`

When switched to Swif6, now build fails on line

```swift
// In Framework A
import B // error: missing required module P

```

This error can be fixed by the adding `FRAMEWORK_SEARCH_PATHS` to the `Framework A` settings. But this is kind'a overkill, and disrupts the whole idea of hiding the dependency.

This error also can be fixed by adding `@_implementationOnly import P`. But then Swift compiler will give a warning that using '@\_implementationOnly' without enabling library evolution for `Framework P` may lead to instability during execution

[Here is](https://github.com/CocoaPods/CocoaPods/issues/12749) the most close-related issue to mine

Any help is appreciated. Thanks

---

<div class="post-metadata">

**Author:** ![brentley](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/brentley/32/40023_2.png) [@brentley](https://forums.swift.org/u/brentley)\
**Post date:** [March 14, 2025, 2:53pm UTC](https://forums.swift.org/t/swift6-private-import-and-transitive-dependencies/78122/2 "2025-03-14T14:53:20Z")

</div>

Ran into this as well. `@_implementationOnly import` worked for our use case because the private dep was an XCFramework with library evolution enabled. Ideally we could use `private import` instead.

---

<div class="post-metadata">

**Author:** ![PaulTaykalo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/paultaykalo/32/23677_2.png) [@PaulTaykalo](https://forums.swift.org/u/PaulTaykalo)\
**Post date:** [June 13, 2025, 6:50am UTC](https://forums.swift.org/t/swift6-private-import-and-transitive-dependencies/78122/3 "2025-06-13T06:50:35Z")

</div>

Okay. Here's what I found. In local project, Framework that have `private imports` needed to be compiled with `BUILD_LIBRARY_FOR_DISTRIBUTION` flag. In this case evertyhing works like a charm - no need pass framework search paths for transitive dependencies. Whether it is a bug or not - ¯\_(ツ)\_/¯ I'm not sure. @brentley may be this will help.
