IBM Worklight 6.1 - How to add custom written native code from Eclipse to Xcode?

纵然是瞬间 提交于 2019-12-23 03:43:29

问题


We created a hybrid application on Iphone 5s. The worklight server version is 6.1, Xcode version is 5.0.2. We noticed that after we deleted our native folder under Iphone, our self-written native codes were gone. Therefore, we need to manually add these native codes to Xcode when we build a Xcode project from Eclipse. I am just wondering if there is a more convenient way to do it?

Thank you very much.


回答1:


If you delete the native folder, then any user-files you've placed in it will be deleted as well. When building the application again after deleting the native folder Worklight can only re-generate the Worklight-files, not user-files...

Your files are your responsibility.

Thoughts:

  1. You can place the class files (the .m and .h files) in the iphone\nativeResoures\Classes folder (create this Classes folder). Now upon every build in Worklight Studio the class files will be copied from the iphone\nativeResources\Classes folder to the iphone\native\Classes folder. So this is a sort of a back-up in case you delete the native folder.

    But note! Copying via nativeResources or manually placing the class files in the iphone\native\Classes folder in Eclipse, is not enough. Eclipse does not know how to reference your class files in the Xcode project. This is something you must do in Xcode so that they will be referenced in the project's .pbxproj file.

    Eclipse cannot do this for you and I would not recommend on doing this referencing manually.

    This is also explained in the "Adding native functionality to hybrid application with Apache Cordova plugin" training module provided in the IBM Worklight Getting Started training materials.

  2. If you develop in Mac, then you can open the .xcodeproj file (located in the native folder) from the Eclipse workspace after you build the project; this means that any changes you will do in Xcode will be part of your project in Eclipse (because you are working on the same files)... So this too is a way to ease on development.

    But be careful if you do this while also using the nativeResources approach, because then you will lose your changes in Xcode upon build in Eclipse.

You can use both of these approaches if you act carefully. Always backup your class files to the nativeResources folder before building in Eclipse after changing the .m or .h files in Xcode.

You are working with 2 IDEs, so you need to juggle...



来源:https://stackoverflow.com/questions/21119086/ibm-worklight-6-1-how-to-add-custom-written-native-code-from-eclipse-to-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!