UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

274 lines (273 loc) 12.2 kB
import type { SentryProjectData } from '../utils/types'; import { PBXSourcesBuildPhase, type PBXNativeTarget, type PBXObjects, type Project } from 'xcode'; import { XcodeProjectObjectWithId } from './xcode-project-object-with-id'; export declare class XcodeProject { /** * The directory where the Xcode project is located. */ baseDir: string; /** * The path to the `<PROJECT>.xcodeproj` directory. */ xcodeprojPath: string; /** * The path to the `project.pbxproj` file. */ pbxprojPath: string; /** * The Xcode project object. */ project: Project; objects: PBXObjects; /** * Creates a new XcodeProject instance, a wrapper around the Xcode project file `<PROJECT>.xcodeproj/project.pbxproj`. * * @param projectPath - The path to the Xcode project file */ constructor(projectPath: string); getAllTargets(): string[]; updateXcodeProject(sentryProject: SentryProjectData, target: string, addSPMReference: boolean, uploadSource?: boolean): void; addUploadSymbolsScript({ sentryProject, targetName, uploadSource, }: { sentryProject: SentryProjectData; targetName: string; uploadSource: boolean; }): void; /** * Retrieves all source files associated with a specific target in the Xcode project. * This is used to find files where we can inject Sentry initialization code. * * @param targetName - The name of the target to get files for * @returns An array of absolute file paths for the target's source files, or undefined if target not found */ getSourceFilesForTarget(targetName: string): string[] | undefined; /** * Finds a native target by name. * * @param targetName - The name of the target to find * @returns The native target, or undefined if the target is not found */ private findNativeTargetByName; /** * Finds the source build phase in a target. * * @param target - The target to find the source build phase in * @returns The source build phase, or undefined if the target is not found or has no source build phase */ findSourceBuildPhaseInTarget(target: PBXNativeTarget): XcodeProjectObjectWithId<PBXSourcesBuildPhase> | undefined; /** * Adds a new script build phase to the specified target. * * @param targetKey - The key of the target to add the build phase to * @param name - The name of the build phase * @param script - The shell script content * @param inputPaths - Array of input paths for the script * @returns The UUID of the created build phase */ addScriptBuildPhase(targetKey: string, name: string, script: string, inputPaths?: string[]): string; /** * Updates an existing script build phase. * * @param buildPhaseId - The UUID of the build phase to update * @param script - The new shell script content * @param inputPaths - Array of input paths for the script */ updateScriptBuildPhase(buildPhaseId: string, script: string, inputPaths?: string[]): void; /** * Finds all files in the source build phase of a target. * * @param nativeTarget - The target to find the files in * @returns The files in the source build phase of the target, or an empty array if the target is not found or has no source build phase */ findFilesInSourceBuildPhase(nativeTarget: XcodeProjectObjectWithId<PBXNativeTarget>): string[]; /** * Resolves the absolute path of a file reference. * * @param fileRef - The file reference to resolve the path of * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path */ private resolveAbsolutePathOfFileReference; /** * Resolves the absolute path of a file reference relative to the parent group. * * @param fileRef - The file reference to resolve the path of * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path */ private resolveAbsoluteFilePathRelativeToGroup; /** * Resolves the absolute path of a file reference relative to the built products directory. * * @param buildFile - The file reference to resolve the path of * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path */ private resolveAbsoluteFilePathRelativeToBuiltProductsDir; /** * Resolves the absolute path of a file reference relative to the source root. * * The source root is the directory where the `.xcodeproj` file is located. * * @param buildFile - The file reference to resolve the path of * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path */ private resolveAbsoluteFilePathRelativeToSourceRoot; /** * Resolves the absolute path of a file reference relative to the SDK root. * * @param buildFile - The file reference to resolve the path of * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path */ private resolveAbsoluteFilePathRelativeToSdkRoot; /** * Resolves the absolute path of a file reference relative to the developer directory. * * @param buildFile - The file reference to resolve the path of * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path */ private resolveAbsoluteFilePathRelativeToDeveloperDir; /** * Resolves the absolute path of a group. * * @param group - The group to resolve the path of * @returns The absolute path of the group, or undefined if the group is not found or has no path */ private resolveAbsolutePathOfGroup; /** * Resolves the path of a group relative to the parent group. * * @param group - The group to resolve the path of * @returns The path of the group relative to the parent group, or undefined if the group is not found or has no path */ private resolvePathOfGroupRelativeToGroup; /** * Resolves the path of a group relative to the source root. * * The source root is the directory where the `.xcodeproj` file is located. * * @param group - The group to resolve the path of * @returns The path of the group relative to the source root, or undefined if the group is not found or has no path */ private resolvePathOfGroupRelativeToSourceRoot; /** * Resolves the path of a group relative to the built products directory. * * @param group - The group to resolve the path of * @returns The path of the group relative to the built products directory, or undefined if the group is not found or has no path */ private resolvePathOfGroupRelativeToBuiltProductsDir; /** * Resolves the path of a group relative to the SDK root. * * The SDK root is the directory where the SDK is installed. * * @param group - The group to resolve the path of * @returns The path of the group relative to the SDK root, or undefined if the group is not found or has no path */ private resolvePathOfGroupRelativeToSdkRoot; /** * Resolves the path of a group relative to the developer directory. * * The developer directory is the directory where the Xcode command line tools are installed. * * @param group - The group to resolve the path of * @returns The path of the group relative to the developer directory, or undefined if the group is not found or has no path */ private resolvePathOfGroupRelativeToDeveloperDir; /** * Resolves the absolute path of a group. * * @param group - The group to resolve the path of * @returns The absolute path of the group, or undefined if the group is not found or has no path */ private resolveAbsolutePathOfSynchronizedRootGroup; /** * Resolves the path of a group relative to the parent group. * * @param group - The group to resolve the path of * @returns The path of the group relative to the parent group, or undefined if the group is not found or has no path */ private resolvePathOfSynchronizedRootGroupRelativeToGroup; /** * Resolves the path of a group relative to the source root. * * The source root is the directory where the `.xcodeproj` file is located. * * @param group - The group to resolve the path of * @returns The path of the group relative to the source root, or undefined if the group is not found or has no path */ private resolvePathOfSynchronizedRootGroupRelativeToSourceRoot; /** * Resolves the path of a group relative to the built products directory. * * @param group - The group to resolve the path of * @returns The path of the group relative to the built products directory, or undefined if the group is not found or has no path */ private resolvePathOfSynchronizedRootGroupRelativeToBuiltProductsDir; /** * Resolves the path of a group relative to the SDK root. * * The SDK root is the directory where the SDK is installed. * * @param group - The group to resolve the path of * @returns The path of the group relative to the SDK root, or undefined if the group is not found or has no path */ private resolvePathOfSynchronizedRootGroupRelativeToSdkRoot; /** * Resolves the path of a group relative to the developer directory. * * The developer directory is the directory where the Xcode command line tools are installed. * * @param group - The group to resolve the path of * @returns The path of the group relative to the developer directory, or undefined if the group is not found or has no path */ private resolvePathOfSynchronizedRootGroupRelativeToDeveloperDir; /** * Finds all files in the synchronized root groups of a target. * * @param nativeTarget - The target to find the files in * @returns The files in the synchronized root groups of the target, or an empty array if the target is not found or has no synchronized root groups */ findFilesInSynchronizedRootGroups(nativeTarget: XcodeProjectObjectWithId<PBXNativeTarget>): string[]; private getFilesInSynchronizedRootGroup; /** * Returns all files in a directory tree. * * @param dirPath - The path of the directory to get the files in * @returns All files in the directory tree, or an empty array if the directory does not exist */ private getAbsoluteFilePathsInDirectoryTree; private filterFilesByExceptionSets; /** * Returns all groups that are PBXGroup. * * This is a helper method to avoid having to map and filter the groups manually. * * @returns All groups that are PBXGroup, excluding comments and non-object values. */ private get groups(); /** * Finds the parent group of a child group or file reference. * * @param childId - The ID of the child group or file reference * @returns The parent group of the child group or file reference, or undefined if the child group or file reference is not found or has no parent group */ private findParentGroupByChildId; /** * Checks if a group is the main group of any project. * * @param groupId - The ID of the group to check * @returns True if the group is the main group, false otherwise */ private isMainGroup; private getExceptionSetsForGroup; /** * The path to the build products directory for the project. * * This is cached to avoid having to read the build settings from Xcode for each call to `getBuildProductsDirectoryPath`. */ private buildProductsDir; /** * Returns the path to the build products directory for the project. * * @returns The path to the build products directory for the project, or undefined if the path is not found */ private getBuildProductsDirectoryPath; }