Using Armadillo C++ library in Swift 5

  armadillo, c++, dylib, swift, uibezierpath

I’m trying to use Armadillo C++ library in my swift code to create sinusoidal curved arrow. Earlier it worked well with Objective C. But when I’m trying to do the same implementation in Swift, it’s showing 'armadillo' file not found error.

I’ve downloaded the file from https://github.com/gadomski/armadillo/tree/master/branch-5.600/include path and copied both armadillo_bits folder and armadillo file into the project.

I’ve created a Objective C++ Wrapper around the C++ class too.

Objective C++ Wrapper DrawSinusoidal.h file

#import <Foundation/Foundation.h>

@interface DrawSinusoidal : NSObject

+(NSArray *)bezierPathsForPoints:(NSArray *)points;

Objective C++ Wrapper DrawSinusoidal.mm file

#import "DrawSinusoidal.h"
#import "DrawSinusoidalMath.h"

@implementation DrawSinusoidal

+(NSArray *)bezierPathsForPoints:(NSArray *)points {
 ...
}

C++ file – DrawSinusoidalMath.h

#include "armadillo"

std::vector<std::vector<arma::vec2>> bezierPathsForPoints(const std::vector<arma::vec2> &points);

C++ file – DrawSinusoidalMath.cpp file

#include <iostream>
#include "DrawSinusoidalMath.h"

using namespace arma;

std::vector<arma::vec2> bezierPathsForPoints(const arma::mat &tValues, const std::vector<arma::vec2> &points)
{
... 
...
 return points
}

Source: Windows Questions C++

LEAVE A COMMENT