简体   繁体   English

使用 Swift 或 Objective-C 创建 Dylib 文件

[英]Creating a Dylib file using Swift or Objective-C

Is it possible to create a .dylib file from a Objective-C or Swift coded-project, or must the code be written in C++?是否可以从 Objective-C 或 Swift 编码项目创建 .dylib 文件,或者代码必须用 C++ 编写?

I've seen several sources, but they're all written in C++.我看过几个来源,但它们都是用 C++ 编写的。

see - Creating and Using a Simple .dylib and How do I create a dynamic library (dylib) with Xcode?请参阅 - 创建和使用简单的 .dylib以及如何使用 Xcode 创建动态库 (dylib)?

Is it even possible to create a .dylib file using any other language than c++?甚至可以使用 C++ 以外的任何其他语言创建 .dylib 文件吗?

As we discussed I have created an sample app for OS X. It uses dylib with single Foo Swift class.正如我们所讨论的,我已经为 OS X 创建了一个示例应用程序。它使用带有单个Foo Swift 类的 dylib。 Foo has doSomething method, which logs kind of "hello world" message into the console. FoodoSomething方法,该方法将某种“hello world”消息记录到控制台中。

Once you are built the project, you can find the dynamic library inside the application bundle in the Frameworks folder.构建项目后,您可以在 Frameworks 文件夹中的应用程序包中找到动态库。 It named libFoo.dylib .它命名为libFoo.dylib

Source code: https://github.com/melifaro-/OSXDylibSample源代码: https : //github.com/melifaro-/OSXDylibSample

Hope it helps.希望它有帮助。

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

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