Skip to content
Draft
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
10 changes: 7 additions & 3 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export const TNS_CORE_THEME_NAME = "nativescript-theme-core";
export const SCOPED_TNS_CORE_THEME_NAME = "@nativescript/theme";
export const WEBPACK_PLUGIN_NAME = "@nativescript/webpack";
export const RSPACK_PLUGIN_NAME = "@nativescript/rspack";
// Project-relative directory the Vite bundler writes its build output to
// before the CLI copies it into the platforms app folder. Mirrors the
// default value computed in `@nativescript/vite`'s base configuration
// (`process.env.NS_VITE_DIST_DIR || '.ns-vite-build'`).
export const VITE_DIST_FOLDER_NAME = ".ns-vite-build";
export const TNS_CORE_MODULES_WIDGETS_NAME = "tns-core-modules-widgets";
export const UI_MOBILE_BASE_NAME = "@nativescript/ui-mobile-base";
export const TNS_ANDROID_RUNTIME_NAME = "tns-android";
Expand Down Expand Up @@ -172,9 +177,7 @@ export class ITMSConstants {
static altoolExecutableName = "altool";
}

class ItunesConnectApplicationTypesClass
implements IiTunesConnectApplicationType
{
class ItunesConnectApplicationTypesClass implements IiTunesConnectApplicationType {
public iOS = "iOS App";
public Mac = "Mac OS X App";
}
Expand Down Expand Up @@ -409,6 +412,7 @@ export enum IOSNativeTargetTypes {
watchApp = "watch_app",
watchExtension = "watch_extension",
appExtension = "app_extension",
application = "application",
}

const pathToLoggerAppendersDir = join(
Expand Down
26 changes: 25 additions & 1 deletion lib/definitions/nativescript-dev-xcode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,27 @@ declare module "nativescript-dev-xcode" {
}

class project {
hash: any;
filepath: string;
constructor(filename: string);

parse(callback: () => void): void;
parseSync(): void;

generateUuid(): string;

writeSync(options: any): string;

addFramework(filepath: string, options?: Options): void;
removeFramework(filePath: string, options?: Options): void;


getProductFile(watchApptarget: target): any;
addToPbxFrameworksBuildPhase(file);
addToPbxCopyfilesBuildPhase(file, comment: string, targetid: string);
pbxFrameworksBuildPhaseObj(targetid: string): any;
pbxBuildFileSection(): {[k: string] : any};

addPbxGroup(
filePathsArray: any[],
name: string,
Expand All @@ -27,17 +38,30 @@ declare module "nativescript-dev-xcode" {

removePbxGroup(groupName: string, path: string): void;

addTargetDependency(target: string, dependencyTargets: string[]);

findTargetKey(name: string);
pbxTargetByName(name: string): target;
pbxNativeTargetSection(): {[key: string]: any};

addToHeaderSearchPaths(options?: Options): void;
removeFromHeaderSearchPaths(options?: Options): void;
updateBuildProperty(key: string, value: any): void;

pbxXCBuildConfigurationSection(): any;

buildPhaseObject(
buildPhaseType: string,
comment: string,
target: tstring
)

addTarget(
targetName: string,
targetType: string,
targetPath?: string,
parentTarget?: string
parentTarget?: string,
productTargetType?: string
): target;
addBuildPhase(
filePathsArray: string[],
Expand Down
39 changes: 35 additions & 4 deletions lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,7 @@ interface INativePrepare {
}

interface IBuildConfig
extends IAndroidBuildOptionsSettings,
IiOSBuildConfig,
IProjectDir {
extends IAndroidBuildOptionsSettings, IiOSBuildConfig, IProjectDir {
clean?: boolean;
architectures?: string[];
buildOutputStdio?: string;
Expand All @@ -615,7 +613,8 @@ interface IBuildConfig
* Describes iOS-specific build configuration properties
*/
interface IiOSBuildConfig
extends IBuildForDevice,
extends
IBuildForDevice,
IiCloudContainerEnvironment,
IDeviceIdentifier,
IProvision,
Expand Down Expand Up @@ -865,6 +864,7 @@ interface IAddExtensionsFromPathOptions extends IAddTargetFromPathOptions {

interface IAddWatchAppFromPathOptions extends IAddTargetFromPathOptions {
watchAppFolderPath: string;
disableStubBinary?: boolean;
}

interface IRemoveExtensionsOptions {
Expand All @@ -873,6 +873,37 @@ interface IRemoveExtensionsOptions {

interface IRemoveWatchAppOptions extends IRemoveExtensionsOptions {}

interface IWatchAppJSONConfigModule {
name?: string;
path: string;
targetType?: string;
embed?: boolean;
frameworks?: Array<string | Record<string, string>>;
dependencies?: string[];
headerSearchPaths?: string[];
resources?: string[];
src?: string[];
linkerFlags?: string[];
buildConfigurationProperties?: Record<string, string>;
SPMPackages?: Array<IOSSPMPackage | string>;
}
interface IWatchAppJSONConfig {
targetType?: string;
forceAddEmbedWatchContent?: boolean;
sharedModulesBuildConfigurationProperties?: Record<string, string>;
basedir?: string;
infoPlistPath?: string;
xcprivacyPath?: string;
importSourcesFromMainFolder?: boolean;
importResourcesFromMainFolder?: boolean;
resources?: string[];
src?: string[];
resourcesExclude?: string[];
srcExclude?: string[];
modules: IWatchAppConfigModule[];
SPMPackages?: Array<IOSSPMPackage>;
}

interface IRubyFunction {
functionName: string;
functionParameters?: string;
Expand Down
41 changes: 39 additions & 2 deletions lib/services/bundler/bundler-compiler-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
BUNDLER_COMPILATION_COMPLETE,
PackageManagers,
CONFIG_FILE_NAME_DISPLAY,
VITE_DIST_FOLDER_NAME,
} from "../../constants";
import {
IPackageManager,
Expand Down Expand Up @@ -77,6 +78,13 @@ export class BundlerCompilerService
super();
}

private getViteDistOutputPath(projectDir: string): string {
return path.join(
projectDir,
process.env.NS_VITE_DIST_DIR || VITE_DIST_FOLDER_NAME,
);
}

public async compileWithWatch(
platformData: IPlatformData,
projectData: IProjectData,
Expand Down Expand Up @@ -126,9 +134,8 @@ export class BundlerCompilerService
}

// Copy Vite output files directly to platform destination
const distOutput = path.join(
const distOutput = this.getViteDistOutputPath(
projectData.projectDir,
".ns-vite-build",
);
const destDir = path.join(
platformData.appDestinationDirectoryPath,
Expand Down Expand Up @@ -170,6 +177,7 @@ export class BundlerCompilerService
);
}
resolve(childProcess);
return;
}

// Transform Vite message to match webpack format
Expand Down Expand Up @@ -372,6 +380,8 @@ export class BundlerCompilerService
reject(err);
});

const isVite = this.getBundler() === "vite";

childProcess.on("close", async (arg: any) => {
await this.$cleanupService.removeKillProcess(
childProcess.pid.toString(),
Expand All @@ -380,6 +390,33 @@ export class BundlerCompilerService
delete this.bundlerProcesses[platformData.platformNameLowerCase];
const exitCode = typeof arg === "number" ? arg : arg && arg.code;
if (exitCode === 0) {
// Non-watch Vite builds spawn the child with stdio:"inherit"
// (no IPC channel), so the emittedFiles message handler in
// compileWithWatch never fires and the Vite output is never
// copied to the platforms app folder. Mirror that copy step
// here so release/CI prepare and build flows actually deploy
// the freshly built bundle. Without this, the deploy folder
// is left empty (or worse, runs stale dev/HMR artifacts from
// a previous `ns debug` run) and the runtime crashes on
// launch with `Check failed: has_pending_exception()`.
if (isVite) {
try {
const distOutput = this.getViteDistOutputPath(
projectData.projectDir,
);
const destDir = path.join(
platformData.appDestinationDirectoryPath,
this.$options.hostProjectModuleName,
);
this.copyViteBundleToNative(distOutput, destDir);
} catch (copyErr) {
this.$logger.warn(
`Failed to copy Vite output to platform destination: ${
(copyErr as Error).message
}`,
);
}
}
resolve();
} else {
const error: any = new Error(
Expand Down
1 change: 0 additions & 1 deletion lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}
}

this.$iOSWatchAppService.removeWatchApp({ pbxProjPath });
const addedWatchApp = await this.$iOSWatchAppService.addWatchAppFromPath({
watchAppFolderPath: path.join(
resourcesDirectoryPath,
Expand Down
Loading
Loading