简体   繁体   English

我可以在 iOS 或 mac 应用程序中使用 C++ 代码吗?

[英]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.

相关问题 如何在Android中使用我的OpenCV C ++代码? - How can I use my OpenCV C++ code in Android ? 我可以使用什么来分析Android的C ++模块代码 - what can I use to profile C++ module code for android 如何在flutter(android)应用程序中使用c++代码? - how to use c++ code in flutter (android) application? 不能在 Android 应用程序中将 SQLite3 与 c++ 本机代码一起使用 - cannot use SQLite3 with c++ Native code in Android application 如何在Ionic Application中使用原生iOS / Android地图? - How can I use native iOS/Android maps in Ionic Application? 如何在我的Android应用程序中使用本机代码(如c / c ++ / objective c)? - How to use native code like c/c++/objective c in my android application? 在这种情况下,将C / C ++用于iOS / Android跨平台代码是否合理? - Is it justified to use C/C++ for iOS/Android cross platform code in this case? C++ Qt 在 Android 和 iOS 上的应用 - C++ Qt application on Android and iOS 有什么简单的方法可以直接在我的android应用程序上直接使用c / c ++源代码? - Are there any simple way to use c/c++ source code directly on my android application? 我可以在Android上的JNI库中使用C ++异常吗? - Can I use C++ exceptions in JNI library on Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM