How to use swift library in NativeScript?
I am trying to use this ios-charts library in NativeScript. This library is written in Swift and not in Objective-C. Can I use it? I have tried to use it but it is giving me an error. I have used it in following steps:
For which I have added library in my nativescript project using
tns library add ios 'library_path'
The library gets added. Then I prepared project for ios platform using
tns prepare ios
To test if library is added successfully, I build the project in Xcode
, it builds successfully, but then I get the following error during runtime.
dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /Users/UserNameHere/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/Charts.framework/Charts
Reason: image not found
I got rid of the this error when I set Embedded content contains swift code
to YES
. But now when I am trying to access the library as
var charts = new Charts();
It is giving a Reference error as below:
ReferenceError: Can't find variable: Charts
What I have already tried:
I tried to access Charts using following methods:
1. var charts = new Charts.Swift();
2. var charts = new Charts.Charts();
3. var charts = new Charts-Swift();
4. var charts = new Charts.LineChartView();
5. var charts = require("Charts");
6. var charts = require("../../lib/Charts.framwork");
7. var charts = require("Charts.framework");
All these methods give the same exact error.
References
I followed these links to develop my project
Using-native-libraries-in-your-nativescript-apps
Using native-libs with cocoa pods: docs.nativescript.org/runtimes/ios/native-libs/CocoaPods
Even if I try this with Cocoa Pods, it still gives the same error.
If anyone has tried this, please let me know.