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
}
Finally I found the solution to it. Sharing the steps which I followed.
$ brew install armadillo
Once it is completed, please keep a note on the installed path from the last line.
In my machine, it is installed on path /usr/local/Cellar/armadillo/10.5.1
/usr/local/Cellar/armadillo/10.5.1/include/armadillo_bits
libarmadillo.dylib
library that is available in the installed path to the sdk path in the Xcode. Open terminal and type following command.sudo ln -s /usr/local/Cellar/armadillo/10.5.1/lib/libarmadillo.dylib /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/lib/libarmadillo.dylib
Targets > Build Phases > Link Binary with Libraries
You should see libarmadillo.dylib
Select and add it to your project.armadillo
text file and armadillo_bits
folder, from below path to the project.
/usr/local/Cellar/armadillo/10.5.1/include
That's it.. The setup is over and you can use the Armadillo library in C++ files inside Objective-C/Swift projects.