-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plugin.xml): generate ios references based on build target
- Loading branch information
1 parent
cac6a12
commit 67d70cf
Showing
3 changed files
with
176 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
var gulp = require('gulp'); | ||
var fs = require('fs'); | ||
|
||
//generate plugin.xml for use as a cordova plugin | ||
//here we explode the contents of the frameworks | ||
gulp.task('gen-npm-plugin-xml', function(){ | ||
var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); | ||
|
||
var files = []; | ||
var root = 'src/ios/dependencies/'; | ||
files = files.concat(emitFiles(root + 'Fabric/')); | ||
files = files.concat(emitFiles(root + 'Branch-SDK/')); | ||
files = files.concat(emitFiles(root + 'Branch-SDK/Requests/')); | ||
|
||
var newLineIndent = '\n '; | ||
xml = xml.replace('<!--[Branch Framework Reference]-->', newLineIndent | ||
+ files.join(newLineIndent)); | ||
|
||
fs.writeFileSync('plugin.xml', xml); | ||
}); | ||
|
||
//generate plugin.xml for local development | ||
//here we reference the frameworks instead of all the files directly | ||
gulp.task('gen-dev-plugin-xml', function(){ | ||
var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); | ||
|
||
xml = xml.replace('<!--[Branch Framework Reference]-->', | ||
'<framework custom="true" src="src/ios/dependencies/Branch.framework" />'); | ||
|
||
fs.writeFileSync('plugin.xml', xml); | ||
}); | ||
|
||
//emit array of cordova file references for all .h/.m files in path | ||
function emitFiles(path){ | ||
var ret = []; | ||
for(filename of fs.readdirSync(path)){ | ||
var fileType = null; | ||
if(filename.match(/\.m$/)){ | ||
fileType = 'source'; | ||
}else if(filename.match(/\.h$/) || filename.match(/\.pch$/)){ | ||
fileType = 'header'; | ||
} | ||
if(fileType){ | ||
ret.push('<' + fileType + '-file src="' + path + filename + '" />'); | ||
} | ||
} | ||
ret.push(''); | ||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
The MIT License (MIT) | ||
Copyright (c) 2015 Branch Metrics, Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--> | ||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
id="io.branch.sdk" | ||
version="2.1.10"> | ||
|
||
<name>branch-cordova-sdk</name> | ||
<description>Branch SDK Plugin</description> | ||
<license>Apache 2.0</license> | ||
<keywords>cordova,branch</keywords> | ||
<repo>https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git</repo> | ||
<issue>https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues</issue> | ||
|
||
<dependency | ||
id="es6-promise-plugin" | ||
url="https://github.com/vstirbu/PromisesPlugin.git"> | ||
</dependency> | ||
|
||
<js-module src="www/branch.js" name="Branch"> | ||
<clobbers target="Branch" /> | ||
</js-module> | ||
|
||
<preference name="BRANCH_KEY" /> | ||
<preference name="URI_SCHEME" /> | ||
|
||
<!-- Hooks --> | ||
<hook src="hooks/afterPrepareHook.js" type="after_prepare" /> | ||
<hook src="hooks/beforePluginInstallHook.js" type="before_plugin_install" /> | ||
|
||
<engines> | ||
<engine name="cordova" version=">=3.5.0" /> | ||
</engines> | ||
|
||
<!-- android --> | ||
<platform name="android"> | ||
<config-file target="config.xml" parent="/*"> | ||
<feature name="BranchSDK"> | ||
<param name="android-package" value="io.branch.BranchSDK" /> | ||
<param name="onload" value="true" /> | ||
</feature> | ||
</config-file> | ||
<config-file target="AndroidManifest.xml" parent="/manifest/application"> | ||
<meta-data android:name="io.branch.sdk.BranchKey" android:value="$BRANCH_KEY" /> | ||
</config-file> | ||
<config-file target="AndroidManifest.xml" parent="/manifest/application/activity"> | ||
<!-- Non AppLink example --> | ||
<intent-filter> | ||
<data android:scheme="$URI_SCHEME" /> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
</intent-filter> | ||
</config-file> | ||
<source-file src="src/android/io/branch/BranchSDK.java" target-dir="src/io/branch" /> | ||
<framework src="io.branch.sdk.android:library:1+" /> | ||
</platform> | ||
|
||
<!-- ios --> | ||
<platform name="ios"> | ||
<config-file target="config.xml" parent="/*"> | ||
<feature name="BranchSDK"> | ||
<param name="ios-package" value="BranchSDK" /> | ||
</feature> | ||
</config-file> | ||
<config-file target="*-Info.plist" parent="branch_key"> | ||
<string>$BRANCH_KEY</string> | ||
</config-file> | ||
<config-file target="*-Info.plist" parent="CFBundleURLTypes"> | ||
<array> | ||
<dict> | ||
<key>CFBundleURLName</key> | ||
<string>io.branch.sdk</string> | ||
<key>CFBundleURLSchemes</key> | ||
<array> | ||
<string>$URI_SCHEME</string> | ||
</array> | ||
</dict> | ||
</array> | ||
</config-file> | ||
<header-file src="src/ios/BranchSDK.h" /> | ||
<source-file src="src/ios/BranchSDK.m" /> | ||
<source-file src="src/ios/AppDelegate+BranchSdk.m" /> | ||
<!--[Branch Framework Reference]--> | ||
</platform> | ||
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters