I am trying to use std::vector in Swift code according to what is written in Swift documentation (https://www.swift.org/documentation/cxx-interop/) and Apple tutorial (https://developer.apple.com/videos/play/wwdc2023/10172/) but I have EXC_BAD_ACCESS error.
I am using Xcode 15.1 to crate app for iOS. My app has only main view, that have only one button:
Button(action: {
var vect = getVectorObject.getVector()
},
label:{
Text("Button")
})
header file that contains declaration of object:
@interface getVectorObject : NSObject
+ (std::vector<int>)getVector;
@end
and Objective C++ file with definition:
@implementation getVectorObject
+ (std::vector<int>)getVector {
std::vector<int> vec = {1,2,3};
return vec;
}
@end
When I compile the project everything is OK but when I run simulation and I press the button I have an error: EXC_BAD_ACCESS in "getVectorObject.getVector()"
As I understand from the Swift documentation and Apple tutorial, something like this should be possible to do.
I tried to use "var" and "let" but I have the same error. I read the documentation and StackOverflow but I cannot see any solution.