I am using MobileFirst 6.3. I am not able to call window.plugins.XXX (i want to use SSLcertificateChecker as XXX) . But the window.plugins is coming as undefined.
I want to include SSLCertificateChecker phonegap plugin from https://github.com/EddyVerbruggen/SSLCertificateChecker-PhoneGap-Plugin into my worklight project.
First i tried iOS. I am adding manually all files.
Added
<feature name="SSLCertificateChecker">
<param name="ios-package" value="SSLCertificateChecker" />
</feature> in config.xml
Add a dependency to Security.framework and also copied SSLCertificateChecker.* to plugin folder
But during implementation window.plugins comes undefined. Not a able to proceed.
It should work by following the same instructions I have provided in this answer, just adjusted to yours.
Note: The same warnings I have written there apply here as well. Namely: on each build performed in MobileFirst Studio the file cordova_plugins.js is being re-generated, thus you will lose the required changes that you will perform in this file, and you will be required to re-do them over and over again.
One possible solution to that is to upgrade to the soon-to-be released MobileFirst Platform Foundation 7.1, which introduces support for another class of application type - Cordova applications, with MobileFirst SDK integrated as a plug-in, thus enabling you to use Cordova Plug-man (or any other method) to install 3rd party plug-ins as you would in any Cordova-based application. Cordova Plug-man is not supported in releases prior to 7.1. Otherwise, you'll just have to find build hacks around it.
Studio
config.xml
Add the plug-in declaration to your-app\iphone\native\config.xml
index.html
Add the following to the header element:
<script type="text/javascript" src="js/SSLCertificateChecker.js"></script>
SSLCertificateChecker.js
Make sure to place the SSLCertificateChecker.js file in the your-app\common\js folder.
Edit the file.
Add at the top:
cordova.define("nl.x-services.plugins.SSLCertificateChecker", function(require, exports, module) {
Add at the bottom: });
Build
Build the project in MobileFirst Studio and open it in Xcode
Xcode
In Build Phases add the required Security.framework (but it will most likely already be there)
Right-click on the project root folder, select "Add Files to..." and copy over the provided .h and .m files
Navigate to native\www\default\worklight\cordova_plugins.js and add the following. This is also the file you will have to re-edit each time you make a build in MobileFirst Studio...
{
"file": "../js/SSLCertificateChecker.js",
"id": "nl.x-services.plugins.SSLCertificateChecker",
"clobbers": [
"window.plugins.sslCertificateChecker"
]
},
Run on iOS Simulator or device.
Related
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.
I am building a Cordova plugin to interface with a 3rd-party library that I am unable to modify. The library includes two separate .a files: one that will build for the iOS simulator and that builds for a device. Using the wrong one for the target will cause the build to fail.
I've added both libraries to the plugin in separate folders (since they're named the same). When the plugin is added to a project, Cordova adds separate Library Search Paths for each library. Unfortunately this means that whichever path is listed first is the one included when the project is built. This means that I have to tell the users of my plugin to "go into settings, find X field on tab Y, switch the order of these two items."
Xcode has the ability to use variable substitution in the paths but I can't find any information on how to override Cordova's generated search paths with one that includes a substitution.
Here's the code from my plugin's plugin.xml file that includes the library:
<platform name="ios">
...
<header-file src="src/ios/lib/FooLibrary.h" />
<source-file src="src/ios/lib/libFooLibrary.a" framework="true" target-dir="iphoneos" />
<source-file src="src/ios/lib/simulator/libFooLibrary.a" framework="true" target-dir="iphonesimulator" />
</platform>
This generates the following Library Search Paths in the containing project:
"$(SRCROOT)/PluginDemoApp/Plugins/cordova-plugin-foolib/iphoneos"
"$(SRCROOT)/PluginDemoApp/Plugins/cordova-plugin-foolib/iphonesimulator"
Instead of those two paths, I need it to only generate this single path:
"$(SRCROOT)/PluginDemoApp/Plugins/cordova-plugin-foolib/${PLATFORM_NAME}"
I've added this path manually in Xcode to the containing project and verified that the substitution with PLATFORM_NAME will cause Xcode to use the appropriate library for whichever platform is targeted. I just can't figure out how to configure my plugin so that Cordova will use this path when the plugin is added to a project.
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
Working with a partner who is creating a cordova plugin.
If we add framework folders and artifacts to the Frameworks directory under iphone->native in eclipse will they get pulled into the corresponding xcode project?
There are some flags that need to be added to the ‘Linking’ properties under build settings. Does this need to be done through the xCode IDE?
Thanks!
JT
Some actions must be done in Xcode.
For example, if you are creating a Cordova plug-in, then you need to:
Edit config.xml - this can be done in Eclipse
Place the .m and .h files in the Classes folder - you can put them there while in Eclipse, but they will not be referenced in the Xcode project
for this you must first build the Worklight project
and then open it in Xcode and add the files you've placed in the Classes folder to the project it self
You would normally need to go to Xcode to create the plug-in to begin with, but assuming you downloaded a plug-in...
The same applies to frameworks.
Im trying to add a module to my project but once its added and i add my code to tiapp.xml, it will not build for ios. I get SystemExit: 65
In android it will build but crashes when it comes to the part that uses the module.
Titanium skd - 1.8.2
Xcode - 4.3
Running on Mac osx lion.
Yes, ive tried a clean rebuild. Ive also deleted the build folder and tried rebuilding that way. Im almost positive im including the module and my code correctly as ive read numerous tutorials and threads about how to do it.
To install the module i placed the .zip in my project root and let it install when it tries to build. It creates all the proper folders and places the files accordingly. Everything seems correct.
My TiApp.xml
<modules>
<module platform="iphone" version="1.0">com.zooz.ti</module>
<module platform="android" version="1.0">com.zooz.ti</module>
</modules>
Adding modules to titanium is a bit buggy and many small details needs to be correct, here are a few:
The module version is the right one and written correctly in tiapp.xml
Make sure that also the version that is inside the module manifest file matches the version you point to.
If you upgrade a module version, a clean build need to be executed.
Minimum SDK version - checkout that the module min titanium sdk version parameter has lower value then the SDK you use.
Regarding the specific ZooZ module. There is a new version much more stable and easier steps to integrate for iOS and Android. For iOS use version 1.2 and Android 1.1. In the new iOS version you don't need the extra step of modifying titanium default xcode project.