Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS package path has changed, ionic run ios throws an error #5048

Open
webberig opened this issue Oct 16, 2023 · 2 comments · May be fixed by #5065
Open

iOS package path has changed, ionic run ios throws an error #5048

webberig opened this issue Oct 16, 2023 · 2 comments · May be fixed by #5065
Labels

Comments

@webberig
Copy link

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 because native-run is given the wrong path.

The command executed and error:

> native-run ios --app platforms/ios/build/device/Zimmo.ipa --device
[native-run] ERR_UNKNOWN: Path 'platforms/ios/build/device/Zimmo.ipa' not found
[ERROR] An error occurred while running subprocess native-run.

However, my app is now in platforms/ios/build/Debug-iphoneos folder. This works:

native-run ios --app platforms/ios/build/Debug-iphoneos/Zimmo.ipa --device

Steps to Reproduce:

  • In any Cordova + Ionic project, install the latest version of XCode.
  • Run 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:

Ionic:

   Ionic CLI                     : 7.1.1 (/Users/mathieu/.nvm/versions/node/v18.12.1/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 7.1.0
   @angular-devkit/build-angular : 16.2.1
   @angular-devkit/schematics    : 16.2.1
   @angular/cli                  : 16.2.1
   @ionic/angular-toolkit        : 7.0.0

Cordova:

   Cordova CLI       : 12.0.0 ([email protected])
   Cordova Platforms : android 12.0.1, ios 7.0.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 21 other plugins)

Utility:

   cordova-res                          : not installed globally
   native-run (update available: 1.7.3) : 1.7.2

System:

   Android SDK Tools : 26.1.1 (/Users/mathieu/Library/Android/sdk)
   ios-deploy        : 1.12.1
   ios-sim           : 8.0.2
   NodeJS            : v18.12.1 (/Users/mathieu/.nvm/versions/node/v18.12.1/bin/node)
   npm               : 8.19.2
   OS                : macOS Unknown
   Xcode             : Xcode 14.3.1 Build version 14E300c

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.

@KarunaLakshman
Copy link

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/[email protected] 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);
};

@Scooby27
Copy link

Hi all, are there any plans to merge the PR fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants