Skip to content

[IOS]Unexpected duplicate tasks #5214

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

Closed
farfromrefug opened this issue Jan 14, 2020 · 13 comments
Closed

[IOS]Unexpected duplicate tasks #5214

farfromrefug opened this issue Jan 14, 2020 · 13 comments
Assignees
Labels
Milestone

Comments

@farfromrefug
Copy link
Contributor

When i am in a working env dev with npm links i might end up with an XCode build error Unexpected duplicate tasks
It is due to native deps being added twice.
For example my plugin nativescript-gesturehandler comes with a framework.
In my current case i have it in my app package.json but also as a dependency of another plugin.
Consequently i have nativescript-gesturehandler in:

  • node_modules/nativescript-gesturehandler
  • node_modules/nativescript-chart/node_modules/nativescript-gesturehandler

Could you filter duplications when creating the XCode project and adding modules targets?

@rosen-vladimirov
Copy link
Contributor

Hey @farfromrefug ,
Thanks for the suggestions. I've created a PR that should resolve this issue.

@rosen-vladimirov
Copy link
Contributor

rosen-vladimirov commented Jan 22, 2020

After latest fixes (currently available in CLI's next version), CLI will detect if NativeScript plugin exists multiple times in node_modules. In case that's the case, CLI will check the versions of the plugin in each occurrence and will apply the following rules:

  • in case all versions are the same, CLI will use the native code from the version which is topmost in node_modules. You can reproduce this by executing:
tns create myApp --js
cd myApp
npm i --save-exact [email protected] [email protected]
cd node_modules/nativescript-ui-listview
npm i --production
cd ../../
tns prepare ios/android

This must produce warning that nativescript-ui-core exists in multiple locations.

  • in case there's difference in the versions, CLI will throw an error:
    You can reproduce this by executing:
tns create myApp --js
cd myApp
npm i --save-exact [email protected] [email protected] [email protected]
tns prepare ios/android

NOTE: the error message will guide you to delete package-lock.json (or other configuration file if it exists in your project). CLI checks if there's npm-shrinkrwrap.json, package-lock.json, yarn.lock and pnpm-lock.yaml.

@farfromrefug
Copy link
Contributor Author

farfromrefug commented Jan 22, 2020

@rosen-vladimirov awesome! will test it and report any error. Will actually leave this open until i can confirm it works

@rosen-vladimirov
Copy link
Contributor

After some additional investigation, we've decided to implement the following:

  1. For Android - analyze the dependencies tree and show debug messages (visible when you pass --log debug in case there are same versions of plugin in node_modules.
  2. For iOS search for .framework in the NativeScript plugins.
    2.1 In case the same framework comes from different plugins - show error message
    2.2 In case the same framework comes from the same plugin, but with different versions in node_modules - show error message
    2.3 In case the same framework comes from the same versions of a plugin - show warning and use only one of the instances

@rosen-vladimirov
Copy link
Contributor

Hey @farfromrefug ,
As the feature has been implemented and released, I'm closing this issue. In case you notice any problems or concerns, please open a new bug report.

@farfromrefug
Copy link
Contributor Author

@rosen-vladimirov right sorry. Forgot to mention that right now it seems perfect. Will notify if i see any issue

@mvnidheesh1992
Copy link

Hi @rosen-vladimirov

getting error like this below

error: Unexpected duplicate tasks:

  1. Target 'demo' (project 'demo'): CodeSign /upgrade/nativescript-plugin/demo/platforms/ios/build/Debug-iphonesimulator/demo.app/Frameworks/TNSWidgets.framework
  2. Target 'demo' (project 'demo'): CodeSign /upgrade/nativescript-plugin/demo/platforms/ios/build/Debug-iphonesimulator/demo.app/Frameworks/TNSWidgets.framework
    error: Multiple commands produce '/upgrade/nativescript-plugin/demo/platforms/ios/build/Debug-iphonesimulator/demo.app/Frameworks/TNSWidgets.framework':
  3. Target 'demo' has copy command from '/upgrade/nativescript-plugin/demo/node_modules/@cn/nativescript-mlkit-plugin/node_modules/@nativescript/core/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework' to '/upgrade/nativescript-plugin/demo/platforms/ios/build/Debug-iphonesimulator/demo.app/Frameworks/TNSWidgets.framework'
  4. Target 'demo' has copy command from '/upgrade/nativescript-plugin/demo/node_modules/@nativescript/core/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework' to '/upgrade/nativescript-plugin/demo/platforms/ios/build/Debug-iphonesimulator/demo.app/Frameworks/TNSWidgets.framework'

package.json

"devDependencies": {
	"typescript": "~4.0.0",
	"prompt": "^1.2.0",
	"rimraf": "^3.0.2",
	"tslint": "^5.12.1",
	"semver": "^7.3.5",
	"@nativescript/types": "^8.1.1"
},
"dependencies": {
	"@nativescript/core": "^8.1.1",
	"@nativescript/hook": "^2.0.0",
	"path": "^0.12.7"
}

could you please help me to fix this issue

@rigor789
Copy link
Member

@mvnidheesh1992 are you using the latest 8.1.1 CLI (ns -v)? If so, can you share the project with us so we can figure out why it happens?

@mvnidheesh1992
Copy link

Hi @rigor789

nativescript CLI is 8.0.2

@rigor789
Copy link
Member

@mvnidheesh1992 please try the latest version, I believe it should work fine.

@mvnidheesh1992
Copy link

@rigor789 Yes. it is working fine. Thank you !!!

@sarbbjeet
Copy link

`error: Unexpected duplicate tasks:

  1. Target 'tapApp' (project 'tapApp'): CodeSign /Users/sarb/Desktop/tap_App/platforms/ios/build/Debug-iphonesimulator/tapApp.app/Frameworks/TNSWidgets.framework
  2. Target 'tapApp' (project 'tapApp'): CodeSign /Users/sarb/Desktop/tap_App/platforms/ios/build/Debug-iphonesimulator/tapApp.app/Frameworks/TNSWidgets.framework
    error: Multiple commands produce '/Users/sarb/Desktop/tap_App/platforms/ios/build/Debug-iphonesimulator/tapApp.app/Frameworks/TNSWidgets.framework':
  3. Target 'tapApp' has copy command from '/Users/sarb/Desktop/tap_App/node_modules/@nativescript/core/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework' to '/Users/sarb/Desktop/tap_App/platforms/ios/build/Debug-iphonesimulator/tapApp.app/Frameworks/TNSWidgets.framework'
  4. Target 'tapApp' has copy command from '/Users/sarb/Desktop/tap_App/node_modules/tns-core-modules-widgets/platforms/ios/TNSWidgets.framework' to '/Users/sarb/Desktop/tap_App/platforms/ios/build/Debug-iphonesimulator/tapApp.app/Frameworks/TNSWidgets.framework'`

same error facing, I am using nativescript cli 8.1.5

@rigor789
Copy link
Member

rigor789 commented Feb 2, 2022

@sarbbjeet something is pulling in tns-core-modules-widgets - that's a legacy package and it's conflicting with @nativescript/core. If you have it in package.json, remove it (same with tns-core-modules if you have them).

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

No branches or pull requests

5 participants