简体   繁体   中英

NSBundle not able to access static library java script file path

In my project I am including a static compiled library, which has a javascript resource in it.

Now in my App at a particular event I want to run that javascript file from my library.

But when I try to access the js file the path is null.

I tried following code:

NSString *jsFilePath  = [[NSBundle mainBundle] pathForResource:@"myJavaScript" ofType:@"js"];

and

 NSBundle *staticBundleName = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"libCalC" ofType:@"bundle"]];
 NSString *filePath = [staticBundleName pathForResource:@"myJavaScript" ofType:@"js"];

There is no bundle in my library, I found some posts on stack overflow to get the resource files from bundle but iOS doesn't allow dynamic loading of bundles also.

I have included the Js file in Copy bundle resource.

Am I missing something here, please guide. ?

thanks KplMax

A static library does not carry it's resources over with it, because it has no concept of bundle. If you want to use your js files (or other assets such as images), you will need to copy those over to the application itself.

Or, you can create your own framework that contains resources that you want to carry over to the application layer.

A similar question + answer can also be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM