Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
949060d
feat(cli): add sentry wizard with Next.js
sentry-junior[bot] Nov 26, 2026
76e162b
feat(cli): add the wizard's shared AST and URL helpers
sentry-junior[bot] Nov 26, 2026
0113841
feat(cli): reject the wizard's removed sign-up flags
sentry-junior[bot] Nov 26, 2026
7e5f894
Merge branch 'feat/cli-wizard-scaffold' into feat/cli-wizard-shared-a…
sentry-junior[bot] Nov 26, 2026
39e20d5
fix(cli): address review findings in sentry wizard
sentry-junior[bot] Nov 26, 2026
c4786b3
Merge branch 'feat/cli-wizard-scaffold' into feat/cli-wizard-shared-a…
sentry-junior[bot] Nov 26, 2026
2c98751
refactor(cli): reuse existing CLI helpers in the wizard AST utils
sentry-junior[bot] Nov 26, 2026
ac6b75d
feat(cli): use positionals and existing CLI flags in sentry wizard
sentry-junior[bot] Nov 26, 2026
4c93aa8
fix(cli): use the credential host for the project issues URL
sentry-junior[bot] Nov 26, 2026
cbdf2f7
feat(cli): add iOS, Apple Snapshots and React Native to sentry wizard
sentry-junior[bot] Nov 26, 2026
d084aa4
Merge remote-tracking branch 'origin/feat/cli-wizard-shared-ast-helpe…
sentry-junior[bot] Nov 26, 2026
10026f1
Merge remote-tracking branch 'origin/feat/cli-wizard-scaffold' into f…
sentry-junior[bot] Nov 26, 2026
3fbc541
refactor(cli): drop the Apple wizard flags and fit the new wizard base
sentry-junior[bot] Nov 26, 2026
ed81e1d
fix(cli): include the xcode typings in the script typecheck
sentry-junior[bot] Nov 26, 2026
2394297
feat(cli): run sentry through npx in the Xcode build phase when missing
sentry-junior[bot] Nov 27, 2026
033ff19
Merge origin/main into feat/cli-wizard-apple-react-native
sentry-junior[bot] Nov 27, 2026
7ba80fb
fix(cli): clear the CodeQL and dependency-review findings in the Appl…
sentry-junior[bot] Nov 27, 2026
acae79a
fix(cli): close a shell injection and two prompt bugs in the Apple an…
sentry-junior[bot] Nov 27, 2026
5f0bbd2
fix(cli): exit the React Native wizard when the test-event prompt is …
sentry-junior[bot] Nov 27, 2026
b53a30f
fix(cli): add Sentry.init after semicolon-less imports in the React N…
sentry-junior[bot] Nov 27, 2026
a514951
fix(cli): only treat real imports as the semicolon-less Sentry.init a…
sentry-junior[bot] Nov 27, 2026
0277642
fix(cli): resolve Xcode file references without sourceTree as <group>
sentry-junior[bot] Nov 27, 2026
2e212cf
fix(cli): don't duplicate withSentryConfig when re-patching a Metro c…
sentry-junior[bot] Nov 27, 2026
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
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"valibot": "^1.4.2",
"vitest": "catalog:",
"wrap-ansi": "^10.0.0",
"xcode": "3.0.1",
"yauzl": "3.4.0"
}
}
1 change: 1 addition & 0 deletions packages/cli/script/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"include": [
"**/*.ts",
"../src/global.d.ts",
"../src/lib/wizard/xcode.d.ts",
"../grammar/**/*.ts",
"../vitest.config.ts"
]
Expand Down
132 changes: 132 additions & 0 deletions packages/cli/src/lib/wizard/apple/apple-wizard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/**
* The iOS wizard (`sentry wizard ios`): adds the Sentry Cocoa SDK through
* Swift Package Manager, a debug-symbol upload build phase, the SDK init
* snippet, and an optional Fastlane upload step to an Xcode project.
*/

import { clack } from "../utils/clack/prompts.js";
import chalk from "chalk";

import { withTelemetry } from "../telemetry.js";
import {
confirmContinueIfNoOrDirtyGitRepo,
featureSelectionPrompt,
getOrAskForProjectData,
printWelcome,
} from "../utils/clack/index.js";
import { offerProjectScopedMcpConfig } from "../utils/clack/mcp-config.js";
import { Sentry } from "../telemetry.js";

import { checkInstalledCLI } from "./check-installed-cli.js";
import { configureFastlane } from "./configure-fastlane.js";
import { configureSentryCLI } from "./configure-sentry-cli.js";
import { configureXcodeProject } from "./configure-xcode-project.js";
import { injectCodeSnippet } from "./inject-code-snippet.js";
import {
lookupXcodeProject,
selectXcodeTarget,
} from "./lookup-xcode-project.js";
import { type AppleWizardOptions } from "./options.js";
import { abortIfSpotlightNotSupported } from "../utils/abort-if-sportlight-not-supported.js";

export async function runAppleWizard(
options: AppleWizardOptions,
): Promise<void> {
return await withTelemetry(
{
enabled: options.telemetryEnabled,
integration: "ios",
wizardOptions: options,
},
() => runAppleWizardWithTelementry(options),
);
}

async function runAppleWizardWithTelementry(
options: AppleWizardOptions,
): Promise<void> {
// Define options with defaults
const projectDir = options.projectDir ?? process.cwd();

// Step - Welcome Message
printWelcome({
wizardName: "Sentry Apple Wizard",
});

// Step - Git Status Check
await confirmContinueIfNoOrDirtyGitRepo({
ignoreGitChanges: options.ignoreGitChanges,
cwd: projectDir,
});

// Step - Sentry CLI Check
checkInstalledCLI();

// Step - Xcode Project Lookup
// This step should be run before the Sentry Project and API Key step
// because it can abort the wizard if no Xcode project is found.
const xcProject = await lookupXcodeProject({ projectDir });
const target = await selectXcodeTarget(xcProject);

// Step - Sentry Project and API Key
const projectData = await getOrAskForProjectData(options, "apple-ios");

if (projectData.spotlight) {
return await abortIfSpotlightNotSupported("Apple/iOS");
}

const { selectedProject, authToken } = projectData;

// Step - Sentry CLI Configuration Setup
configureSentryCLI({
projectDir,
authToken: authToken,
orgSlug: selectedProject.organization.slug,
projectSlug: selectedProject.slug,
});

Sentry.setTag("package-manager", "SPM");

// Step - Configure Xcode Project
configureXcodeProject({
xcProject,
project: selectedProject,
target,
});

// Step - Feature Selection
const selectedFeatures = await featureSelectionPrompt([
{
id: "logs",
prompt: `Do you want to enable ${chalk.bold(
"Logs",
)} to send your application logs to Sentry?`,
enabledHint: "optional",
},
]);

// Step - Add Code Snippet
injectCodeSnippet({
project: xcProject,
target,
dsn: selectedProject.keys[0].dsn.public,
enableLogs: selectedFeatures["logs"] ?? false,
});
Comment thread
sentry-junior[bot] marked this conversation as resolved.
Resolved

// Step - Fastlane Configuration
await configureFastlane({
projectDir,
orgSlug: selectedProject.organization.slug,
projectSlug: selectedProject.slug,
});

// Offer optional project-scoped MCP config for Sentry with org and project scope
await offerProjectScopedMcpConfig(
selectedProject.organization.slug,
selectedProject.slug,
);

clack.log.success(
"Sentry was successfully added to your project! Run your project to send your first event to Sentry. Go to Sentry.io to see whether everything is working fine.",
);
}
92 changes: 92 additions & 0 deletions packages/cli/src/lib/wizard/apple/check-installed-cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* Check that the debug-file upload build phase can find `sentry`.
*
* The user runs the wizard through `sentry`, so the CLI is installed, but an
* Xcode build phase doesn't see the user's shell `PATH`: it searches the
* system directories plus the ones the generated script adds (see
* {@link xcodeSearchDirs}). Without `sentry` there, the build phase runs it
* with `npx`, so the wizard only notes that builds would be faster with the
* CLI installed. With neither, it warns and prints how to install it where
* Xcode finds it.
*/

import { homedir } from "node:os";
import path from "node:path";

import { whichSync } from "../../which.js";
import { Sentry } from "../telemetry.js";
import { clack } from "../utils/clack/prompts.js";
import { debug } from "../utils/debug.js";

/**
* The directories a Sentry build phase searches for `sentry`: the
* standalone installer's (`~/.local/bin`, `~/bin`), Homebrew's, and the
* system ones in Xcode's default `PATH`.
*/
export function xcodeSearchDirs(home: string = homedir()): string[] {
return [
path.join(home, ".local", "bin"),
path.join(home, "bin"),
"/opt/homebrew/bin",
"/usr/local/bin",
"/usr/bin",
"/bin",
];
}

/** Commands that install the Sentry CLI where an Xcode build phase finds it. */
const SENTRY_CLI_INSTALL_COMMANDS = [
" brew install getsentry/tools/sentry",
" curl https://cli.sentry.dev/install -fsS | bash",
" npm install -g sentry",
];

/** Default warning when `sentry` is out of the build phase's reach. */
const DEFAULT_WARNING =
"Xcode build phases can't find the `sentry` CLI, so your builds won't upload debug symbols to Sentry.";

/**
* Whether an Xcode build phase finds `sentry`, or `npx` to run it with,
* warning with install instructions when it finds neither.
*
* @param warning - Explains what doesn't work without `sentry`.
* @returns The path of the `sentry` or `npx` the build phase would run, if any.
*/
export function checkInstalledCLI(
warning: string = DEFAULT_WARNING,
): string | undefined {
debug("Checking whether Xcode build phases can find sentry");
const searchDirs = xcodeSearchDirs();
const searchPath = { PATH: searchDirs.join(path.delimiter) };
const cliPath = whichSync("sentry", searchPath) ?? undefined;
Sentry.setTag("has-cli", cliPath !== undefined);
if (cliPath) {
debug(`Xcode build phases will run ${cliPath}`);
return cliPath;
}

const npxPath = whichSync("npx", searchPath) ?? undefined;
if (npxPath) {
debug(`Xcode build phases will run the Sentry CLI with ${npxPath}`);
clack.log.info(
[
"Xcode build phases will run the Sentry CLI with `npx sentry`, which downloads it on the first build.",
"For faster builds, install it with one of:",
...SENTRY_CLI_INSTALL_COMMANDS,
].join("\n"),
);
return npxPath;
}

clack.log.warn(
[
warning,
"Xcode doesn't use your shell's PATH: it looks in",
`${searchDirs.join(", ")}.`,
"",
"Install the Sentry CLI with one of:",
...SENTRY_CLI_INSTALL_COMMANDS,
].join("\n"),
);
return undefined;
}
Loading
Loading