cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [13/43] git commit: [CB-3057] Change iOS platform to default to ARC.
Date Thu, 09 May 2013 23:00:15 GMT
[CB-3057] Change iOS platform to default to ARC.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/548ae527
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/548ae527
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/548ae527

Branch: refs/heads/master
Commit: 548ae5271a3c651aa342a0f1d8b162d19c34310e
Parents: be6d2ed
Author: Michal Mocny <mmocny@gmail.com>
Authored: Wed Apr 17 16:48:19 2013 -0400
Committer: Michal Mocny <mmocny@gmail.com>
Committed: Wed Apr 17 16:48:19 2013 -0400

----------------------------------------------------------------------
 lib/cordova-ios/bin/create                         |   13 +++++++-
 .../project/__TESTING__/Classes/AppDelegate.m      |   22 +++++++++++---
 src/platform.js                                    |    3 +-
 3 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/548ae527/lib/cordova-ios/bin/create
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/bin/create b/lib/cordova-ios/bin/create
index bef0f57..d617f09 100755
--- a/lib/cordova-ios/bin/create
+++ b/lib/cordova-ios/bin/create
@@ -31,8 +31,9 @@
 set -e
 
 function usage() {
-  echo "Usage: $0 [--shared] <path_to_new_project> <package_name> <project_name>"
+  echo "Usage: $0 [--shared] [--arc] <path_to_new_project> <package_name> <project_name>"
   echo "	--shared (optional): Link directly against the shared copy of the CordovaLib instead
of a copy of it."
+  echo "	--arc (optional): Enable ARC."
   echo "	<path_to_new_project>: Path to your new Cordova iOS project"
   echo "	<package_name>: Package name, following reverse-domain style convention"
   echo "	<project_name>: Project name"
@@ -40,10 +41,15 @@ function usage() {
 }
 
 USE_SHARED=0
+USE_ARC=0
 if [[ $1 == "--shared" ]]; then
     USE_SHARED=1
     shift;
 fi
+if [[ $1 == "--arc" ]]; then
+    USE_ARC=1
+    shift;
+fi
 
 # check whether it is a proper create command (at least 3 arguments)
 if [ $# -lt 3 ]; then
@@ -59,7 +65,7 @@ done
 
 BINDIR=$( cd "$( dirname "$SCRIPT" )" && pwd )
 CORDOVALIB_DIR="$BINDIR/../CordovaLib"
-CDV_VER=$(cat $CORDOVALIB_DIR/VERSION)
+CDV_VER=$(cat "$CORDOVALIB_DIR/VERSION")
 
 PROJECT_PATH=$1
 PACKAGE=$2
@@ -134,3 +140,6 @@ else
     "$BINDIR/update_cordova_subproject" "$R.xcodeproj/project.pbxproj" "$PROJECT_PATH/CordovaLib/CordovaLib.xcodeproj/project.pbxproj"
> /dev/null
 fi
 
+if [[ $USE_ARC = 1 ]]; then
+    /usr/bin/sed -i '' 's/CLANG_ENABLE_OBJC_ARC = NO/CLANG_ENABLE_OBJC_ARC = YES/' "$R.xcodeproj/project.pbxproj"
> /dev/null
+fi

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/548ae527/lib/cordova-ios/bin/templates/project/__TESTING__/Classes/AppDelegate.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/bin/templates/project/__TESTING__/Classes/AppDelegate.m b/lib/cordova-ios/bin/templates/project/__TESTING__/Classes/AppDelegate.m
index 318f793..5c05ac8 100644
--- a/lib/cordova-ios/bin/templates/project/__TESTING__/Classes/AppDelegate.m
+++ b/lib/cordova-ios/bin/templates/project/__TESTING__/Classes/AppDelegate.m
@@ -45,7 +45,11 @@
 
     int cacheSizeMemory = 8 * 1024 * 1024; // 8MB
     int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
-    NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory
diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
+#if __has_feature(objc_arc)
+        NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory
diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
+#else
+        NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory
diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease];
+#endif
     [NSURLCache setSharedURLCache:sharedCache];
 
     self = [super init];
@@ -61,10 +65,18 @@
 {
     CGRect screenBounds = [[UIScreen mainScreen] bounds];
 
-    self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
+#if __has_feature(objc_arc)
+        self.window = [[UIWindow alloc] initWithFrame:screenBounds];
+#else
+        self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
+#endif
     self.window.autoresizesSubviews = YES;
 
-    self.viewController = [[[MainViewController alloc] init] autorelease];
+#if __has_feature(objc_arc)
+        self.viewController = [[MainViewController alloc] init];
+#else
+        self.viewController = [[[MainViewController alloc] init] autorelease];
+#endif
     self.viewController.useSplashScreen = YES;
 
     // Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
@@ -99,8 +111,8 @@
 }
 
 // repost the localnotification using the default NSNotificationCenter so multiple plugins
may respond
-- (void)           application:(UIApplication*)application
-   didReceiveLocalNotification:(UILocalNotification*)notification
+- (void)            application:(UIApplication*)application
+    didReceiveLocalNotification:(UILocalNotification*)notification
 {
     // re-post ( broadcast )
     [[NSNotificationCenter defaultCenter] postNotificationName:CDVLocalNotification object:notification];

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/548ae527/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index a5db481..1862f72 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -86,11 +86,12 @@ module.exports = function platform(command, targets, callback) {
                         // TODO: eventually refactor to allow multiple versions to be created.
                         // Run platform's create script
                         var bin = path.join(cordova_util.libDirectory, 'cordova-' + target,
'bin', 'create');
+                        var args = (target=='ios') ? '--arc' : '';
                         var pkg = cfg.packageName().replace(/[^\w.]/g,'_');
                         var name = cfg.name().replace(/\W/g,'_');
                         // TODO: PLATFORM LIBRARY INCONSISTENCY: order/number of arguments
to create
                         // TODO: keep tabs on CB-2300
-                        var command = util.format('"%s" "%s" "%s" "%s"', bin, output, (target=='blackberry'?name:pkg),
name);
+                        var command = util.format('"%s" %s "%s" "%s" "%s"', bin, args, output,
(target=='blackberry'?name:pkg), name);
 
                         shell.exec(command, {silent:true,async:true}, function(code, create_output)
{
                             if (code > 0) {


Mime
View raw message