Well, I am pretty new to phone gap. A day back, I got it installed on MAC OSX 10.7.1 with Xcode version 4.2.
First thing, I couldn’t see an option in my Xcode to create phone gap application. However I can make it happen using terminal. (Later came to know, that is how it works on this version, probably).
Second, I followed this tutorial and tried to add plugins. When I compile, it gives me fatal error. 'CDVPlugin.h' file not found. But i could see it in the Cordovalib.xcodeproj
In NativeControls.h
#import <Cordova/CDVPlugin.h>
#else
#import "CDVPlugin.h"
#endif
So can anyone please point out what I am doing wrong? Should I need to add CDVPlugin.h and related files again?
The compilation worked after modifying both the files NativeControls.h and NativeControls.m:
Modified NativeControls.h:
//
// NativeControls.h
//
//
// Created by Jesse MacFadyen on 10-02-03.
// MIT Licensed
// Originally this code was developed my Michael Nachbaur
// Formerly -> PhoneGap :: UIControls.h
// Created by Michael Nachbaur on 13/04/09.
// Copyright 2009 Decaf Ninja Software. All rights reserved.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UIKit/UITabBar.h>
#import <UIKit/UIToolbar.h>
//#ifdef PHONEGAP_FRAMEWORK
#import <Cordova/CDVPlugin.h>
//#else
//#import "CDVPlugin.h"
//#endif
#interface NativeControls : CDVPlugin <UITabBarDelegate, UIActionSheetDelegate> {
UITabBar* tabBar;
NSMutableDictionary* tabBarItems;
UIToolbar* toolBar;
UIBarButtonItem* toolBarTitle;
NSMutableArray* toolBarItems;
CGRect originalWebViewBounds;
}
/* Tab Bar methods
*/
- (void)createTabBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)showTabBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)hideTabBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)showTabBarItems:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)createTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)updateTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)selectTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
/* Tool Bar methods
*/
- (void)createToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)resetToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)setToolBarTitle:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)createToolBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)showToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)hideToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
/* ActionSheet
*/
- (void)createActionSheet:(NSArray*)arguments withDict:(NSDictionary*)options;
#end
Modifications in the file NativeControls.m: in line 22, change PGPlugin to CDVPlugin
Hope this will help.
In Cordova 2.1 (only)
I got around this error by simply commenting out if/else for a given PushNotification plugin
#import <Foundation/Foundation.h>
//#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
//#else
//#import "CDVPlugin.h"
//#endif
#import <EventKitUI/EventKitUI.h>
#import <EventKit/EventKit.h>
Related
is there any best way to listout Property of Contact in detail?
like it is working in IOS 6.1 and earlier Version.
//
// ABPersonViewController.h
// AddressBookUI
//
// Copyright (c) 2010 Apple Inc. All rights reserved.
//
#import <UIKit/UIViewController.h>
#import <AddressBook/AddressBook.h>
#interface ABPersonViewController : UIViewController <UIViewControllerRestoration>
// ABPersonViewController does not support subclassing in iOS 7.0 and later. A nil instance will be returned.
i found a solution :please see source
there is some deprecated functions but we can resolve it,
by replace Below function in "ABContactsHelper" Class
+ (ABAddressBookRef) addressBook
{
#ifdef __IPHONE_6_0
return ABAddressBookCreateWithOptions(NULL, NULL);
#else
return ABAddressBookCreate();
#endif
}
Use it where "ABAddressBookCreate()" is Called.
Like
ABAddressBookRef addressBook = [ABContactsHelper addressBook];
I tried to compile a tweak using theos, an amazing framework to create tweaks easily on many different platform. Here I am trying to show a settings icon every time I respring and slowly fade it out but it is failing to compile. I have all the needed headers and frameworks and am running a real Mac (Despite the name u see on my terminal :P) with the latest Xcode installed and a previous install of the Xcode 4.2. This is the tweak.xm:
#import <UIKit/UIKit2.h>
#import <objc/runtime.h>
#import <SpringBoard/SpringBoard.h>
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <substrate2.h>
#import <IOSurface/IOSurface.h>
#import <QuartzCore/QuartzCore2.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CaptainHook/CaptainHook.h>
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <AVFoundation/AVAudioPlayer.h>
#import <Celestial/Celestial.h>
#import <SpringBoardServices/SpringBoardServices.h>
#import <CoreFoundation/CFNotificationCenter.h>
#import <ChatKit/ChatKit.h>
%hook CKConversationListController
- (void)composeButtonClicked:(id)clicked {
}
%end
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
NSArray *animationArray = [NSArray arrayWithObjects:[UIImage imageNamed:#"/Applications/Preferences.app/BlobIcon#2x.png"], nil];
[NSTimer scheduledTimerWithTimeInterval:.75 target:self selector:#selector(crossfade) userInfo:nil repeats:YES];
mainImageView.animationImages = animationArray;
mainImageView.animationDuration = 4.5; //mainImageView is instance of UIImageView
mainImageView.animationRepeatCount = 0;
[mainImageView startAnimating];
CABasicAnimation *crossFade = [CABasicAnimation animationWithKeyPath:#"contents"];
crossFade.autoreverses = YES;
crossFade.repeatCount = 1;
crossFade.duration = 1.0;
}
%new
- (void) crossfade {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; // user dependent transition acn be set here
mainImageView.alpha = !mainImageView.alpha;
[UIView commitAnimations];
}
%end
And the makefile looks like this:
include theos/makefiles/common.mk
export GO_EASY_ON_ME=1
TWEAK_NAME = Goofy
Goofy_FILES = Tweak.xm
Goofy_FRAMEWORKS = Foundation UIKit CoreGraphics ChatKit
Goofy_PRIVATE_FRAMEWORKS = ChatKit VoiceServices AppSupport
include $(THEOS_MAKE_PATH)/tweak.mk
I am keeping on getting
Making all for tweak Goofy...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Tweak.xm: In function ‘void _logos_method$_ungrouped$SpringBoard$applicationDidFinishLaunching$(SpringBoard*, objc_selector*, objc_object*)’:
Tweak.xm:32: error: ‘mainImageView’ was not declared in this scope
Tweak.xm: In function ‘void _logos_method$_ungrouped$SpringBoard$crossfade(SpringBoard*, objc_selector*)’:
Tweak.xm:53: error: ‘mainImageView’ was not declared in this scope
make[2]: *** [.theos/obj/Tweak.xm.o] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [Goofy.all.tweak.variables] Error 2
Hackint0sh-HD:Goofy iHackerMe$
What am I missing here?
The problem is that mainImageView hasn't been declared as anything...
Just do UIImageView *mainImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"/Applications/Preferences.app/BlobIcon#2x.png"]];
Unless you're trying to move an object that is already on the lockscreen like say the clock, in that case you'd need to find out what the object is, include it in the file using #import and then animating it like you have already.
Please help me in this what I am trying to do is I have
a Cocoa application with webkit in it.
an HTML5 based web application with local database.
I am trying to run this HTML5 application in cocoa application and get this error "Error: Unknown error Error: SECURITY_ERR: DOM Exception 18." same application is working fine in
Safari
iphone safari
UIWebkit
I have tried following things
#interface WebPreferences (WebPreferencesPrivate)
- (void) _setLocalStorageDatabasePath:(NSString *)path;
- (void) setDatabasesEnabled: (BOOL) databaseEnabled;
- (void) setLocalStorageEnabled: (BOOL) localStorageEnabled;
#end
WebPreferences* prefs = [self.mainWebVEW preferences];
[prefs _setLocalStorageDatabasePath:appdir];
[prefs setDatabasesEnabled:YES];
[prefs setLocalStorageEnabled:YES];
[prefs setDefaultFontSize:20];
only preference that seem working is font size.
Can anybody help me how to get over this?
Thanks in advance
Regards
Ankit
ok so finally resolved it all you have to do is use one more private API
#interface WebView(WebViewPrivate)
- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(id) origin database:(NSString *)databaseIdentifier;
#end
- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(id) origin database:(NSString *)databaseIdentifier
{
static const unsigned long long defaultQuota = 5 * 1024 * 1024;
if ([origin respondsToSelector: #selector(setQuota:)]) {
[origin performSelector:#selector(setQuota:) withObject:[NSNumber numberWithLongLong: defaultQuota]];
} else {
NSLog(#"could not increase quota for %#", defaultQuota);
}
}
I am using conditional code as below,
I want to run certain code only in ios5.0 and > ios5.0( i mean i want to support ios5.0 and 5.1 version too)
But the below condition dos not seem to work. ( Currently my development version is 5.1 but the below snippet is not getting identified.the control is not going into it.)
Please let me know your thoughts
#ifdef __IPHONE_5_0_OR_LATER
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0
// iPhone 5.0 code here
#endif
#define __IPHONE_2_0 20000
#define __IPHONE_2_1 20100
#define __IPHONE_2_2 20200
#define __IPHONE_3_0 30000
#define __IPHONE_3_1 30100
#define __IPHONE_3_2 30200
#define __IPHONE_4_0 40000
#define __IPHONE_4_1 40100
#define __IPHONE_4_2 40200
#define __IPHONE_4_3 40300
#define __IPHONE_5_0 50000
#define __IPHONE_5_1 50100
#define __IPHONE_NA 99999 /* not available */
How to target a specific iPhone version?
#ifdef is a compile directive, thus it will be evaluated at compile time not run time.
Thus if you add this to you code, the methods call in the if will all ways be called if your target SDK matches your #ifdef. So if you compile an app for both iOS 4 and 5 and place all the 5 only methods in #ifdef io5 the app will crash on iOS 4 since the methods will be called.
If you want to check if some method is available then you should do like :
Here is an example for dismissing an modal view controller from it's parent. Since parentViewController is changed to presentingViewController in iOS 5, we check if presentingViewController is available and use it.
if ([self respondsToSelector:#selector(presentingViewController)]) {
[self.presentingViewController dismissModalViewControllerAnimated:YES];
} else {
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
The same with goes for checking if a class is available :
if ([MPNowPlayingInfoCenter class]) {
MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
NSDictionary *songInfo = /* ... snip ... */;
center.nowPlayingInfo = songInfo;
}
NSArray *versionCompatibility = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:#"."];
if ( 5 == [[versionCompatibility objectAtIndex:0] intValue] ) { /// iOS5 is installed
// Put iOS-5 code here
} else { /// iOS4 is installed
// Put iOS-4 code here
}
I want to disable WebView's contextmenu "Reload", "Open Link", "Open Link in new Window", "Download link" etc..
I've tried a really long time, this method with contextMenuItemsForElement, but no matter how I try do not work
I really feel very sad, I hope someone can help me, I would be very grateful.
The following is my code:
#class WebView;
#interface UIWebView (Client)
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItem;
#end
#implementation UIWebView (Client)
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element
defaultMenuItems:(NSArray *)defaultMenuItems
{
NSLog(#"contextMenuItemsForElement");
return nil;
}
#end
Why are not working?
I don't think webView:contextMenuItemsForElements: is available in the iPhone SDK (or at least publicly).
If you have control over the html/css code, you can put this rule in your css
a {
-webkit-touch-callout: none !important;
}
and if it isn't possible, try
[yourWebView stringByEvaluatingJavascriptFromString:#"var a = document.getElementsByTagName('a'); for (var i = 0; i < a.length; i++) { a.style.WebkitTouchCallout = 'none'; }"];
in your webViewDidFinishLoad: method.
Here is a solution to disable long press context menu using UIKit Overrides for menu building and validation. Add this in your ViewController.m file
-(void)buildMenuWithBuilder:(id<UIMenuBuilder>)builder {
NSLog(#"%#", builder);
[builder removeMenuForIdentifier:UIMenuLookup];
[builder removeMenuForIdentifier:UIMenuShare];
[builder removeMenuForIdentifier:UIMenuStandardEdit];
}
Note: import UIKit #import <UIKit/UIKit.h>