question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: capacitor:sync:before also runs on copy and/or update

See original GitHub issue

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.3.0
  @capacitor/core: 4.3.0
  @capacitor/android: 4.3.0
  @capacitor/ios: 4.3.0

Installed Dependencies:

  @capacitor/cli: 4.3.0
  @capacitor/core: 4.3.0
  @capacitor/android: 4.3.0
  @capacitor/ios: 4.3.0

[success] iOS looking great! 👌
[error] Missing <manifest package=""> attribute in app/src/main

Platform(s)

Current Behavior

I added capacitor:sync:before to my package.json, with a script to increment build number. "capacitor:sync:before": "npx trapeze run trapeze.config.yaml -y" However the script runs three times instead of one. Looking at screen output, it seems to also be running at cap copy and/or update. Tested with same result both ionic cap sync and npx cap sync

Expected Behavior

Script should run only once, before cap sync

Code Reproduction

Add below line to package.json, then run npx cap syncand you will se HELLO! three times instead of one "capacitor:sync:before": "echo 'HELLO!'"

Other Technical Details

npm --version output: 6.14.15

node --version output: v14.16.0

pod --version output (iOS issues only):

Additional Context

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jcesarmobilecommented, Oct 10, 2022

Will mark it as feature request, but if we do we would have to wait for Capacitor 5 since it would be breaking as capacitor:copy:before wouldn’t contain the $CAPACITOR_PLATFORM_NAME variable anymore and some users might be depending on it.

1reaction
jcesarmobilecommented, Oct 10, 2022

The hook runs once per platform, so if you have 3 (web, ios and android) it will run three times. On each run the $CAPACITOR_PLATFORM_NAME variable value will have a different value, so you can use that variable in the hook to do different things based on the platform it’s running.

If instead of npx cap sync you run npx cap sync ios then it will run only once with the ios value on $CAPACITOR_PLATFORM_NAME.

But maybe we should have capacitor:sync:before:platformName to allow platform specific hooks and make the capacitor:sync:before without platform to run only once.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: capacitor sync ios exited with exit code 1 #4147 - GitHub
android seems to work fine. Current Behavior. Running ionic cap build ios --verbose OR ionic cap sync results in exit code 1 during...
Read more >
Ionic Capacitor Sync Command
Sync (copy + update) an Android or iOS device project with Ionic Capacitor Sync. Read our documentation to learn more about this command...
Read more >
npx cap sync vs npx cap copy - Stack Overflow
npx cap update searches for Cordova and Capacitor plugins and copy/update some native files the plugins need for working. So copy is for...
Read more >
Development Workflow | Capacitor Documentation
To do this, you can use the Capacitor CLI to "sync" your web code and install/update the required native dependencies. To sync your...
Read more >
[CAPACITOR] Capacitor Workflow for iOS and ... - YouTube
In this video, we cover the basic workflow when using Capacitor in an Ionic application. We look at setting up Capacitor, copying web...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found