简体   繁体   English

使用Swift Package Manager时出错

[英]Error while using Swift Package Manager

I'm following this tutorial on using OpenGL in Swift. 我正在关注在Swift中使用OpenGL的教程。 It apparently depends on some GitHub Repo for GLFW and uses a Package.swift file to build it into your executable. 它显然取决于GLFW的一些GitHub Repo并使用Package.swift文件将其构建到您的可执行文件中。 Sadly, while running the instructed build command swift build -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib I get the following error: 遗憾的是,在运行指令的构建命令swift build -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib我收到以下错误:

error: Empty manifest file is not supported anymore. 错误:不再支持空清单文件。 Use swift package init to autogenerate. 使用swift package init自动生成。

When I run the suggested init command, I get: 当我运行建议的init命令时,我得到:

error: a manifest file already exists in this directory 错误:此目录中已存在清单文件

What should I do? 我该怎么办?

That tutorial is written for Swift version 2, and it's been outdated for some time. 该教程是为Swift版本2编写的,它已经过时了一段时间。 The only reason you need the library in that repository is because it defines some OpenGL function loaders necessary to make your program link properly. 您在该存储库中需要库的唯一原因是它定义了一些必要的OpenGL函数加载器,以使您的程序正确链接。 I currently use a patched version of that SGLOpenGL library that I hacked to make it compile under Swift 3. I believe this is the only way currently to use OpenGL with Swift. 我目前使用的是我所攻击的SGLOpenGL库的修补版本,使其在Swift 3下编译。我相信这是目前在Swift中使用OpenGL的唯一方法。 You will have to correct the Swift UnsafePointer s and rewrite the function parameter lists to use (or remove) named arguments, among other things, as Swift 3 was a source-breaking release. 您必须更正Swift UnsafePointer并重写函数参数列表以使用(或删除)命名参数等,因为Swift 3是一个源代码破解版本。 The compiler will generally tell you what you have to do, it's just a lot of tedious work. 编译器通常会告诉你你需要做什么,这只是一些繁琐的工作。

Note that you don't need any of Turnbull's other libraries to use OpenGL with Swift. 请注意,您不需要任何Turnbull的其他库来使用OpenGL和Swift。 You can easily (“easily”) write your own implementations of the Math functions for the quaternions, vectors, matrices, camera frusta, etc. Google is your friend, as most of these routines are well-studied problems in computer graphics, and there is a great deal of pseudocode and C++ implementations on the web to help you get started. 您可以轻松(“轻松”)为四元数,向量,矩阵,相机截止等编写自己的Math函数实现.Google是您的朋友,因为大多数这些例程都是计算机图形学中经过充分研究的问题,并且Web上有大量的伪代码和C ++实现,可以帮助您入门。

The Image PNG library is non-trivial to replace, but luckily there already exists a native Swift PNG decoder MaxPNG designed to work with graphics frameworks. Image PNG库非常容易替换,但幸运的是已经有一个原生的Swift PNG解码器MaxPNG 设计用于图形框架。

Good luck!!! 祝好运!!!

( Disclosure, I am the author of MaxPNG ; I wrote it because I was in the exact same position as you a few months ago. ) 披露,我是MaxPNG的作者;我写的是因为几个月前我和你的位置完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM