Building an ios application from an existing Meteor package. I have been running the following in order to get the application to become an Xcode project:
meteor build ../example-output --mobile-settings settings-staging.json --server https://example-staging.meteorapp.com:443
I already have a mobile-config.js, which includes all the typical configurations for meteor such as App.info, App.icons, App.launchScreens, App.appendToConfig. In addition, I have the REVERSED_CLIENT_ID included in the file. Everything works fine, until I add any cordova plugins (meteor add plugin cordova: etc.)
App.configurePlugin("cordova-plugin-googleplus", {
REVERSED_CLIENT_ID: "com.googleusercontent.apps.010101010-bexamples123"
});
The application builds into a .xcworkspace but then has issues which I think these cordova plugins will fix. How can I configure/fix the REVERSED_CLIENT_ID and/or config issues and add cordova plugins so that this project can compile to an Xcode .xcworkspace?
Thanks to this Github post, which pointed out that
"This problem exists since 1.2.x. It sometimes happens if a Cordova
package references another Cordova package as a dependency. I had this
problems a lot with the cordova-plugin-compat package which is
referenced by some others."
The solution ended up being to simply remove the cordova build:
rm -rf .meteor/local/cordova-build
I also removed and added the iOS platform again for good measure:
meteor remove-platform ios
meteor add-platform ios
I'm trying to add LocalFileSystem plugin into my project. But when i execute this command phonegap plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git from '../assets/www/' directory i get this error : JScript runtime error 800A1391 'window' is undefined
I don't think you're in the right directory, you want to be in the root of your Cordova/PhoneGap application (where the config.xml is located). For you, it looks like it might be your /assets/ directory. Also, try this command:
cordova plugin add org.apache.cordova.file
Taken from: http://plugins.cordova.io/#/package/org.apache.cordova.file
Try going to the main folder of your project (The highest level folder) and execute
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
at the CLI. You also need to configure config.xml and AndroidManifest.xml according to the docs: Phonegap Docs
See phonegap-android-localfilesystem-is-not-defined
I was using phonegap 3.0. I updated phonegap to latest version 3.4 and that solved my problem. The .cordova folder was not present in my project directory.
I am using XCode 5.0.2 and Cordova 3.4.0-0.1.3 - What I find is after creating the project using the Cordova CLI and opening in XCode, no changes to the index.html file and index.js file are ever carried over to the simulator when I click run.
I have to open terminal and issues a Cordova Build command and then run the simulator and it works
I followed all the instructions here:
Phonegap - developing and launching app on simulator
xcode 4 + phonegap ... not update JS upon build?
And none of it works! any one a have a solution to this, because having to switch back and forth is becoming a pain.
You can add a pre-action script to your XCode project's build. To do this:
Select Product > Scheme > Edit Scheme from the menu (or ⌘ < on keyboard)
Select Build > Pre-actions from the left
Click + and select "New Run Script Action"
Add a script like this:
cd /path/to/your/cordova/project/
cordova prepare ios > xcode-prepare-results.txt
Now XCode should always run cordova prepare before building your project so you don't have to jump to terminal. You can see the output of prepare in the file xcode-prepare-results.txt.
Note, that depending on how your cordova executable is set up and which shell you use, you might have to either change the shell or modify your PATH in order for the script to find cordova.
So after much searching I seem to have found a solution that works, here is what I did. After looking at other Stackoverflow questions I found someone that said this worked for them.
Find the file called copy-www-build-step.sh.
Mine was in
[project_folder]/platforms/ios/cordova/lib/copy-www-build-step.sh
In that file, find the lines beginning rsync -a "...
Add -c to the rsync lines, so they ready rsync -a -c "...
Well I tried that and it did not work on its own. I also tried the answer from Ville and that pulled closer but no cigar. Finally I took what the command from Ville and put it in the copy-www-build-step.sh file
so my top line is now
cd /path/to/your/cordova/project/
cordova prepare
SRC_DIR="www/"
DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/www"
COPY_HIDDEN=
ORIG_IFS=$IFS
IFS=$(echo -en "\n\b")
.....
.....
.....etc etc
And now I make change , and click run , bam all is updated. I hope this helps someone else.
Other answers in this thread either didn't work for me or screwed up cordova plugins e.g. InAppBrowser, so i finally came up with this:
Edit the file copy-www-build-step.sh and add the following row in the beginning:
cp -fR ../../www/ www/
so it should look like:
...
cp -fR ../../www/ www/ # new code
SRC_DIR="www/"
...
This way your code will be updated properly and your plugins will work
I also edited the copy-www-build-step.sh file, however you don't want to use an absolute path from your User folder. If you are working with other developers you would have to change that every time you check out code.
It's not a big deal, just change:
SRC_DIR="www/"
To:
SRC_DIR="../../www/"
UPDATE
Worked for me on Cordova and Phonegap.
To have the source files automatically copied from the www source directory to the platforms/ios/www directory when you click the Run button in XCode:
In XCode, choose Product->Scheme->Edit Scheme...
Expand the triangle for Build->Pre-actions
Click the "+" to create a new Pre-action
You can leave the "Shell" setting blank.
Set "Provide build settings from" to the project you are building. This is important.
In the script area enter:
cd ${PROJECT_DIR}/../..
echo "--- Start ---" > xcode-prepare-ios-results.txt
echo "Running cordova prepare ios command..."
pwd >> xcode-prepare-ios-results.txt
cordova prepare ios --verbose >> xcode-prepare-ios-results.txt
echo "--- Finished ---" >> xcode-prepare-ios-results.txt
This works for me with XCode 8.2 and Apache Cordova 6.x
I suggest you clean before build your xcode project. And one more thing, make sure you build again your project using cordova build, not inside xcode because it's totally different.
cordova build yourproject
#Ksliman
I modified you code a bit to work on my system and make slight bit more generic.
top of file copy-www-build-step.sh
## New Code Begin ###
cd ../../
PATH=${PATH}:/usr/local/bin
cordova prepare ios
## New Code End ###
SRC_DIR="www/"
simply type:
cordova prepare
on your terminal and run your project again in Xcode
Simple solutions is to build the app with cordova using:
sudo cordova build ios
Then go to xcode > Product > Clean
Then go to xcode > Run (Play Button)
Run "cordova prepare ios" during the building phases:
Open Xcode.
Select your project.
Go to "Build Phases".
Go on "+" to add a "New Run Script Phase".
Move this section before "Copy www directory".
Add the following lines (for Mac):
cd /Users/*/YOUR_PROJECT_FOLDER (Change your project folder)
/Users/*/.nvm/versions/node/v?.?.?/bin/node node_modules/cordova/bin/cordova prepare ios (Change the path to node version)
After "Play" the www-folder will automatically refresh!
All I had to do was to include the full absolute src path for my project. For example:
From your project directory, vim platforms/ios/cordova/lib/copy-www-build-step.sh
change SRC_DIR to the absolute path of your www, SRC_DIR="/Users/michael/Documents/Development/SampleMobileApp/www/"
Save, build, and you should be good to go.
I found that sometimes Cordova gets confused... you need to do a "cordova platform rm ios" (just leave your plugins alone), and then do a "cordova platform add iOS", which will reinstall all your plugins into your platform... then try your build again.
Every time I use cordova build its overrides content in my platform specific www file. So I use cordova compile instead.
From help:
compile <platforms> compiles platform project without preparing it
It is important to just compile the changes not to build entire projects especially if you creating mobile app for many platforms and you have to do some platform specific improvements.
For me, there was an error in my code. I simply needed to run npm start to locate it.
If you are directly changing html from the Xcode, then you should change the code/html of the staging folder, not main folder
In the staging folder you will get same structure which you have in the main folder, but it will reflected directly in the xcode (iOS) build
Staging folder
Note: The changes you made in the xcode will be replace when you build again from the cordova build/run, so please copy your changes in the main folder before doing firing cordova commands
You can get more information from this answer: Purpose of Staging folder in PhoneGap 3.4? Only changes to index.html in this folder get recognized?
This is the correct solution taken from:
Cordova + Xcode 7.3 (html + Javascript) not changed or updated when build and emulate
I installed phonegap 3.3.0 via the command line, created app, added android platform OK. I can use the latest Android ADT to import phonegap app and test it on my Android device. Everything worked perfect.
I installed the Email Composer plugin https://github.com/katzer/cordova-plugin-email-composer via the command line
cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git
The plugin seems install ok, however when I tried to run the javascript code
window.plugin.email.open();
I got error
Uncaught TypeError: Cannot call method 'open' of undefined:43
I put the email_composer.js inside js folder and in my index.html I add reference to it. Not sure why I get this error.
I already asked the author here https://github.com/katzer/cordova-plugin-email-composer/issues/9 and he answered:
You lead the plugin in the wrong way. Do not lead the plugins directly.
If you install a plugin through the command line interface,
they will be listed in the cordova_plugins.js file which is loaded
by cordova.js.
I looked up the file cordova_plugins.js I only saw these code:
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [];
module.exports.metadata =
// TOP OF METADATA
{}
// BOTTOM OF METADATA
});
I should see something about email_composer.js in this file, right? If so, then what I should write in here.
This is my first time using phonegap plugin, not sure what to do. Hope someone can help
Thanks
Always remember to 'prepare' your app after installing any new plugin. From the app's root:
cordova prepare android
This should update your cordova_plugins.js file
I found the bug. I got error if I call the javascript like this
window.plugin.email.open();
To make it works, call like this:
window.plugin.open();
(remove "email")
Hope this help someone
I am new to ExtJS. I tried installing it as per the steps given here.
But I am getting one error while running this command.
sencha create jsb -a http://localhost:8080/helloext/index.html -p app.jsb3
Error msg :
C:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\helloext>sencha create jsb -a http://localhost:8080/helloext/index.html -p app.jsb3 'sencha' is not
recognized as an internal or external command, operable program or
batch file.
What is the problem ?
PS : I already done with the prior steps of installing Apache Server and unzipping ExtJS SDK.
Thanks.
Windows is not finding the sencha executable.
Are you sure you downloaded the Sencha Tools SDK? (Current version is 1.2.3beta). The link from that tutorial shows a page with an obvious link to download the ExtJS library, and less obvious link for the Sencha SDK. Try downloading and installing this from here. Then see if typing "sencha" on the command line does something sensible.
I dont have time to reaad te tutorial but I will let you know how I get started using extjs. I download the library and extract the folder. Name the folder extjs. Then in my webroot or whatever you prefer I make a directory called lib and place extjs inside of it. Then when i create a html document I reference the library by using <script type="text/javascript" src="/lib/extjs/ext-all.js></script>. This is how you can call it up in order to use it. If you have a "app/js" file simply reference it after the example I gave you above so that it is loaded after the ext-all.js file.