使用系统模块导入OpenGL头文件:https :
//github.com/apple/swift-package-
manager/blob/master/documentation/SystemModules.md
假设您的目录布局如下:
COpenGL/ Package.swift module.modulemap .git/YourApp/ Package.swift main.swift .git/
COpenGL / module.modulemap文件将类似于:
module COpenGL [system] { header "/usr/include/gl/gl.h" link "gl" export *}这必须在单独的git repo中创建,并带有一个version标签:
touch Package.swiftgit initgit add .git commit -m "Initial Commit"git tag 1.0.0
然后在YourApp / Package.swift文件中将其声明为依赖项
import PackageDescriptionlet package = Package( dependencies: [ .Package(url: "../COpenGL", majorVersion: 1) ])
然后可以在main.swift文件中将其导入:
import COpenGL// use opengl calls here...



