add new plugin to phonegap 3.4 - ios

I'm trying to add new plugin (https://github.com/xu-li/cordova-plugin-wechat) to my phonegap project. but I get stuck on the installation number 1.
For number 1, they said Add wechat lib to your project. Don't forget to add the "URL Type". but I don't know where should I put library files to? which folder? because I know that every time I use cordova build ios command, it will generate new project files in platforms/ios. Should I put library files after generated?
Thank you.

Make sure you have install the required SDK. use command $ cordova platform add ios. Now add the generated files in the project folder. See if this works. Add Cordova command script file if required.

Related

How to add plugins for ios in phonegap?

I am new to phonegap.
Using phonegap app I have created new project.
Now I like to use this project in xcode (7.2.1) is it possible?
What is the best way to develop app in phonegap for various plugin ,I was googled and heard about coredova but can't understand exact needed .
For IOS Try this to add any new Plugin.
Go to your Created Project Directory in Mac CLI.
Then do this.
If you haven't added IOS Platform then run below command.
cordova platform add ios
Then build your whole project with below command.
cordova prepare ios
Then to add plugin run below command.
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
Here take whatever plugin you want to install.
Make sure you connected with internet while installing plugin.
Now I like to use this project in xCode (7.2.1) is it possible?*
Yes it is possible, Read this article
What is the best way to develop app in phonegap for various plugin
I am assuming you are asking how to add different plugins?
Create your APP with the PhoneGap Interface (You already did)
Go to the www folder where you stored the PG build files and look for your config.xml, then you will see a section where a few plugins already exists. You can add additional ones by just simply copying and pasting the below XML syntax (Battery Status Plugin), example:
<plugin name="cordova-plugin-battery-status" spec="1.1.0" source="pgb" />
Reference this article for a comprehensive list of PhoneGap's plugins:
https://build.phonegap.com/plugins
Alternatively, you can add them through the Command Line interface (See the first answer to your question)

Create IPA from a Cordova project with xcodebuild command

I'm trying to build a system which can compile a project given the source code (the Cordova SDK app project) and the optional provision settings, similiar to PhoneGap's Build. Behind the scenes I try to use the xcodebuild command to create the final IPA and return it to the user. All the projects developed using Cordova and prepared to be compiled with XCode with the following commands:
cordova platform add ios
cordova prepare ios
The problem is that the xcodebuild requires the project's schemes, which according to my search on the subject are generated only when you open the project with the XCode GUI.
Is there any way to generate the schemes for the project using command line tools only? Are the schemes are the same for every project so I can copy a static one to each project I want to compile?
I'm not really a XCode guy or Mac guy for that matter, so I'd be happy for a clear explanation for how and why the solution works, if there is one...
Edit:
Just to clarify my final intestions:
When I open the project using the XCode GUI (double click the .xcodeproj) it generates the schemes and then I can use the xcodebuild command successfully without any problem. But I need this system to be completely automated, so that the user can upload he's project built with the Cordova framework and have this system generate the IPA for him if he choose so. (He can also choose other platforms which are supported by the Cordova framework). Much like PhoneGap's build eventually.
You can generate the schemes programmatically using a build hook script that the Cordova CLI will run before building for iOS. I wrote a blog post on this here but here's a summary:
I chose to use the xcodeproj Ruby gem, you can get this with:
sudo gem install xcodeproj
Then create a hook script "fix_xcode_schemes.rb" in the hooks folder of your Cordova project, set it to 755 file permissions so that it is executable and put this in the script:
#!/usr/bin/env ruby
require 'xcodeproj'
xcproj = Xcodeproj::Project.open("platforms/ios/schemedemo.xcodeproj")
xcproj.recreate_user_schemes
xcproj.save
Adjust the platforms/ios/schemedemo.xcodeproj to match your project name.
Then to run the script edit your project's config.xml and add:
<platform name="ios">
<hook type="after_platform_add" src="hooks/fix_xcode_schemes.rb" />
...
</platform>
Full code and Github on the blog post I linked to. Here I use after_platform_add so the Cordova CLI will add the schemes after the iOS platform is added. For an existing project you may want to swap this for before_prepare or before_build to add the schemes if you don't want to remove and re-add the ios platform to use my original example. Cordova Hook documentation is here.

how add manually a cordova plugin to ios existing project

i've a cordova project created via cordova cli command.
i build the project for Android and iOS platform but... i copied the build project into respective workspace (eclipse/xcode) and i updated that single project.
Now i need to add a plugin.
The project into cordova project folder is now so outdate so i would add the plugin via cli and copy the plugin to the respective project.
I copied successfully the generated plugin into the android project, but i'm not able to do the same thing with iOS.
For example i added the console plugin for iOS
cordova plugin add org.apache.cordova.console
if i open and run the build project it work and i see my message in console, but if i try to copy the generated plugin into my existing project it doesn't work.
nobody could help me to understand how add manually a plugin into my existing project?
update
yes i know, i'll try to explain better
i have my cordova project under folder /Document/cordova
when i made an ios build via command line cordova put the built project under /Document/cordova/platforms/ios
well i copied the folder ios under /workspace/my-project-name
after some work under workspace i see that i need to add a cordova plugin.
i added the plugin via command line and it was added to /Document/cordova/platforms/ios
at this poin i have a project under /Document with plugin but asset outdated and one project updated without plugin under /workspace
i'm trying to copy from built project to /workspace project.
i copied
/workspace/my-project-name/my-project-name/Plugins
/workspace/my-project-name/my-project-name/config.xml
/workspace/my-project-name/www/plugins
/workspace/my-project-name/www/cordova.js
/workspace/my-project-name/www/cordova_plugins.js
but it doesn't work... i missed somethings?
After reading it several times I think I get more less the idea...
Well, I am not sure why do you want to copy the ios project outside the current location. I suppose you have a good reason to do it, however you can always tweak that project instead of going back and forward, cordova will not impact non cordova related files each time you run "cordova build".
Are you familiar with control versioning? Git, SVN, mercurial? If so it is simple just we which files were impacted once you add the plugin and copy those... If no, I suggest using control versioning anyways to help keep track of your code changes.
NOTE: Be aware if you build the cordova projet and then you just want to update the files noted above it is highly likely that it won't work, that is why you run "build" is not a simple file sync. I recommend taking the new cordova project with the plugin added and then just add you personal tweaks on the ios in the other folder. Or just tweak the ios folder inside platforms folder...
I hope you are doing for good reason. Anyway you are missing to copy below file to work
/workspace/my-project-name/my-project-name/platforms/ios/my-project-name/config.xml
Copying the cordova iOS platform folder is not a good idea. The reason is, cordova builds an Xcode project in the platform folder, and there is some sort of caching/built in references to absolute location of the original Xcode project. Therefore it would be unclear to you and to Xcode which file is being referenced from within Xcode. This may have caused some other unnoticed errors in the project as well. So therefore, instead of keeping original project path available along with the new path, I would recommend renaming the original project folder in order to remove the ambiguity. This way, you will assure that the right file versions are referenced.

Where can we place config.xml in IOS phone gap?

Hi I am new to IOS and Xcode. Can we use config.xml in IOS xcode? If we are using where can we place the config.xml. While creating my project I did not get config.xml. Is it will be a problem?
Using the latest versions of cordova tipically update the required files (config.xml) for you when you use the CLI with command
Cordova plugin add
The documentation explain specific tweaks to the config.xml
http://cordova.apache.org/docs/en/3.1.0/config_ref_index.md.html#The%20config.xml%20File
From the doc
For projects created with the Cordova CLI (described in The Command-line Interface The Command-line Interface), this file can be found in the top-level www directory. Using the CLI to build a project regenerates versions of this file in various subdirectories within platforms .Ifyou usetheCLI to create a project, but then shift your workflow to an SDK, the platform-specific file serves as a source.

Installing Phonegap on iOS

Recently I was trying to install Cordova onto my mac so I can compile for the iphone, but I ran into a problem. The option to create a Cordova project wasn't there on xcode. I looked online and saw that I needed to create the project through the terminal. I did this, but nothing was created as far as I can see.
On the terminal, after dragging the bin folder to the terminal I did: ./create /desktop/ios-program/ com.appname appname
Did I do something wrong? Thanks
here a complete guide is given to create phonegap environment in xcode
http://www.adobe.com/devnet/html5/articles/getting-started-with-phonegap-in-xcode-for-ios.html
if it is not enough than go for this
http://www.kendoui.com/blogs/archive/11-12-27/setup_your_phonegap_development_environment_on_mac.aspx
http://docs.phonegap.com/en/2.7.0/guide_getting-started_ios_index.md.html
These instructions are pretty clear, even if the directory tree you get after extracting the zip file is not exactly the one they show.
After installing all the requirements:
1. extract the content of phonegap-2.7.0.zip wherever you want
2. go to lib/ios/bin and run the create command with the suggested parameters.
3. open the finder and go to the directory you used as first parameter
4. doubleclick the file with extension xcodeproj to open XCode and the project will be automatically created
Make sure that you are inside \phonegap-2.7.0\lib\ios\bin before entering ./create command.
Refer the Blog Tutorial

Resources