# Problem with new Package Manager System Library Targets

**URL:** <https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358>\
**Category:** Using Swift\
**Tags:** spm\
**Created:** [September 21, 2018, 7:43pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358 "2018-09-21T19:43:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![freda](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@freda](https://forums.swift.org/u/freda)\
**Post date:** [September 21, 2018, 7:43pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/1 "2018-09-21T19:43:06Z")

</div>

With the introduction of Swift 4.2 I got a deprecation warning stating that I have to use a system library:

```swift
warning: system packages are deprecated; use system library targets instead

```

The library that was being linked was a library that did not really link a library, it just loaded a header file which I needed to do some low level network requests. So the `module.modulemap` used to contain:

```nohighlight
module Network [system] {
    header </usr/include/ifaddrs.h>
    export *
}

```

The `Package.swift` file contained:

```swift
// swift-tools-version:3.1

import PackageDescription

let package = Package(name: "Network")

```

It seems, if I read the [SPM System Library Target](https://github.com/apple/swift-evolution/blob/master/proposals/0208-package-manager-system-library-targets.md) correctly there is no longer an option to specify the header.

Am I missing something or is this still possible in 4.2? Or have we removed this possibility with this release?

Any advise would be appreciated.

---

<div class="post-metadata">

**Author:** ![Aciid](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aciid/32/429_2.png) [@Aciid](https://forums.swift.org/u/Aciid)\
**Post date:** [September 21, 2018, 8:42pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/2 "2018-09-21T20:42:32Z")

</div>

You need to update the manifest file and declare a system library target. The new manifest will probably look something like:

```swift
// swift-tools-version:4.2

import PackageDescription

let package = Package(
    name: "Network",
    products: [
        .library(name: "Network", targets: ["Network"]),
    ],
    targets: [
        .systemLibrary(name: "Network", path: "."),
    ]
)

```

---

<div class="post-metadata">

**Author:** ![freda](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@freda](https://forums.swift.org/u/freda)\
**Post date:** [September 21, 2018, 8:44pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/3 "2018-09-21T20:44:15Z")

</div>

Thanks for your response. But where would I specify `/usr/include/ifaddrs.h`?

---

<div class="post-metadata">

**Author:** ![Aciid](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aciid/32/429_2.png) [@Aciid](https://forums.swift.org/u/Aciid)\
**Post date:** [September 21, 2018, 8:45pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/4 "2018-09-21T20:45:10Z")

</div>

In the same module.modulemap file, that part hasn't changed.

---

<div class="post-metadata">

**Author:** ![freda](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@freda](https://forums.swift.org/u/freda)\
**Post date:** [September 21, 2018, 9:02pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/5 "2018-09-21T21:02:52Z")

</div>

So I have made the changes as you suggested and get the following errors when I use the library:

```nohighlight
warning: Ignoring declared target(s) 'Network' in the system package
warning: system packages are deprecated; use system library targets instead

```

So it doesn't recognize that this is a system library. I tried removing the product section, given that I don't really build a library. It is all about the header nothing else. No luck. The message is identical.

---

<div class="post-metadata">

**Author:** ![Aciid](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aciid/32/429_2.png) [@Aciid](https://forums.swift.org/u/Aciid)\
**Post date:** [September 21, 2018, 9:05pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/6 "2018-09-21T21:05:52Z")

</div>

Oh I think you also need to move the modulemap to a directory under Sources. So the modulemap file should be at:

```swift
<pkg>/Sources/Network/module.modulemap

```

---

<div class="post-metadata">

**Author:** ![freda](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@freda](https://forums.swift.org/u/freda)\
**Post date:** [September 21, 2018, 9:25pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/7 "2018-09-21T21:25:57Z")

</div>

Thanks. I got it working. I had to remove the path in `systemLibrary` definition.

---

<div class="post-metadata">

**Author:** ![Aciid](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aciid/32/429_2.png) [@Aciid](https://forums.swift.org/u/Aciid)\
**Post date:** [September 21, 2018, 9:27pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/8 "2018-09-21T21:27:16Z")

</div>

Great!

---

<div class="post-metadata">

**Author:** ![joesus](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joesus/32/24541_2.png) [@joesus](https://forums.swift.org/u/joesus)\
**Post date:** [August 12, 2019, 3:40pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/9 "2019-08-12T15:40:22Z")

</div>

Side note. I ran into this error while trying to code along with the examples at:

> <https://github.com/apple/swift-package-manager/blob/main/Documentation/Usage.md>

Specifically the line `swift package init --type system-module` Is it possible to update these docs? I would update them myself and open a PR but as somebody just at the tutorials phase of this I'm not sure I'm qualified to write the tutorial yet. 😛

---

<div class="post-metadata">

**Author:** ![vine](https://avatars.discourse-cdn.com/v4/letter/v/6bbea6/32.png) [@vine](https://forums.swift.org/u/vine)\
**Post date:** [March 21, 2022, 3:45pm UTC](https://forums.swift.org/t/problem-with-new-package-manager-system-library-targets/16358/10 "2022-03-21T15:45:11Z")

</div>

Is there an update now?
