So I asked and answered the question [how to do Phonegap 3.0 without Phonegap Build][1]. Now my app is ready for iOS as well (I think) and it's time to start deploying and debugging for that platform.
The formal question: how can I add the iOS platform to a Phonegap 3.0 project?
This answer is still in progress.
Goals I've achieved:
Compiling the project in command line, then running on device or sim using xCode
Attempts failed:
Compiling and running (device/sim) all from the command-line
1. Creation
I could easily add the iOS platform as described in the docs' iOS Platform Guide.
Basically, if the project already exists because you did Android first, this is how you set up the iOS app structure.
$ add platform ios
Then you should add files to the main /www folder if you didn't already have them from your Android work. Then this takes care of creating the app in debug form:
$ cordova prepare //Creates all the necessary source filed
$ cordova compile //Creates an ipa file
//Alternatively, do both in one go with cordova build
2. Deploying to device
But it is completely unclear how to use the command line interface to actually deploy the test app to device or emulator.
When you attach a physical iOS device, and simply try this from the main project folder...
$ cordova run ios
You get a pretty clear answer:
[Error: An error occurred while running the ios project. Targeting a device is not supported currently.
]
So I've resigned myself that for device testing, I must still use xCode. No biggie. However, xCode cannot "refresh" the project by itself after you've updated your files, so in between deploys you must go back to the command-line to recompile the iOS app.
Strangely, when I update my code, I do need to use "cordova run ios" (even with the above error) in order for the the /platforms/ios/www folder to be updated. So this is what works and does not work:
$ cordova run ios
//Rebuilds the app with main /www files successfully,
//then tries to deploy to device and fails in that.
$ cordova prepare ios
//Does not rebuild with main /www files
//(Also does not deploy but that is not its intended function)
And remember that you also need to clean your xCode project in between runs. So the sequence is:
Previous run
Edit your code
In console, do: cordova run ios
In xCode, Menu bar > Product > Clean product
in xCode, Run
3. Deploying to emulator
Still, "deploying to device is not possible" begs the question "What about emulator?"...
The docs page on the 3.0 command-line interface mentions you should enter the command
$ /path/to/my_new_project/cordova/run
This had me all confused. What kind of path is that? From where are you supposed to run it? Is it a nice way of providing a command you can run from anywhere? Why force me to enter my annoyingly long project path for each command?
Confusingly, the run command doesn't work if you actually go to the "platforms/ios/cordova" directory where the run executable is located.
The trick is to be one directory lower, i.e. at the /platforms/ios subfolder of your Cordova app project. There you type "cordova/run". Then in my case it starts building.
4. Install "ios-sim"
But that was not the end of it. I subsequently get an unanticipated error about "ios-sim" not being installed.
[...]
** BUILD SUCCEEDED **
Error: ios-sim was not found. Please download, build and install version 1.5 or greater from https://github.com/phonegap/ios-sim into your path. Or 'brew install ios-sim' using homebrew: http://mxcl.github.com/homebrew/
Fortunately that project webpage has adequate documentation on how to install. However, even after adding the ios-sim directory to my $PATH, when I want to emulate I get the following error.
$ cordova emulate ios
[TypeError: Arguments to path.join must be strings]
This is where I am currently stuck. My path looks exactly like this (all in one line):
export PATH=${PATH}:/Applications/adt-bundle/
sdk/platform-tools:/Applications/adt-bundle/sdk
/tools:%JAVA_HOME%\bin%ANT_HOME%\bin:"/Users/
cool/Library/Developer/iossim"
What am I doing wrong? I've tried with and without doublequotes, and I've even renamed the ios-sim directory to iossim in case the hyphen was the problem. No effect.
So no simulator for now.
5. Install to iOS App Store
This is the point where Phonegap really leaves you out in the woods. Maybe because they want you to use their paid app publishing service, but also because the process of publishing an iOS app is basically soemthing you do using xCode, iOS Developer Portal, and iTunes Connect.
So here that goes:
You need to have all the right certificates and profiles for your app (yes, it's a bunch of incomprehensible virtual documents that all require each other, Apple is like the Soviet Union of app stores).
You request those certificates and profiles in the iOS Developer Portal, save them to disk, then double-click them so that xCode knows you have them and will include them in your app.
This is the docs page for xCode 4 on how to publish your app.
The most counter-intuitive bit is that in order to publish your app, you first have to create an archive of it in xCode (Open your project in xCode > menu bar > Product > Archive).
When the archive is made, you will see it in the Organizer view under the Archives tab. There should be two buttons: Validate and Distribute. Validate checks and includes all your profiles and certificates in the app, and it also checks for errors like a wrong version number.
Distribute does what it says: it sumbits the app to the App Store.
Congratulations! (Now wait five days)
Related
I have a relatively simple question:
Is there a possibility to run an xslt-script on an android device? I have an .xml file, using a .xsl script to create a new .xml file.
On windows I am using saxon, which works good, but as I don´t have always access to it I would prefer to run a script on my android phone and/or android tablet.
I did some research with google and also on this site, but i didn´t found any clear answer.
thanks in advance and greetings
I have now found a way to run both Saxon-JS 2 or rather its command line tool xslt3 as well as Saxon HE Java from a command line terminal for Android.
I installed Termux, I had to use the version from F-Droid, as the one on the Google play store seems to be no longer supported, then in the Termux terminal shell I installed node and java (try to run with e.g. ˋnodeˋ and it will tell you the ˋpkg install ...ˋ command line to install, then I did e.g. ˋnpm install -g xslt3ˋ to install Saxon-JS's command line tool and downloaded the Saxon HE 11.2 Java zip from Sourceforge with wget and unzipped it and finally I am able to run e.g. xslt3 to run Saxon-JS or java -jar path-to-saxon11jar to run XSLT 3 (or in the case of Saxon Java of course XQuery too.
The interaction with the rest of the Android file system is a bit complicated to find out but the Linux Terminal shell has its own file system with a storage folder with sub folders like storage/download linked to the usual download folder other Android apps (e.g. your browser) use.
Here is a screenshot of Termux on my Android tablet showing the execution of Saxon HE 11 Java and Saxon-JS 2: .
It turns out the same procedure doesn't work quite as well on my Android phone which has Android 12 as the running Java and therefore Saxon HE 11 or any other Saxon Java HE currently does not work due to a known issue https://github.com/termux/termux-packages/issues/7332. But Node.js and npm and therefore Saxon-JS with xslt3 run fine on that phone.
I am trying to build or run an Ionic Cordova App. But it always builds a default app with playlists.
OS is Windows 10
I do the following from my command prompt:
c:\users\martijn\documents\ionic start testapp blank
c:\users\martijn\documents\testapp\ionic run android
now it is building a different app then in my app directory. When I do ionic serve I see the right app in my browser. Can't figure out why running or building gives me a different app, I think it is a default example app.
Can somebody help?
See link here:
https://github.com/driftyco/ionic-cli/issues/1283
Appears you may have to delete the the last apk file from platforms\android\build\outputs\apk
I am having issues getting a legacy mobile app to run in an emulator - it all seems to run in the browser without any issues but when I run the cordova emulate command the app attempts to install but I always get a white screen (nothing else) & the app isn't visible to use.
I am running Cordova CLI v5.0.0 although the app was made about a year ago so was developed in an older version of Cordova.
Can anyone suggest the best ways to debug this app to find the cause of the problem & why the problem only persists when I run the emulate command but seems fine in the browser?
-- update --
I have installed the Samsung drivers to allow me to connect my OnePlusOne device to adb, and I am know using the Android Studio program to collate errors etc..
In Android studio I can see the logs (see gist below):
https://gist.github.com/gkimpson/fbde0f5a7d1017daae17
Its quite long so added it externally - any ideas why I am having problems with my app?
-- update --
This line seems to be the problem
D/SystemWebChromeClient﹕ file:///android_asset/www/js/app/modules/stickers/stickers.js: Line 357 : Uncaught TypeError: window.requestFileSystem is not a function
The code in stickers.js is below for that section..
if (window.isDevice) {
window.requestFileSystem(window.PERSISTENT, 512, onInitFs, errorHandler);
} else {
callback(fc);
}
Ok here is what I had to do when I migrated from cordova 3.6 to cordova 5.
But first, I suggest you a little reading :
Cordova Android 4 release notes
Plugins switch to npm
The white list plugin documentation And in addition the CSP documentation
To sum-up, the security has changed in cordova, if you don't add the white list plugin your app will have no network access, and the plugins are now installed via npm instead of via git.
So what I did (a little bit hardcore maybe):
delete completly the platforms/android folder
delete the plugins folder (maybe before cordova plugins list if you don't have the list somewhere)
reinstall the plugins with the new name (most of external plugins haven't changed name, but all cordova plugins have) for example cordova-plugin-camera replaces org.apache.cordova.camera
add the white list plugin and configure it (or if you're not concerned about security, install the white list-legacy plugin which should work as previous versions)
add the android platform
and you can run cordova plugin save and cordova platform saveto have all your plugins and platforms saved in config.xml
I started PhoneGap today only. I have experience with native code but not with HTML5 stuff. I am comfortable with GUI so CLI is new to me.
So I am trying to build app in android. But it uploads data to remote site & as its my second app, Its says "Private app limit reached".
Is there any way to build file locally?? Like with no internet connection. Screenshot attached for further refrence. Thankyou in advance
If you look at the Android platform guide section of the PhoneGap documentation you'll get instructions for setting up your SDK locally.
Pay attention so that you got your PATH setup correctly, a quick way to verify that on windows is to type echo %PATH% in the command prompt. If you already had your command prompt open as you set PATH it'll not be reflected so you've to close cmd and open it again.
After the SDK is setup successfully and you got your PATH verified you should be able to do the following to run it:
phonegap install android
phonegap local build android
phonegap local run android --emulator
I'm trying to install my Phonegap application onto an Android AVD/Emulator. I have launched the AVD and it's registering as 5554:Nexus_S.
When using the Phonegap commands at the Windows prompt I am typing:
phonegap build android
phonegap install android
The output I get says it successfully installed the app onto the device, but it never shows up. This is the output of the install command:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] trying to install app onto device
cp: dest file already exists: C:\Users\username\app\platforms\android\assets\www\phonegap.js
[phonegap] successfully installed onto device
I've tried variations of targeting the device using options with no luck:
--device=5554
--target=5554
Any ideas?
I figured it out. You have to specify the --emulator= in the call, so the command looks like:
phonegap install --emulator=emulator-5554 android
You can find the name/id of your running emulators by running the list-started-emulators.bat under the /platforms/android/cordova/lib/ folder in your project.
Another quick note is that sometimes even when you have started the emulator phonegap will not recognize it... so you have to start it from phonegap bat file so that the right process number is registered. to do this.
Use the following command,
1. List-emulator-images.bat : This will display available emulator images you have
2. start-emulator : This will start the emulator which will register with phonegap.
Also make sure you are running all of this from and ADMIN Enabled command prompt.
Okay, I've solved my problem. This solution may not be applied to all, but I was suffering from the same problem as I've mentioned in the comments of the question.
What did I do wrong?
I made some changes in one of the plugins.
I was working on my app and added the Vibration plugin. I made some changes in the plugin, both in the generic version [your_project_root\plugins\org.apache.cordova.vibration\src\android\Vibration.java] and also in the platform specific version [your_project_root\platforms\android\src\org\apache\cordova\vibration\Vibration.java].
But when I reverted the changes back, everything went fine.
I say it again, this solution may not be generic but can be useful for at least my type of problem.
And this gives rise to another question, can't we make changes in the Plugins?I think it is totally fine to make changes in them. Maybe I had done something wrong.