How to explore NSBundle contents?

150 Views Asked by At

I've got NSBundle file named main.jsbundle packaged by react-native bundle, which tool I can use to explore it's contents? I can see that it got the minified js code inside, and also some sort of index at the beginning of file. I need to extract the js code in order to debug an issue.

2

There are 2 best solutions below

0
Ilia Sidorenko On BEST ANSWER

As @ivanmoskalev pointed out, this might not be necceserily NSBundle. Anyway, piping the file through strings outputs pretty much just the javascript part of the file, so that works for me.

3
ivanmoskalev On

NSBundle is a totally different thing – it is a native class representing an Apple format of packaging applications and frameworks, allowing to access and manipulate it from native code.

You are asking about a React Native bundle, which is quite a loose concept of a single file of minified JS code + an assets folder for images and data. You can actually de-minify the js-bundle using conventional tools such as uglify-js and try to inspect it.

You can also use sourcemaps produced by Metro, and maybe metro-symbolicate to understand how the minified code from the bundle maps to actual sources, although I can't recommend anything more specific without knowing the problem at hand. There is also no documentation for metro-symbolicate, meaning you'll have to grok its sources.