简体   繁体   English

Xcode 7.1和C ++

[英]Xcode 7.1 and C++

I have a C++11 header and source file to call from swift (of course i'm including the header in the bridging header). 我有一个C ++ 11标头和要从swift调用的源文件(当然,我将标头包括在桥接标头中)。 I've set the build settings for C++ to: 我已经将C ++的构建设置设置为:

"C++ Language Dialect" -> "C++11 [-std=c++11]" “ C ++语言方言”->“ C ++ 11 [-std = c ++ 11]”

"C++ Standard Library" -> "libc++ (LLVM standard C++ library with C++11 support)" “ C ++标准库”->“ libc ++(具有C ++ 11支持的LLVM标准C ++库)”

It still can't find some #include (file not found): 它仍然找不到一些#include(找不到文件):

#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include <utility>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <utility>

As mentioned in one of the comments, you can use a wrapper. 如评论之一所述,您可以使用包装器。 In fact, the wrapper doesn't even have to be in Objective-C. 实际上,包装程序甚至不必在Objective-C中。 It can actually be a C++ wrapper, but the functions intended to be called from Swift should have C linkage. 实际上,它可以是C ++包装器,但是打算从Swift调用的函数应该具有C链接。 See http://www.swiftprogrammer.info/swift_call_cpp.html for a tutorial. 有关教程,请参见http://www.swiftprogrammer.info/swift_call_cpp.html

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

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