forked from EddyVerbruggen/cordova-plugin-googleplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EddyVerbruggen#280 Not Working on IOS 10
- Loading branch information
1 parent
8db84ae
commit 1e8f388
Showing
7 changed files
with
137 additions
and
4 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
.DS_Store | ||
*.iml | ||
npm-debug.log |
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,94 @@ | ||
// using error to see if this shows up in AB | ||
console.error("Running hook to add iOS Keychain Sharing entitlements (required since iOS 10)"); | ||
|
||
var xcode = require('xcode'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
plist = require('plist'), | ||
util = require('util'); | ||
|
||
module.exports = function (context) { | ||
var Q = context.requireCordovaModule('q'); | ||
var deferral = new Q.defer(); | ||
|
||
if (context.opts.cordova.platforms.indexOf('ios') < 0) { | ||
throw new Error('This plugin expects the ios platform to exist.'); | ||
} | ||
|
||
var iosPlatform = path.join(context.opts.projectRoot, 'platforms/ios/'); | ||
var iosFolder = fs.existsSync(iosPlatform) ? iosPlatform : context.opts.projectRoot; | ||
console.log("iosFolder: " + iosFolder); | ||
|
||
fs.readdir(iosFolder, function (err, data) { | ||
if (err) { | ||
throw err; | ||
} | ||
|
||
var projFolder; | ||
var projName; | ||
|
||
// Find the project folder by looking for *.xcodeproj | ||
if (data && data.length) { | ||
data.forEach(function (folder) { | ||
if (folder.match(/\.xcodeproj$/)) { | ||
projFolder = path.join(iosFolder, folder); | ||
projName = path.basename(folder, '.xcodeproj'); | ||
} | ||
}); | ||
} | ||
|
||
if (!projFolder || !projName) { | ||
throw new Error("Could not find an .xcodeproj folder in: " + iosFolder); | ||
} | ||
|
||
var destFile = path.join(iosFolder, projName, 'Resources', projName + '.entitlements'); | ||
if (fs.existsSync(destFile)) { | ||
console.error("File exists, not doing anything: " + destFile); | ||
} else { | ||
console.log("Will add iOS Keychain Sharing entitlements to project '" + projName + "'"); | ||
|
||
//var projectPlistPath = path.join(context.opts.projectRoot, 'platforms/ios', projName, util.format('%s-Info.plist', projName)); | ||
var projectPlistPath = path.join(iosFolder, projName, util.format('%s-Info.plist', projName)); | ||
var projectPlistJson = plist.parse(fs.readFileSync(projectPlistPath, 'utf8')); | ||
var bundleID = projectPlistJson.CFBundleIdentifier; | ||
console.log("KeychainSharingBundleID: " + bundleID); | ||
|
||
|
||
// create a new entitlements plist file | ||
var sourceFile = path.join(context.opts.plugin.pluginInfo.dir, 'src/ios/resources/KeychainSharing.entitlements'); | ||
fs.readFile(sourceFile, 'utf8', function (err, data) { | ||
data = data.replace(/__KEYCHAIN_ACCESS_GROUP__/g, bundleID); | ||
|
||
fs.writeFileSync(destFile, data); | ||
|
||
var projectPath = path.join(projFolder, 'project.pbxproj'); | ||
|
||
var pbxProject; | ||
if (context.opts.cordova.project) { | ||
pbxProject = context.opts.cordova.project.parseProjectFile(context.opts.projectRoot).xcode; | ||
} else { | ||
pbxProject = xcode.project(projectPath); | ||
pbxProject.parseSync(); | ||
} | ||
|
||
pbxProject.addResourceFile(projName + ".entitlements"); | ||
|
||
var configGroups = pbxProject.hash.project.objects['XCBuildConfiguration']; | ||
for (var key in configGroups) { | ||
var config = configGroups[key]; | ||
if (config.buildSettings !== undefined) { | ||
config.buildSettings.CODE_SIGN_ENTITLEMENTS = '"' + projName + '/Resources/' + projName + '.entitlements"'; | ||
} | ||
} | ||
|
||
// write the updated project file | ||
fs.writeFileSync(projectPath, pbxProject.writeSync()); | ||
console.warn("OK, added iOS Keychain Sharing entitlements to project '" + projName + "'"); | ||
|
||
deferral.resolve(); | ||
}); | ||
} | ||
}); | ||
|
||
return deferral.promise; | ||
}; |
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,6 @@ | ||
{ | ||
"dependencies": { | ||
"xcode": "0.8.0", | ||
"plist": "1.1.0" | ||
} | ||
} |
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,17 @@ | ||
console.error("Google Sign-In prerequisites"); | ||
|
||
module.exports = function (context) { | ||
var child_process = context.requireCordovaModule('child_process'), | ||
deferral = context.requireCordovaModule('q').defer(); | ||
|
||
var output = child_process.exec('npm install', {cwd: __dirname}, | ||
function (error) { | ||
if (error !== null) { | ||
console.log('exec error: ' + error); | ||
deferral.reject('npm installation failed'); | ||
} | ||
deferral.resolve(); | ||
}); | ||
|
||
return deferral.promise; | ||
}; |
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
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
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>keychain-access-groups</key> | ||
<array> | ||
<string>$(AppIdentifierPrefix)__KEYCHAIN_ACCESS_GROUP__</string> | ||
</array> | ||
</dict> | ||
</plist> |