cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [84/91] [abbrv] git commit: [ios] added support for weakly linked frameworks
Date Mon, 04 Mar 2013 19:32:50 GMT
[ios] added support for weakly linked frameworks


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/9ca3c8fb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/9ca3c8fb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/9ca3c8fb

Branch: refs/heads/master
Commit: 9ca3c8fb4a707f7f6bdb90c1d35fcfd7b189e316
Parents: 2e92055
Author: Brett Rudd <brettrudd@gmail.com>
Authored: Sun Feb 17 16:53:36 2013 -0800
Committer: Brett Rudd <brettrudd@gmail.com>
Committed: Sun Feb 17 18:20:34 2013 -0800

----------------------------------------------------------------------
 README.md                            |    8 +++++-
 platforms/ios.js                     |    6 +++-
 test/ios-install.js                  |   31 ++++++++++++++++++++++++++++-
 test/plugins/ChildBrowser/plugin.xml |    2 +
 4 files changed, 42 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9ca3c8fb/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index b530e61..942fcf4 100644
--- a/README.md
+++ b/README.md
@@ -310,13 +310,17 @@ of this document will likely merge these elements with `source-file`.
 
 ### &lt;framework&gt;
 
-Identifies a framework (usually part of the OS/platform) that the plugin depends
-on. Example:
+Identifies a framework (usually part of the OS/platform) that the plugin depends on.
+
+Examples:
 
     <framework src="libsqlite3.dylib" />
+    <framework src="social.framework" weak="true" />
 
 plugman identifies the framework through the `src` attribute and attempts to add the framework
to the Cordova project, in the correct fashion for a given platform.
 
+The optional `weak` attribute is a boolean denoting whether the framework should be weakly-linked.
Default is `false`.
+
 ## Variables
 
 In certain cases, a plugin may need to make configuration changes dependent on

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9ca3c8fb/platforms/ios.js
----------------------------------------------------------------------
diff --git a/platforms/ios.js b/platforms/ios.js
index 2d0e473..ae550fb 100644
--- a/platforms/ios.js
+++ b/platforms/ios.js
@@ -131,10 +131,12 @@ exports.handlePlugin = function (action, project_dir, plugin_dir, plugin_et)
{
     });
 
     frameworks.forEach(function (framework) {
-        var src = framework.attrib['src'];
+        var src = framework.attrib['src'],
+            weak = framework.attrib['weak'];
 
         if (action == 'install') {
-            xcodeproj.addFramework(src);
+			var opt = { weak: (weak && weak.toLowerCase() == 'true') };
+            xcodeproj.addFramework(src, opt);
         } else {
             xcodeproj.removeFramework(src);
         }

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9ca3c8fb/test/ios-install.js
----------------------------------------------------------------------
diff --git a/test/ios-install.js b/test/ios-install.js
index 1940c87..7292b67 100644
--- a/test/ios-install.js
+++ b/test/ios-install.js
@@ -173,7 +173,7 @@ exports['should edit the pbxproj file'] = function (test) {
     obj = xcode.project(projPath).parseSync();
     var fileRefSection = obj.hash.project.objects['PBXFileReference'],
         fileRefLength = Object.keys(fileRefSection).length,
-        EXPECTED_TOTAL_REFERENCES = 92; // magic number ahoy!
+        EXPECTED_TOTAL_REFERENCES = 96; // magic number ahoy!
 
     test.equal(fileRefLength, EXPECTED_TOTAL_REFERENCES);
     test.done();
@@ -185,6 +185,7 @@ exports['should add the framework references to the pbxproj file'] = function
(t
     var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
         projContents = fs.readFileSync(projPath, 'utf8'),
         projLines = projContents.split("\n"),
+		weak_linked = "settings = {ATTRIBUTES = (Weak, ); };",
         references;
 
     references = projLines.filter(function (line) {
@@ -194,9 +195,37 @@ exports['should add the framework references to the pbxproj file'] =
function (t
     // should be four libsqlite3 reference lines added
     // pretty low-rent test eh
     test.equal(references.length, 4);
+    test.ok(references[0].indexOf(weak_linked) == -1);
     test.done();
 }
 
+exports['should add the framework references with weak option to the pbxproj file'] = function
(test) {
+    // run the platform-specific function
+    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
+        projContents = fs.readFileSync(projPath, 'utf8'),
+        projLines = projContents.split("\n"),
+		weak_linked = "settings = {ATTRIBUTES = (Weak, ); };",
+        references;
+
+    weak_references = projLines.filter(function (line) {
+        return !!(line.match("social.framework"));
+    })
+
+    non_weak_references = projLines.filter(function (line) {
+        return !!(line.match("music.framework"));
+    })
+
+    // should be four libsqlite3 reference lines added
+    // pretty low-rent test eh
+    test.equal(weak_references.length, 4);
+    test.ok(weak_references[0].indexOf(weak_linked) != -1);
+    
+	test.equal(non_weak_references.length, 4);
+    test.ok(non_weak_references[0].indexOf(weak_linked) == -1);
+	test.done();
+}
+
 exports['should not install a plugin that is already installed'] = function (test) {
     ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
 

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9ca3c8fb/test/plugins/ChildBrowser/plugin.xml
----------------------------------------------------------------------
diff --git a/test/plugins/ChildBrowser/plugin.xml b/test/plugins/ChildBrowser/plugin.xml
index 1f12d5c..f7fd2ca 100644
--- a/test/plugins/ChildBrowser/plugin.xml
+++ b/test/plugins/ChildBrowser/plugin.xml
@@ -58,5 +58,7 @@
 
         <!-- framework for testing (not actual dependency of ChildBrowser -->
         <framework src="libsqlite3.dylib" />
+        <framework src="social.framework" weak="true" />
+        <framework src="music.framework" weak="rabbit" />
     </platform>
 </plugin>


Mime
View raw message