How to minify MobileFirst hybrid iOS project? - ibm-mobilefirst

I would like to obfuscate my code. The tutorial is under Concatenation and minification topic
These are the steps I’ve used to minify the code in hybrid app:
export JAVA_HOME=$(/usr/libexec/java_home)
cd /Users/keatooon/Desktop/testmfpminify2
mfp create testProject
cd testProject
mfp add hybrid testApp
mfp start
mfp build
mfp push
mfp console
mfp push —concatenate —minify
xxx:testProject xxx$ mfp push --concatenate --minify
Preparing for push...
Verifying Server Configuration...
Runtime 'testProject' will be used to push the project into.
Pushing to Server...
Deploying
/Users/xxx/Desktop/wktestmfp2/testProject/bin/testApp-common.wlapp...
Deploy complete for
/Users/xxx/Desktop/wktestmfp2/testProject/bin/testApp-common.wlapp.
/Users/xxx/Desktop/wktestmfp2/testProject/bin/testApp-common.wlapp
has been deployed.
Push Completed Successfully.
However, it does not add any security to the code.
Code before vs after Concatenation and minification:
Moreover, the code doesn’t work at all after concatenating and minifying it.

Without specifying which files you want to minify, done in the build-settings.xml file located in the root folder of your application, nothing would actually get concatenated and/or minified.
The fact that it fails the app from running is interesting...
Have you edited said file? If not, try to.
Find more information about concatenation and minification, here:
Updating the build-settings.xml file: http://www.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/dev/c_optimize_app_cli.html
Configuring the build-settings.xml file: http://www.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.reference.doc/cli_commands/build_config.html

Related

The server was unable to process the request from the application. Please try again later

I have an Application developed in Worklight 6.1 and I upgraded the application to Mobile first 7.1. I have build and deployed the application in Mobile first 7.1.
But my application Not able to invoke the adapter and displayed the Message "The server was unable to process the request from the application. Please try again later"
I have followed the below procedure for up gradation.
1. Installed the Mobile first 7.1 Plugin in Eclipse
2. Imported the Existing 6.1 project in to My work space(I hope Tool will
auto upgrade app to 7.1)
3. Build the application and it generated .war, .wlapp and .adapter files
4. we have installed the standalone 7.1 Server.
5. Deployed the build files in servers.
6. Created the apk and installed in Mobile.
Now it is showing the Message "The server was unable to process the request from the application. Please try again later" while launching the application.
From the logs i found the below details when i try to invoke adapter
invocationContext: null
Status : 404
invocationResult : undefined
Note: It was working well in development environment
Kindly suggest
It'd be more useful to see the complete server and client logs as well. Please upload and edit the question with links to the log files.
That said, in step 6 (Created the apk and installed in Mobile.) you do not mention if you have re-built the project with the correct remote server host, port and context root values. Make sure you've done that. See The Build Settings and Deploy Target command.

IBM Ready Healthcare app migration from v6.3 to v8.0 issue

I am trying to migrate the IBM Ready Healthcare app (https://github.com/IBM-MIL/IBM-Ready-App-for-Healthcare) from v6.3 to v8.0.
I ran "mfpmigrate client ..." command from 'healthcare-mfpf' folder (folder structure shown below), and I got "No supported platforms were detected to migrate" error. Next, I ran the command "mfp add environment" in order to add the environment, that would add the platform. However, I get an error saying that there needs to be a hybrid app available to add environment. I had no luck on running the commands from apps folder as well (folder structure shown below).
Would anyone please kindly let me know the folder I should run the command from, or do I need to go through some extra steps before I can run the "mfpmigrage client ..." command.
Folder structure
Notice: please note that the Ready Apps are no longer maintained by IBM. Just take this under considerations
This project is a Hybrid app, meaning you need to first add it to MobileFirst Studio and then add a supported environment. The project does not come with environments by default.
Only once you do this step will the migration tool find a platform (= environment) to migrate from...
Looking at the file structure you've provided, it's wrong.
It shows:
Apps
- android
- iphone
It's supposed to be:
Apps
- some app
--- android
--- iphone
--- common
It could be that they call the app in the platform name, but that doesn't matter, it still needs to have the environment folder, so maybe to "Android" you need to add the "Android environment" (right-click > add environment...).
It could be because you thought this is Cordova app and used mfp add environment in the wrong filesystem location (also looks like you're trying to use a CLI instead of Studio?).
Looking at the GitHub repository, this whole structure is unconventional and it's not clear why they did it this way.
The links to the documentation there are also dead. This looks like a dead project.

MobileFirst CLI 7.1 push on remote server

I try to push .wlapp to a remote server with the following command.
mfp push rockW510_Local mprod
And i have the following error
Preparing for push...
Error: error code: 306
Error: The runtime being pushed to [mprod] is not the same as the application's >runtime [StarterApplication_ionic-release71]
Error: INVALIDRUNTIMESCENARIO
Error: Push has failed
Is it not possible to push .wlapp, .adapter on a remote server with a different runtime of the local projet ?
Thanks
Update:
The official word is as following:
This behavior is by design. That runtime check was put in place to
ensure MFP project based apps were only deployed to the associated
project's runtime.
Cordova apps created outside of a MFP project can be deployed to any
runtime.
I was able to recreate this the following way:
Created a local server with a project "myproject", added a Hybrid app and mfp pushed it to create the .wlapp file
Create a server config for the remote server I have
Ran the command: mfp push server2 myproject2
It failed with the same error.
I then:
Loaded the console of server2
Dropped the .wlapp file
The .wlapp file successfully got deployed
So I guess that something in mfp push is failing in this scenario. Or it could be the expected behavior... need to double-check this (in progress...)
In the meanwhile you have the above workaround.

dojo/_base/*js missing from worklight apk in wl 6.1

I have a hybrid app that was created with WL 6.1 that uses the included dojolib. Currently it is in production for iphone and we are adding the android flavor of it. When running the code from the mobile simulator on the console, both the android and iphone work fine. The ipa file works fine. When I run the hybrid on an android device (Samsung S4), the application throws errors in the log on app startup. I have the "provide dojo libraries" turned off. In the DDMS log I see statements like the following:
09-09 12:47:12.092: E/AndroidProtocolHandler(20324): Unable to open asset URL: file:///android_asset/www/default/dojo/_base/declare.js
09-09 12:47:12.263: E/AndroidProtocolHandler(20324): Unable to open asset URL: file:///android_asset/www/default/dojo/_base/connect.js
09-09 12:47:12.303: E/AndroidProtocolHandler(20324): Unable to open asset URL: file:///android_asset/www/default/dojo/_base/event.js
Looking out in the android project in eclipse, I see those files in the "assets/www/default/dojo/_base" directory. The issue is when I look in the APK file, the "_base" directory is not there. Any help as to understanding why it is missing?
Your application should be using the compiled version of the dojo files, it seem that its not.
i would check
These files : core-web-layer.js and mobile-ui-layer are in your www folder
That the wlCommonInit function includes below:
function wlCommonInit() {
require([ "layers/core-web-layer", "layers/mobile-ui-layer" ], dojoInit);
}
I've also found an alternative way to get around the android packaging bug. As I mentioned earlier one way is to use the DojoBuildFactory to create a new layer that would have the files imbedded in them. This is the same process that WL uses to create the core-web-layer and mobile-ui-layer. I have a team working on this, but the documentation is ... scant and it is a time consuming process.
While they were doing that, I found what I think is a cleaner way of addressing the issue. Effectively open up an unsigned apk, insert the files, and then sign the APK. Worked like a charm. Here are the steps I used:
Build from working pointing to the correct worklight server and with the provide missing dojo libraries turned off
Export as Android project as an unsigned apk
Open command prompt with right env settings pointing to JDK and ADT
Create keystore (if not already done)
Unpack into temp using jar
Copy dojo files over from android/native/www/default
Pack back into apk using jar
Sign the jar
Zipalign the jar
Now you have a working apk that includes the files/directories in asset that begin with a "_".

Building a Sencha Touch 2.1 project

I've built myself a small Sencha Touch 2 app, so now i'm trying to make it smaller/minify it
My app looks like
/touch
/app.js
/resources
/ux
/app
/app.json
/index.html
/build.xml
So I was trying to make it more efficient & faster to load so I loaded up Sencha Cmd and ran
sencha compile --classpath=app,touch/src,ux include -all
So it does what looks like compiling it, without giving any errors, it gives a few warnings but those are ok. So it finishes up and nothings changed. The directories are exactly as there were before.
How would I use this correctly to make my app smaller & load faster?
The command
sencha app build package
or
sencha app build production
Will minify/package your application. All of the javascript will be contained in a single app.js file, and the javascript+css will be minified. More information about these commands can be found here: http://docs.sencha.com/touch/2-1/#!/guide/command_app
See Also cmd tool doc for detailed info:
http://docs.sencha.com/cmd/3.1.2/#!/guide/command_app_touch-section-deploying-your-application
Deploying your application simply means editing source code and refreshing the browser. All source files are dynamically loaded on demand. There's no building process involved. When it comes to deployment, Sencha Cmd provides the following four build environment options:
testing - intended for QA prior to production. All JavaScript and CSS source files are bundled, but not minified, which makes it easier to debug.
package - creates a self-contained, redistributable production build that normally runs from the local file system without a web server.
production - creates a production build that is normally hosted on a web server and serves multiple clients (devices). The build is offline-capable using HTML 5 application cache, and is enabled to perform over-the-air updates.
native - first generates a package build, then packages it as a native application, ready to be deployed to native platforms.