Changes disappearing when building Cordova app for ios - ios

I'm an absolute beginner with Cordova and was following this tutorial when I started experiencing my problem.
The tutorial is more aimed at building the project for android but I applied the same steps to create an ios build on my mac.
danieloram CordovaProject $ cordova run ios
the default project builds and runs fine but whenever I edit either the index.html or cordova.js files in the ios directory of the platforms folder and run the above command (or cordova build ios), all my changes revert back to the default code.. This behaviour isn't mentioned anywhere that I can see in the linked tutorial.
Am I missing something really obvious?
I haven't been able to find anything online about any other users experiencing this issue.. so I'm inclined to think it is trivial.

Seems I found my answer, and a quick one at that.
The tutorial did not explicitly state which index.html file I was to edit so I naturally assumed it was the file nested inside the platforms/ios directory.
These file however should not be edited as they are overwritten using the outermost index.html file in the myapp/www/ folder.
This SO answer sums it up perfectly with more detail.

Related

How can you permanently change iOS app configuration in Meteor Cordova?

Every time I meteor build, I have to open XCode and do the following:
remove and add an item from "Link Binary With Libraries" (Facebook SDK)
add a URL Type (custom URL scheme for my app)
add a "Required device capabilities" to "Custom iOS Target Properties"
How can I edit my Meteor project to have these steps done automatically, and to auto add things to AndroidManifest.xml?
In some way use mobile-config.js or cordova-build-override?
I'm happy to see another guy who is trying to build a hybrid application using Meteor / extending a Meteor Cordova iOS app, since I'm facing the very same issues. So I'm very happy to share my experiences and approaches with you. :-)
So far, I ended up with the following approach:
I created a base template for my iOS app using meteor build (not meteor run ios-device, since I did not know if Meteor does some optimizations for production code).
Then, I copied the whole Xcode project under /platforms/ios to another loaction and used this new project as my "master" project from then on. This project is being enriched with native code, e.g. it also includes the Cocoa Pods I'm needing.
Of course, I also did not want to copy files each and every time I trigger a new Meteor build. At least, I would like to have the Staging/www folder updated, as this is happening quite frequently.
So my first (rather naive) approach was
delete the Staging/www folder in the master project
replace it with a relative link (using Xcode's linking functionality) to the Staging/www folder inside the .meteor/local/.../ios/ project
This approach did not work, since the shell script used in the Meteor Xcode project can't handle these links.
My second approach is to create a symlink on the filesystem level instead. This works as it should, and I'm able to build the project in Xcode as it should.
I could have followed the same approach for the Cordova plugins folder, but I've decided to replace the plugins manually in order to get a better control over them, even it means a bit more effort then.
Having the symlink in place also means that Xcode's version management (and also SVN which I am using for everything) will ignore everything below Staging/www, which is good in my opinion, because I'm already versioning the webapp code in the Meteor project itself.
BTW: I've started a discussion thread on hybrid mobile app on the Meteor forums as well, but so far it did not get too much attraction:
https://forums.meteor.com/t/building-a-hybrid-meteor-cordova-app-share-experiences/8212
Maybe we could follow up on Meteor-specific things there, to have the Meteor community participate in the discussion?
EDIT: I would also like to share an approach that failed completely, at least for me, maybe I was too dumb... Before I used Meteor's Xcode template as the starting point, I also tried it "the other way round", i.e. I started with my already existing Xcode app project and tried to include Meteor's / Cordova's part by hand. Using this approach, I never managed to set everything up correctly. I had lots of troubles and also had to tweak a lot of the compiler / linker flags to even get the code compiling. This grew me a lot of gray hairs. But even after I managed to get everything to compile, Meteor hang during startup - and I never figured out why.
One remaining problem I'm still facing is that Meteor's hot code push functionality seems to have some severe issues on iOS, that are also documented as GitHub issues. It can happen that the iOS app gets completely broken and needs to be reinstalled. I tried the mdg:reload-on-resume package, but this did not work as it should and made things even worse. As far as I can tell from the GitHub discussions, one should better disable hot code push until the Meteor team has addressed these issues. Breaking the app completely due to code pushes is not what my users would expect.
Unfortunately plist values (and assumably AndroidManifest.xml as well) can only be changed by a plugin:
Add entry to iOS .plist file via Cordova config.xml

phonegap.js (cordova.js) functionality missing, or invalid

Ok, trying to build out my first phonegap based project and I am coming to a point where I need to start tieing into the device such as the camera. Which I can't do due to errors like:
Can't find variable: FileUploadOptions
Which I have found means that I have to have this js file called phonegap.js. Which from what I have learned generates at the time of building out your app. However. Sometime in the recent past support for phonegap.js has been removed, and cordova.js is now apparently the file that replaces it. Which this did generate. However the function above for example, fails because there is no reference to such a function/class anywhere in cordova.js yet the cordova docs/help point to phonegap docs.. which tell you to include this plugin (which I do) and tells me how to do things which I follow to a letter so I can first try to get it working. So, this continues to fail.
I go out and find a copy of a phonegap.js but its useless to me as its an older version concept. 1.9.0 (and who knows which platform it was generated for) Either way for giggles I try with that one I get a syntax error. Soooo..
Can someone for the sake of my sanity tell me, one, why is it so hard for the docs to describe these things. two.. If the file is supposed to generate, but doesn't yet its required, what does one do?
It's been a long time since you asked your question so I will answer for PhoneGap version 3.3.
You need to build your project for iOS with phonegap local build ios. Then the phonegap.js file will in $PROJECT_ROOT/platforms/ios/www directory.
Make sure you include phonegap.js in your index.html file, near the bottom so that it is after any dependencies.
<script type="text/javascript" src="phonegap.js"></script>
You may see warnings that cordova.js is not found, but this is ok as long as you have phonegap.js.
For reference, Apache Cordova is an open source project and PhoneGap offers some extra features on top of Cordova.

How to deploy a SenchaTouch App with Cordova?

A friend send me the code of a SenchaTouch App (v2.0) he made. I should make some changes as the performance is not so good. To start, I want to "deploy" the App on my iPad and see where its slow. He told me that he didn't use SenchaCmd and the Cordova version seems a little bit older, too. In the picture below you can see the project structure. How can I deploy the App to my iPad (there are no XCode project files in these folders)? In the future I will do a complete refactoring of the App but for the moment he wants me to do some little performance tweeks with his code... Any suggestions?
Andres commnt was the correct hint. I could just create a new cordova/phonagap project with the command line and then put the contents of the folder in the www directory.

Doing a make on OSX using Xcode 4.5.2 with the Makefile supplied with PhoneGap 2.3.0 doesn't create the PhoneGapLibInstaller.pkg file

I downloaded the latest version of Phonegap for IOS and ran "make" from Terminal. I ran make in the following subdir.
phonegap-2.3.0/lib/ios
I get these two lines back on stdout:
Xcode.app: '/Applications/Xcode.app'
Using Developer folder: '/Applications/Xcode.app/Contents/Developer'
and my shell prompt is back.
However, no PhoneGapLibInstaller.pkg file is created as it describes on the github site instructions.
https://github.com/infil00p/phonegap-iphone
The file wasn't in my ios directory but when I did a search on my entire hard drive there is nothing there. I wanted to check in case it put it in the Xcode.app package contents for some reason.
In case this make file did something other than in the guides and actually worked, I loaded Xcode but PhoneGap doesn't show up as a Framework/template to choose from when making a new package.
Any thoughts or suggestions?
Thanks,
Dano
That Github repo is from 3 years ago. You would probably be better off looking at the actual current documentation.
Adobe "value add" distribution page: http://phonegap.com
Docs: http://docs.phonegap.com
Latest Cordova information (the open source project PhoneGap is based on): http://cordova.apache.org/
Current Github: https://github.com/apache/cordova-ios

Phonegap - gap in tutorial for iOS?

Despite the title, I fully expect this to be a user error.
I've done mostly native Android development, and now I'm trying to get an HTML5/Phonegap application going on iOS. I'm following the extended "getting started" tutorial Here. I get the application up and running on a physical test device, but my phonegap functionality is non-responsive, so something is amiss.
Take a look at the following screenshots from the tutorial, we'll call this step 3:
The screenshot above is what my project looks like at this point. I see the PhoneGap.framework in there, so I'm feeling optimistic. Step 4 says, drag your "WWW" folder into your project, which I did (assuming the red box indicates the landing zone), and I was prompted with the screenshot presented in the tutorial, I selected the same options..
Step 5 shows the screenshot above. Notice the differences:
PhoneGap.framework isn't there anymore
There is another project in the workspace called PhoneGapLib.xcodeproj
There was only one simple step in between, yet the project looks very different. It seems to me, that more things happened than just dragging the www folder?? I know thousands of people are using PhoneGap with iOS, so I'm hoping one of you can shine a light on what went wrong here.
Ok, looks like this was indeed a user error. When you create the PhoneGap project, you're supposed to run a build before you do anything. This generates the www folder, but doesn't actually add it to your project. You have to go to the folder location where your app resides, and drag the created www folder into the project.
I was dragging my own www folder that already had my code that works in Android. Not sure why this didn't work.
In my defense, even now that it's working, my project doesn't look like the screenshot above with the additional phonegap project. Either way - I hope this saves someone some time...

Resources