Including resources

Native code sometimes requires additional resources, such as layout or image files. These work in slightly different ways on Android and iOS but can be easily included in modules for both.


To include resources they must be placed in the module/android/res folder. Once there the Android inspector project should be updated: in Eclipse, you'll see a resources in the ForgeInspector project's res folder, and will have been generated in the ForgeModule's trigger-gen folder.

For more information about what kind of resources can be added to your module and how they can be used with the Android SDK, see the `official Android docs concerning App Resources.

Important: Due to a limitation of ADT, in platform versions less than v2.0.2 it is necessary to move from the ForgeModule's trigger-gen folder into the src folder, alongside your and files.

To do this, you can use Eclipse's Move... refactor to change the package the class is in.


This is only necessary for platform versions older than v2.0.2. You'll need to do this refactor each time you regenerate your inspector project.

In your code, you can refer to your resources via the R class as normal, e.g.:

LayoutInflater inflater = (LayoutInflater) ForgeApp.getActivity().getLayoutInflater(); 
View view = inflater.inflate(R.layout.myLayout, null);


On iOS, any resources included in your module must be part of a bundle.

3rd party bundles can be included by placing the bundles in module/ios/bundles. An inspector project update will then be required to include them in the inspector for development

If you have resources such as images that you want to include in your module, you must create your own bundle. The inspector project includes a ForgeModuleResources target which can be used to help with this:

  • All bundles must have a unique name - you can name your bundle by setting the Product Name for the ForgeModuleResources target.

module set bundle name

  • Add the required resources to the ForgeModule project and include them in the ForgeModuleResources target.

  • Use the named bundle to reference these resources from your native code, with code like this:

     NSString * bundlePath = [[NSBundle mainBundle] pathForResource:@"my_bundle_name" ofType:@"bundle"];
     NSBundle * myBundle = [NSBundle bundleWithPath:bundlePath];

For more information, see Accessing a Bundle's Contents.

  • When building UniversalForgeModule your bundle will be output in the build folder: make sure to include this in ios/bundles/ in your module folder.

In Summary:

  1. Run UniversalForgeModule to produce build folders.

  2. Copy inspector/ios-inspector/build/<bundle_name>.bundle to module/ios/bundles/<bundle_name>.bundle

  3. Quit Xcode.

  4. Update iOS inspector.

  5. Reopen Xcode. Note that <bundle_name>.bundle is listed under ForgeInspector's frameworks.

  6. Any new or changed resources will require you to start again at step 1.