BarredEwe / Prefire

🔥 A library based on SwiftUI Preview, for easy generation: Playbook view, Snapshot and Accessibility tests
Apache License 2.0
251 stars 16 forks source link

Xcode 15 NSCocoaError 513 #24

Closed Velin92 closed 9 months ago

Velin92 commented 9 months ago

When I try to run my tests on Xcode 15 with the PrefireTestsPlugin I get the following error:

Screenshot 2023-09-19 at 10 45 51

I am using a custom prefire config file where I write the tests in an internal folder of the project tests

BarredEwe commented 9 months ago

Xcode 15 does not give plugins permission to write to the project directory 🥲

As a quick solution, I can recommend writing in DerivedData. To do this, remove the test_file_path parameter from the .prefier.yml file.

Now I'm trying to find another solution, but so far there are difficulties with this. To be honest, I'm not sure that it can be possible now: https://github.com/apple/swift-package-manager/issues/6814

Velin92 commented 9 months ago

I see, thanks for the suggestion, however I just tried it by removing the test_file_path and the UnitTests do not build since multiple commands seem to be produce the UnitTests product.

Do you know what might be causing this issue?

Prepare build
note: Building targets in dependency order
error: Multiple commands produce '/Users/mauroromito/Library/Developer/Xcode/DerivedData/ElementX-aywdboxrhlkajqbvczulivesmexq/Build/Products/Debug-iphonesimulator/ElementX.app/PlugIns/UnitTests.xctest/UnitTests'
    note: Target 'UnitTests' (project 'ElementX') has copy command from '/Users/mauroromito/Library/Developer/Xcode/DerivedData/ElementX-aywdboxrhlkajqbvczulivesmexq/SourcePackages/plugins/ElementX.output/UnitTests/PrefireTestsPlugin/UnitTests' to '/Users/mauroromito/Library/Developer/Xcode/DerivedData/ElementX-aywdboxrhlkajqbvczulivesmexq/Build/Products/Debug-iphonesimulator/ElementX.app/PlugIns/UnitTests.xctest/UnitTests'
    note: Target 'UnitTests' (project 'ElementX') has link command with output '/Users/mauroromito/Library/Developer/Xcode/DerivedData/ElementX-aywdboxrhlkajqbvczulivesmexq/Build/Products/Debug-iphonesimulator/ElementX.app/PlugIns/UnitTests.xctest/UnitTests'

Building targets in dependency order

Multiple commands produce '/Users/mauroromito/Library/Developer/Xcode/DerivedData/ElementX-aywdboxrhlkajqbvczulivesmexq/Build/Products/Debug-iphonesimulator/ElementX.app/PlugIns/UnitTests.xctest/UnitTests'

Computing target dependency graph and provisioning inputs

Create build description
Build description signature: 4f8dec47da3429f29502ac0dae87d55d
Build description path: /Users/mauroromito/Library/Developer/Xcode/DerivedData/ElementX-aywdboxrhlkajqbvczulivesmexq/Build/Intermediates.noindex/XCBuildData/4f8dec47da3429f29502ac0dae87d55d.xcbuilddata
BarredEwe commented 9 months ago

Could you try the latest release?

Velin92 commented 9 months ago

Tried, and it now works thanks! However having the code in the DerivedData has some downsides (sometimes the code does not preview, you cannot directly change it to play around with it, which makes editing the stencil a bit more painful, it does not render immediately until you run the tests if you use a project file builder tool like xcodegen and other small things).

Not a bid deal, but was wondering instead of generating the code through the plugin, would be possible to instead expose/use a command that we may run during the Build Phase of the app? I guess this should allow for changes inside the project directory itself.

Btw great work, this package is amazing, will close the issue, hope this suggestion might be of help! Thanks again.