# Using Library Evolution in a versioned package

**URL:** <https://forums.swift.org/t/using-library-evolution-in-a-versioned-package/63486>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [March 2, 2023, 6:21pm UTC](https://forums.swift.org/t/using-library-evolution-in-a-versioned-package/63486 "2023-03-02T18:21:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bnickel](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bnickel/32/7804_2.png) [@bnickel](https://forums.swift.org/u/bnickel)\
**Post date:** [March 2, 2023, 6:21pm UTC](https://forums.swift.org/t/using-library-evolution-in-a-versioned-package/63486/1 "2023-03-02T18:21:15Z")

</div>

I had an issue a while back with an XCFramework depending on a Swift Package, where the solution was to enable Library Evolution in the dependency.

> [@Prevent optimizing away public interfaces needed by an XCFramework (aka dyld: Symbol not found)](https://forums.swift.org/t/prevent-optimizing-away-public-interfaces-needed-by-an-xcframework-aka-dyld-symbol-not-found/63162/2):
>
> I've found a solution, based on the following lead: While I don't know exactly what's causing the cross-module symbol culling, enabling library evolution does appear to fix the problem: .target( name: "HeapSwiftCore", dependencies: [.product(name: "SwiftProtobuf", package: "swift-protobuf"),], swiftSettings: [ .unsafeFlags([ "-enable-library-evolution", "-emit-mod…

The target looks like this:

```swift
        .target(
            ...
            swiftSettings: [
                // Emulate BUILD_LIBRARY_FOR_DISTRIBUTION to prevent culling of ABI used by
                // compiled frameworks.
                .unsafeFlags([
                    "-enable-library-evolution",
                    "-emit-module-interface"
                ]),
            ]),

```

The following works when using the package as a dependency:

```swift
    dependencies: [
        .package(url: "...", branch: "main"),
    ],

```

The following fails:

```swift
    dependencies: [
        .package(url: "...", from: "0.0.2"),
    ],

```

```swift
    dependencies: [
        .package(url: "...", exact: "0.0.2"),
    ],

```

Both produce the following error:

> xcodebuild: error: Could not resolve package dependencies:  
> the target 'PackageName' in product 'PackageName' contains unsafe build flags

Am I doing this right? Is there a different way to trigger full ABI generation in a package or one that doesn't use unsafe flags?

I'm pretty sure I can repackage the XCFramework without specifying a dependency, but that seems worse since errors won't be detected until the app runs and fails to resolve symbols.

---

<div class="post-metadata">

**Author:** ![lukasa](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lukasa/32/1232_2.png) [@lukasa](https://forums.swift.org/u/lukasa)\
**Post date:** [March 4, 2023, 10:16am UTC](https://forums.swift.org/t/using-library-evolution-in-a-versioned-package/63486/2 "2023-03-04T10:16:07Z")

</div>

Unsafe flags are not supported in stable library dependencies (that is, those that use version numbers). I believe this is intentional behaviour.
