문제

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.

도움이 되었습니까?

해결책

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...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top