Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ To install the plugin in your Cordova app, run the following:
```script
cordova plugin add cordova-plugin-intercom
```

The Intercom iOS SDK is no longer published to the CocoaPods trunk. When the plugin is added to the iOS platform, it downloads
`Intercom.xcframework.zip` for the exact iOS SDK version this release was built against from the
[intercom-ios GitHub release](https://github.com/intercom/intercom-ios/releases), verifies its SHA-256 checksum and embeds it
in your app. The download is cached in `~/Library/Caches/cordova-plugin-intercom`; set `INTERCOM_IOS_SDK_CACHE_DIR` to use
another directory, for example one your CI caches or one you pre-fill for offline builds. The download comes from `github.com`,
which redirects to `release-assets.githubusercontent.com`, so allow both hosts if your network only allows the CocoaPods CDN.

If you are upgrading from a version that installed the `Intercom` pod, remove and re-add the plugin
(`cordova plugin rm cordova-plugin-intercom`, then `cordova plugin add cordova-plugin-intercom`) so the pod is removed from
`platforms/ios/Podfile`, and remove `pod 'Intercom'` if you added it yourself. If the app still links the old pod afterwards,
remove and re-add the platform (`cordova platform rm ios`, then `cordova platform add ios`).

The pod-based plugin also added `use_frameworks!` to the generated Podfile. Pods from your other plugins are now built as
static libraries unless another plugin asks for frameworks, so duplicate symbol errors or missing resource bundles from those
pods after upgrading come from this change.

### PhoneGap

To add the plugin to your PhoneGap app, add the following to your `config.xml`:
Expand Down
2 changes: 2 additions & 0 deletions intercom-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/ios/Intercom.xcframework/
src/ios/.intercom-ios-sdk
20 changes: 0 additions & 20 deletions intercom-plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions intercom-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
"cordova-ios",
"cordova-android"
],
"dependencies": {
"q": "^1.5.1"
},
"engines": {
"cordovaDependencies": {
"14.1.1": {
Expand Down
13 changes: 3 additions & 10 deletions intercom-plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@


<platform name="ios">
<hook type="before_plugin_install" src="scripts/prepareCocoaPods.js" />
<hook type="after_prepare" src="scripts/checkForUpdate.js" />
<hook type="before_plugin_install" src="scripts/installIntercomIosSdk.js" />

<header-file src="src/ios/IntercomBridge.h" />
<source-file src="src/ios/IntercomBridge.m" />
Expand Down Expand Up @@ -63,14 +62,8 @@
</array>
</config-file>

<podspec>
<config>
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="Intercom" spec="~> 19.9.2" />
</pods>
</podspec>
<!-- The iOS SDK version and checksum are pinned in scripts/installIntercomIosSdk.js. -->
<framework src="src/ios/Intercom.xcframework" custom="true" embed="true" link="true" />
Comment thread
niamh-coleman marked this conversation as resolved.
Resolved
</platform>

<platform name="android">
Expand Down
105 changes: 0 additions & 105 deletions intercom-plugin/scripts/checkForUpdate.js

This file was deleted.

65 changes: 65 additions & 0 deletions intercom-plugin/scripts/installIntercomIosSdk.js
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';
Comment thread
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');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: readFileSync slurps the whole zip. Fine at ~12 MB, but a stream hash is two lines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept readFileSync: the hook is synchronous, so streaming means a chunked read loop or making the hook async, and at ~12 MB I don't think it's worth the extra code.

🤖 Addressed by Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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');
Comment thread
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the pod kept preserve_paths for dSYM; this drops the dSYMs. Only affects symbolicating Intercom frames in crash reports — just flagging it as a choice rather than a side effect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No dSYMs are lost here: the xcframework Info.plist sets DebugSymbolsPath = dSYMs for each slice, and Xcode copies Intercom.framework.dSYM into the build products from it (seen in the Example simulator build).

🤖 Addressed by Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed on the 19.9.2 zip: no top-level dSYM directory, DebugSymbolsPath = dSYMs on both slices, and dSYMs/Intercom.framework.dSYM inside ios-arm64 and ios-arm64_x86_64-simulator. The trunk spec's 'dSYM' preserve path matched nothing. Nothing lost — resolving.

} finally {
fs.rmSync(tmp, { recursive: true, force: true });
}
fs.writeFileSync(stampPath, stamp);
};
13 changes: 0 additions & 13 deletions intercom-plugin/scripts/prepareCocoaPods.js

This file was deleted.

Loading