Referencing a new Plugin in an Existing Native Project (iOS / Mac / Android)

Summary

Show code and images as:

Introduction

This tutorial will help you understand how to reference a plugin in an already created xCode or Android project.
For this tutorial, we will take jpEventQueue as example.

1. xCode project (iOS / Mac)

Reference the static library of the plugin in your xCode project.

Here's the path of the static library in your ShiVa project directory :
Plugins/com.jpierron.jpeventqueue/Contents/iOS/jpEventQueue_iOS.a

Drag and drop this file somewhere in the Project Navigator of xCode and choose "Copy items if needed"

2. Android project

Open Android content folder of jpEventQueue, the path is :
Plugins/com.jpierron.jpeventqueue/Contents/Android

Open another window with your Android project and do the following actions :

For a project generated with ShiVa 1.9.x :

  • Copy 'jpEventQueue_Android.a' in the following folder (if existing) : /obj/local/armeabi
  • Copy 'jpEventQueue_Android_arm_v7a.a' in the following folder (if existing) : /obj/local/armeabi-v7a, and rename it to jpEventQueue_Android.a
  • Edit the file named Android.mk (in the /jni folder) and add the following line :
    LOCAL_LDLIBS += -Wl,-whole-archive $(APP_PROJECT_PATH)/obj/local/$(TARGET_ARCH_ABI)/jpEventQueue_Android.a -Wl,-no-whole-archive
  • Copy all the .jar files (if existing) in the following folder : /libs
  • Under Eclipse, select the root of your project, right click and choose 'Refresh (F5)'

For a project generated with ShiVa 2.0 :

  • Copy 'jpEventQueue_Android.a' in the following folder (if existing) : /prebuilt/plugins/armeabi
  • Copy 'jpEventQueue_Android_arm_v7a.a' in the following folder (if existing) : /prebuilt/plugins/armeabi-v7a, and rename it to jpEventQueue_Android.a
  • Edit the file named Android.mk (in the /jni folder) and add the following lines before the latest 'include $(CLEAR_VARS)' :
    include $(CLEAR_VARS)
    LOCAL_MODULE := jpPlayStore_Android
    LOCAL_SRC_FILES := prebuilt/plugins/$(TARGET_ARCH_ABI)/jpPlayStore_Android.a
    include $(PREBUILT_STATIC_LIBRARY)
  • In the same Android.mk file, add the following line just after 'LOCAL_SHARED_LIBRARIES := openal ssl crypto' :
    LOCAL_WHOLE_STATIC_LIBRARIES += jpEventQueue_Android
  • Copy all the .jar files (if existing) in the following folder : /libs
  • Under Eclipse, select the root of your project, right click and choose 'Refresh (F5)'