I tried to run the hello-window-1 example from the examples repository by naively typing swift run but got the following error:
[...]/01-hello-window-1$ swift run
[...]
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "shim.h"
^
[...]/01-hello-window-1/.build/checkouts/CGLFW3.git-2014552659416122263/shim.h:5:10: error: 'GLFW/glfw3.h' file not found
#include "GLFW/glfw3.h"
^
[...]/01-hello-window-1/main.swift:4:8: error: could not build Objective-C module 'CGLFW3'
import CGLFW3
^
error: terminated(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f [...]/01-hello-window-1/.build/debug.yaml example.exe
I installed glfw using MacPorts. Adding the include and library directories on the command line solves the problem and let's the example run without modification: swift run -Xswiftc -I/opt/local/include -Xlinker -L/opt/local/lib. But this kinda sucks because I have to remember adding those options whenever I want to build or run my projects and Xcode does not automatically know about those directories either and I have to configure it there too.
I'm a complete novice when it comes to Swift package management but I noticed that adding pkgConfig: "glfw3" to CGLFW3's Package.swift allows me to run the example with just swift run and from within the generated Xcode project without any adjustments.
diff --git a/Package.swift b/Package.swift
index e1f46ee..cc1bbd3 100644
--- a/Package.swift
+++ b/Package.swift
@@ -1,5 +1,6 @@
import PackageDescription
let package = Package(
- name: "CGLFW3"
+ name: "CGLFW3",
+ pkgConfig: "glfw3"
)
Is there any downside to this? Otherwise it would IMHO greatly improve the experience of using this library on macOS.
I tried to run the
hello-window-1example from the examples repository by naively typingswift runbut got the following error:I installed
glfwusing MacPorts. Adding the include and library directories on the command line solves the problem and let's the example run without modification:swift run -Xswiftc -I/opt/local/include -Xlinker -L/opt/local/lib. But this kinda sucks because I have to remember adding those options whenever I want to build or run my projects and Xcode does not automatically know about those directories either and I have to configure it there too.I'm a complete novice when it comes to Swift package management but I noticed that adding
pkgConfig: "glfw3"toCGLFW3'sPackage.swiftallows me to run the example with justswift runand from within the generated Xcode project without any adjustments.Is there any downside to this? Otherwise it would IMHO greatly improve the experience of using this library on macOS.