# SPM System Library target functions not seen by Swift

**URL:** <https://forums.swift.org/t/spm-system-library-target-functions-not-seen-by-swift/17350>\
**Category:** Using Swift\
**Tags:** spm, system-library\
**Created:** [October 25, 2018, 12:34pm UTC](https://forums.swift.org/t/spm-system-library-target-functions-not-seen-by-swift/17350 "2018-10-25T12:34:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SwiftStudies](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/swiftstudies/32/5077_2.png) [@SwiftStudies](https://forums.swift.org/u/SwiftStudies)\
**Post date:** [October 25, 2018, 12:34pm UTC](https://forums.swift.org/t/spm-system-library-target-functions-not-seen-by-swift/17350/1 "2018-10-25T12:34:02Z")

</div>

I'm trying to create a Swifified version of the allegro game library (```brew install pkg-config allegro``) and it feels like I'm almost there but I'm missing a crucial step as the functions of the library aren't visible from the Swift side.

The package can be found here: [GitHub - SwiftStudies/Allegro: Swiftied version of the Allegro 5 C game library](https://github.com/SwiftStudies/Allegro)

I'm getting an error that al\_init() is an unresolved identifier. This is the only error I get from the build process (everything else... finding headers etc seems to work fine now)

As a quick test I added a string constant to the c header for the system library target and that is found and builds fine (see Allegro.version in Allegro.swift).

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [October 25, 2018, 3:51pm UTC](https://forums.swift.org/t/spm-system-library-target-functions-not-seen-by-swift/17350/2 "2018-10-25T15:51:38Z")

</div>

It looks like [`al_init` is a macro](https://www.allegro.cc/manual/5/al_init), not a real function. Swift only knows how to handle very simple macros at this time. However, you should be able to expand the macro yourself to handle this.

---

<div class="post-metadata">

**Author:** ![SwiftStudies](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/swiftstudies/32/5077_2.png) [@SwiftStudies](https://forums.swift.org/u/SwiftStudies)\
**Post date:** [October 25, 2018, 4:02pm UTC](https://forums.swift.org/t/spm-system-library-target-functions-not-seen-by-swift/17350/3 "2018-10-25T16:02:37Z")

</div>

Oh thank you. It's been so long since I've done any C I had forgotten how you don't really know what anything is!

---

<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:** [October 25, 2018, 4:06pm UTC](https://forums.swift.org/t/spm-system-library-target-functions-not-seen-by-swift/17350/4 "2018-10-25T16:06:10Z")

</div>

A useful trick is looking at the swift interface of the C library by generating an Xcode project using `swift package generate-xcodeproj`.

---

<div class="post-metadata">

**Author:** ![SwiftStudies](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/swiftstudies/32/5077_2.png) [@SwiftStudies](https://forums.swift.org/u/SwiftStudies)\
**Post date:** [October 25, 2018, 4:40pm UTC](https://forums.swift.org/t/spm-system-library-target-functions-not-seen-by-swift/17350/5 "2018-10-25T16:40:02Z")

</div>

I love that idea... but really dumb question... once in Xcode how do I do that? The generated project is excluding the c/h files, so I can't see them there... and the only "Product" is the final framework which doesn't expose any of these things...

What am I not seeing?

---

<div class="post-metadata">

**Author:** ![SwiftStudies](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/swiftstudies/32/5077_2.png) [@SwiftStudies](https://forums.swift.org/u/SwiftStudies)\
**Post date:** [October 25, 2018, 4:41pm UTC](https://forums.swift.org/t/spm-system-library-target-functions-not-seen-by-swift/17350/6 "2018-10-25T16:41:20Z")

</div>

Forget it! Right click on the CAllegro import!

Thank you SO much... pro tip!!!
