[swift-users] Wrapping ImageMagick in a Swift Package

Toni Suter tonisuter at me.com
Tue Oct 3 02:32:32 CDT 2017


I am trying to create a Swift Package that wraps the ImageMagick C API. So I installed ImageMagick using MacPorts and
I was then able to build the sample program with the following commands:

export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
cc main.c `pkg-config --cflags --libs MagickWand`

Then I created a package with the command "swift package init --type=system-module" and I modified Package.swift to look
like this:

// swift-tools-version:4.0

import PackageDescription

let package = Package(
	name: "TestPkg",
	pkgConfig: "MagickWand"

and I modified module.modulemap to the following:

module TestPkg [system] {
  header "/opt/local/include/ImageMagick-6/wand/MagickWand.h"
  link "MagickWand-6.Q16"
  link "MagickCore-6.Q16"
  export *

Now when I run "swift build", I get the following error message:

<unknown>:0: error: unexpected 'commands' value (expected map)
<unknown>:0: error: unable to load build file
error: terminated(1): /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-27-a.xctoolchain/usr/bin/swift-build-tool -f /Users/tonisuter/Desktop/TestPkg/.build/debug.yaml main

Does anybody know how I can fix this error?

Thanks and best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171003/90e5e069/attachment.html>

More information about the swift-users mailing list