Worklight - Building iPhone environment - ios

I am working on Worklight version 6.1.I have created a native ios environment.I added controller classes in the Xcode project and added native functionalities. I have added .js files in the eclipse project.Now I need build my iPhone environment.But I am afraid that native content (Xcode project) will get lost,after building the environment.What is the solution for this.
I should build at the same time native content shouldn't be lost.
How to do this...

Your explanation is VERY raw... it doesn't make much sense to me.
have created a native ios environment
What is that exactly? do you mean that you:
Created a Worklight project and added a Native API for iPhone, or
Created a Worklight project, added a Hybrid app and then added the iPhone environment to that application
Created a fully native project in Xcode?
The distinction between the 3 is important, and you need to mention this in your question in clear wording.
If what you mean is that you went with option 2 above, then your JS, CSS and HTML can be either in the common folder or in the environment folder.
If you then want to add native code, you need to first build your project and then open the generated Xcode project in Xcode, write native code and make sure to copy it back to your Worklight project in Eclipse.
I added controller classes in the Xcode project and added native
functionalities
Where did you add this? In which file? in the classes provided by Worklight in option 2 above, or in a new Class.
Either way, you need to bring these files back into Eclipse.
In Eclipse, you can create a iphone\nativeResources\Classes folder. During build-time in Eclipse, the files in this folder will be copied into the iphone\native\Classes folder, and when opened again in Xcode - your native code will be there...
Note: if you created your own class file, you will need to reference it in Xcode (right-click > add files...). Worklight cannot do this for you.

I believe your customizations should not be lost. Have you tried making the build already and your resources were overwritten?

Related

How to update a Cordova iOS platform project with only iOS source code

I have got a job to reform a Cordova iOS project to the newest version. However the only source code I have received is the iOS platform. The folder's structure is like this
-ios (root folder)
--cordova (folder)
--CordovaLib (folder)
--icon
--icon#2x.png
--AppName (folder)
--AppName.xcodeproj
--RandomSDK (folder)
--Versioning.txt
--www(folder)
So as you can imagine, it must be just a sub-folder under the platform folder in a complete Cordova project. And the Cordova version of this iOS project indicated by the file under path .\CodovaLib\VERSION is 2.7.0
My question is, is there any whether "dirty" or "clean" way one can build it up to the newest Cordova platform as well as the newest iOS version? I even don't have to recover the original Cordova project. The only thing need to be cared here is the iOS project.
I have read some of the post like Upgrade Cordova Version of an iOS app (which I called it a "dirty" way). I just want to do something like that, with only www folder, plugin folder and config file in the iOS platform, but that post only tells how to do it with the original Cordova project.
For the "clean" way I mean do something like this: https://cordova.apache.org/docs/en/latest/guide/platforms/ios/upgrade.html .
OK, After some struggles, I finally make it work and compiled. Here are the steps I do in a high level of view.
First, I have created a brand new Helloworld template Cordova project and name the project name and bundle identity exactly same as the old one. Second I copy the www folder to from the old iOS project to the new Cordova project. (Yes, the www folder in both iOS platform and Cordova are the same), and then base on what I need, I change the settings such as content src to the one I want manually. Third I built the iOS platform, then copied all the files that are missing from the old iOS project, use the old xcode project covered the new one, and manually changed all the config files manually to make it consist both to the newest Cordova and the old iOS project. Last I exclude all the old plugin from the xcode project, and remove any old plugin from the project, then reinstall them via the latest Cordova. And miraculously it work!
In general, what I did is mostly like what this post have done, except first you need to set up all the config manually, second after you build up the iOS platform you still have to copy everything and confiure them again since the Cordova project here is no more than a Helloworld template with the html, js and css files you need.
Actually this is my first time maintaining a Cordova project at work. I think the idea is really neat, but somehow it is really hard to make it work due to the hardware support vary from device to device, which is unfortunately. Hopefully later on people can use the design pattern that separate the UI and core of the mobile app so that at least things like Cordova can do the UI work all together.

Modifying Cordova iOS platform template -- linking frameworks?

I have been working on a Cordova project for both iOS and Android.
As part of the project as we will need to build a number of projects from a basic template.
I have done this by creating a template for the actual cordova project and also as part of it I pulled the cordova-ios-master code base for when we add the iOS platform. So we use our own cordova-ios-master due to some small modifications we needed to add.
With some of the plugins we have added / created we need to access SDK's / API's from some third party developers (this is mainly for some push notification services). Normally when we create the project and have added the platform we then need to add the linked frameworks using Xcode.
However I can see that within the cordova-ios-master there is the template Xcode project. I was hoping I could add the linked frameworks within this project so that they are already added when we first create the project and add the custom iOS platform.
What seems to be happening though is if I add the linked library into the template Xcode project and then save it. Once I then re-add that platform to the cordova project instead of the Xcode project being named after the cordova project name, it seems to have messed the re-naming of the Xcode project.
Below shows how the Xcode project normally appears when you add the libraries manually after adding the platform
So if i modify the Xcode template in cordova-ios-master, shown below....
You can see it already has a libCordova.a added.
I add one more and re-save the project.
But then when I add the platform to my project again from this source, i open the Xcode project for it and whilst my library is added, the project was named "myproject" but i can't choose to run it as the project selection seems to appear as "PROJECT_NAME" as opposed to being named and usable as "my project"....
Im fairly new to mac's and Xcode so maybe I'm doing something basic wrong.
Any suggestions or ideas would really help, I hope this post makes sense, it is a bit complex.
Thanks again
Rhys
Right I found a solution. I think I was looking at the problem the wrong way round. So if I need to add a framework for a particular plugin, rather than edit the Xcode project to add the framework. Cordova actually gives you the option to add certain frameworks from within the plugin.xml. Found this answer here....
How to copy a custom ios framework using plugin.xml on Phonegap 3
so I have added a required framework like so....
<framework src="src/ios/OtherLevels/OtherLevels.framework" custom="true" />
My bad!
-Rhys

Framework folder getting generated inside dynamic framework

I am creating a dynamic framework using Swift. When I build the framework, the resulting artifact has a Framework folder that has a bunch of system dylibs that I don't expect.
I am using this documentation for reference - https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html#//apple_ref/doc/uid/20002253-99920-BAJFEJFI
Because of this folder and libswiftRemoteMirror.dylib, the app's release archive is getting rejected by iTunes upload.
I found out the solution to this. In my framework build settings, I had Always Embed Swift Standard Libraries enabled which should have been disabled. Not sure why it was enabled in the first place, since I didn't write the framework, someone else did. But I think it might have been because they started the project using an iOS app template instead of the framework template.

Where to find worklight.plist?

I'm using this URL to implement the App authenticity for iOS.
https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-6-3/authentication-security/application-authenticity-protection/application-authenticity-protection-native-ios/
However, I need to know where to find the worklight.plist to make sure that the applicationId is matching what i'm putting in the application-descriptor.xml.
The worklight.plist file is available only after building the MobileFirst application using the MobileFirst Studio Eclipse plug-in (or CLI commandline tool).
For Hybrid applications,
You can then find the worklight.plist file in the your-project\apps\your-app\iphone\native folder.
For Native applications,
You need to only generate the NativeAPI for iOS and it'll be located in the generated folder, in your-project\apps\your-nativeapi\WorklightAPI folder. You then need to follow the native apps tutorial to copy over this (and more) files to the Xcode project.
Thank you,
I have found it after building the project inside the native folder.

Xcode - debugging library built outside project

I have a C library whose code resides in say /repos1/clib. I build that from the command line using the latest iOS sdk to create clib.a (including a debug build for the simulator) which I copy to an iOS project say in /repos2/proj.
I have been using this setup for several years. The old C library very occasionally might require some debugging and I was pleased by the fact that Xcode simply stepped into the library code that was outside the project (inside repos1) without having to do any setup - it just worked.
But this was up until a few Xcode versions ago. I am not sure exactly when it changed - perhaps when they moved from gcc to llvm? - since I very seldom needed to debug the C code, but for a while now I only get dissasembly when I try to debug the C library from the iOS project (including at least references to the C file name & line number). For the few times I need to debug it is very inconvenient (I create a temp project that includes the C code).
So, any idea why it worked before and doesn't now? Where should I look? Could it be the way I build the C library, maybe there was a flag in gcc I was using that does not have an equivalent in llvm (I can find and post the old build command I was using if it is relevant)? Is the issue in Xcode and there is a way to tell it where to look for the sources?
Thanks!
Edit: To make it clear, I can add the C library either as the source or as a subproject in Xcode, however for reasons that are out of scope this is not helpful for this specific project. So, can it work like it used to with older Xcode versions? If not, it would still be interesting to know why not.
The recommended approach is to create a library project in Xcode, one for iOS (there is a template for it), then when you get that to build add that project to your app, make sure the lib is a dependency and gets linked. There are many tutorials on the web how to do this.
Then as iOS evolves and new architectures (armv7s) arrive you simply update both projects.
I was struggling with the same issue.
I tried resetting in library/application project all options related to symbol stripping and copy application project to same truecrypt drive as library project but it didn't help.
In my case it appeared it was an app project issue. Same library could be debugged in another app project with source code so that was a clue.
I had more than one version of the same library in app project and set only target membership to choose which should be used. Not sure if that could affect my app project somehow.
Nevertheless after deleting all libraries and copying them to app project again I was able to debug libraries with access to source code.

Resources