Repository navigation
Embed the Intercom iOS SDK from its GitHub release instead of CocoaPods #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| src/ios/Intercom.xcframework/ | ||
| src/ios/.intercom-ios-sdk |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| var crypto = require('crypto'); | ||
| var execFileSync = require('child_process').execFileSync; | ||
| var fs = require('fs'); | ||
| var os = require('os'); | ||
| var path = require('path'); | ||
|
|
||
| // The Intercom pod is no longer published to the CocoaPods trunk; fetch the GitHub release instead. | ||
| var VERSION = '19.9.2'; | ||
| var SHA256 = '6af284508f58de833313b263f3d82eaebc255c4d9a56ad9adf2fc6af4228c0f4'; | ||
|
niamh-coleman marked this conversation as resolved.
Resolved
|
||
| var RELEASE_URL = 'https://github.com/intercom/intercom-ios/releases/download/' + VERSION + '/Intercom.xcframework.zip'; | ||
|
|
||
| function cacheDir() { | ||
| return process.env.INTERCOM_IOS_SDK_CACHE_DIR || path.join(os.homedir(), 'Library', 'Caches', 'cordova-plugin-intercom'); | ||
| } | ||
|
|
||
| function sha256(file) { | ||
| return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kept 🤖 Addressed by Claude Code
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair — a chunked read loop or an async hook isn't worth it at 12 MB. Dropping this. |
||
| } | ||
|
|
||
| function cachedZip() { | ||
| var zipPath = path.join(cacheDir(), VERSION, 'Intercom.xcframework.zip'); | ||
| if (fs.existsSync(zipPath) && sha256(zipPath) === SHA256) { | ||
| return zipPath; | ||
| } | ||
|
|
||
| var downloadPath = zipPath + '.download'; | ||
| fs.mkdirSync(path.dirname(zipPath), { recursive: true }); | ||
| console.log('[Intercom] Downloading the Intercom iOS SDK ' + VERSION + ' from ' + RELEASE_URL); | ||
| try { | ||
| execFileSync('curl', ['--fail', '--silent', '--show-error', '--location', '--retry', '3', '--output', downloadPath, RELEASE_URL], { stdio: 'inherit' }); | ||
| } catch (error) { | ||
| fs.rmSync(downloadPath, { force: true }); | ||
| throw new Error('[Intercom] Could not download ' + RELEASE_URL + '. Check your network, or place the zip at ' + zipPath + | ||
| ' (set INTERCOM_IOS_SDK_CACHE_DIR to use another cache directory).'); | ||
| } | ||
|
|
||
| var actual = sha256(downloadPath); | ||
| if (actual !== SHA256) { | ||
| fs.rmSync(downloadPath, { force: true }); | ||
| throw new Error('[Intercom] Checksum mismatch for ' + RELEASE_URL + ': expected ' + SHA256 + ', got ' + actual + '.'); | ||
| } | ||
| fs.renameSync(downloadPath, zipPath); | ||
| return zipPath; | ||
| } | ||
|
|
||
| module.exports = function (context) { | ||
| var frameworkPath = path.join(context.opts.plugin.dir, 'src', 'ios', 'Intercom.xcframework'); | ||
|
niamh-coleman marked this conversation as resolved.
Resolved
|
||
| var stampPath = path.join(path.dirname(frameworkPath), '.intercom-ios-sdk'); | ||
| var stamp = VERSION + ' ' + SHA256; | ||
| if (fs.existsSync(path.join(frameworkPath, 'Info.plist')) && fs.existsSync(stampPath) && | ||
| fs.readFileSync(stampPath, 'utf8') === stamp) { | ||
| return; | ||
| } | ||
|
|
||
| var zipPath = cachedZip(); | ||
| var tmp = fs.mkdtempSync(path.join(path.dirname(frameworkPath), 'extract-')); | ||
| try { | ||
| execFileSync('unzip', ['-q', zipPath, '-d', tmp], { stdio: 'inherit' }); | ||
| fs.rmSync(frameworkPath, { recursive: true, force: true }); | ||
| fs.renameSync(path.join(tmp, 'Intercom.xcframework'), frameworkPath); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: the pod kept
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No dSYMs are lost here: the xcframework Info.plist sets 🤖 Addressed by Claude Code
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed on the 19.9.2 zip: no top-level |
||
| } finally { | ||
| fs.rmSync(tmp, { recursive: true, force: true }); | ||
| } | ||
| fs.writeFileSync(stampPath, stamp); | ||
| }; | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.