12

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.

Nabiya
  • 121
  • 1
  • 4
  • 2
    It's not possible to use Swift third-party libraries at the moment. You can watch this issue regarding Swift support in NativeScript for iOS: https://github.com/NativeScript/ios-runtime/issues/257 – jasssonpet Aug 06 '15 at 15:31
  • I successfully used this library, do you still need help? – sailens Jun 01 '16 at 07:53

1 Answers1

10

You can check for example my dialog plug-in: https://github.com/enchev/nativescript-dialog

I'm consuming Swift library SDCAlertView and you can find more info about how to setup this in the pod and xconfig files: https://github.com/enchev/nativescript-dialog/tree/master/platforms/ios

All classes most probably are avaialble in the global context. For example:

var chart = new BarChartView(); 
Vladimir Enchev
  • 815
  • 7
  • 12