Open webberig opened 7 months ago
For those are still annoyed by this issue, I'm using ios after_build hook to overcome this for time being. Here goes the hooking script which could be a temporary solution.
const fs = require('node:fs');
const fsExtra = require('fs-extra');
const path = require('node:path');
const { findXCodeProjectIn } = require('cordova-ios/lib/build');
module.exports = async ({ opts }) => {
const { device, projectRoot, release, options } = opts;
// Pragmatically this fix is required only for emulation
if (!options.emulator) {
return;
}
const projectPath = path.join(projectRoot, 'platforms/ios');
const appName = await findXCodeProjectIn(projectPath);
const binaryName = `${appName}.app`;
// Mimic cordova (Ref: node_modules/cordova-ios/lib/build.js#218)
const configuration = release ? 'Release' : 'Debug';
const appPath = path.join(
projectPath,
'build',
`${configuration}-${device ? 'iphoneos' : 'iphonesimulator'}`,
binaryName
);
// @ionic/cli@6.20.9 expectation (lib/integrations/cordova/project.js#13)
const ionicIosSimulatorPackagePath = 'platforms/ios/build/emulator';
const ionicIosDevicePackagePath = 'platforms/ios/build/device';
const ionicIosBuildPath = path.join(
projectRoot,
device ? ionicIosDevicePackagePath : ionicIosSimulatorPackagePath
);
await fs.promises.mkdir(ionicIosBuildPath, {
recursive: true
});
const ionicBinaryPath = path.join(ionicIosBuildPath, binaryName);
await fsExtra.copy(appPath, ionicBinaryPath);
};
Hi all, are there any plans to merge the PR fix?
Description: It appears that the latest version of XCode builds the app to a different folder (my version is 14.3.1). This causes an error when you run
ionic cordova run ios
becausenative-run
is given the wrong path.The command executed and error:
However, my app is now in
platforms/ios/build/Debug-iphoneos
folder. This works:Steps to Reproduce:
ionic cordova run ios --device
Output: [native-run] ERR_UNKNOWN: Path 'platforms/ios/build/device/Zimmo.ipa' not found [ERROR] An error occurred while running subprocess native-run.
My
ionic info
:Other Information: I guess the problem is caused here: https://github.com/ionic-team/ionic-cli/blob/develop/packages/%40ionic/cli/src/lib/integrations/cordova/project.ts#L15
I'm not sure if this can just be changed, this may need to become an array for backwards compatibility ? I can create a PR for this if you like.