[英]Can I use C++ Code in iOS or mac application?
I have a code written in Ruby and I want to convert it to a library that both of my Android and iOS apps can consume.我有一个用 Ruby 编写的代码,我想将其转换为我的 Android 和 iOS 应用程序都可以使用的库。 I am planning on rewriting it in C++ so that all platforms can use this library (including embedded sensors and small devices and phones)
我打算在 C++ 中重写它,以便所有平台都可以使用这个库(包括嵌入式传感器和小型设备和手机)
I know Android can consume C++ based code via NDK but can iOS devices consume a C++ library code?我知道 Android 可以通过 NDK 使用基于 C++ 的代码,但 iOS 设备可以使用 ZF6F87C9FDCF8B3C3F07F93 库代码吗? or do I have to convert it to Objective-C?
还是我必须将其转换为 Objective-C?
Yes, C++ (and even most recent versions, like c++17) is fully supported on all popular platforms (Android, iOS/watchOS/tvOS, macOS and UWP/Windows 10).是的,所有流行平台(Android、iOS/watchOS/tvOS、macOS 和 UWP/Windows 10)都完全支持 C++(甚至是最新版本,如 c++17)。 The only major thing you will have to face is so-called "glue layer" code, which has to be written separately for each platform to let your code interface with OS-native language.
您必须面对的唯一主要事情是所谓的“粘合层”代码,它必须为每个平台单独编写,以让您的代码与操作系统原生语言交互。 For Android that would be C-based Java Native Interface (JNI), for Apple OSes that would be Objective-C++ classes and MIDL/cppwinrt for UWP.
对于 Android,它将是基于 C 的 Java 本机接口 (JNI),对于 Apple 操作系统,将是 Objective-C++ 类和 MIDL/cppwinrt,用于 UWP。
Source: ~10 years of developing/updating/mantaining C++-based cross-platform apps.资料来源:大约 10 年的开发/更新/维护基于 C++ 的跨平台应用程序。
Please feel free to ask for specifics and I will update my answer.请随时询问细节,我会更新我的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.