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

Multiple commands produce 'xxx/RswiftGeneratePublicResources/xxx/R.generated.swift' #815

Open
RobertDresler opened this issue Mar 14, 2023 · 8 comments

Comments

@RobertDresler
Copy link

Hello,

I have iOS app which has embedded watchOS app. I also have SPM package which runs R.swift plugin:

.target(
    name: "VOSStrings",
    dependencies: [.product(name: "RswiftLibrary", package: "R.swift")],
    resources: [.process("Resources")],
    plugins: [.plugin(name: "RswiftGeneratePublicResources", package: "R.swift")]
)

This package is added to both targets: the main iOS app and its embedded watchOS app. Unfortunately, I am unable to build the app since I receive the error Multiple commands produce 'xxx/RswiftGeneratePublicResources/xxx/R.generated.swift'

Screenshot 2023-03-14 at 20 26 52

When I remove watchOS app from target dependencies of iOS app, it works, but then iOS app can't be built. Don't you know what could be wrong?

Thank you!

@SpectatorNan
Copy link

i have the same error, but i delete old R.generated.swift file and then rebuild project success

@LP-sleep
Copy link

I use 7.3.0, which does not need to add R.geratated.swift to your target, only need to add script in accordance with SPM access steps to build and then R.xxx can used. It is worth noting that the name of the struct is changed to _R, and the Struct can extension with _R struct.

@RobertDresler
Copy link
Author

RobertDresler commented Mar 20, 2023

@SpectatorNan unfortunetely, this doesn't solve the problem for me since I use SPM where storing this file is out of my control.

@RobertDresler
Copy link
Author

@tomlokhorst here is minimal reproducible example. Don't you know, what could be wrong?
https://github.com/RobertDresler/RSwift-in-shared-package

@tomlokhorst
Copy link
Collaborator

Thanks for the minimal reproducible example, that is very useful!

I'm no expert on the Xcode build system, so I'm not exactly sure what's going on.

But I did manage to the the example building, with some changes:

  • I removed the reference to Strings from both targets
  • I added a new Framework target, that does use Strings
  • I included that new framework in both original targets

Again, I'm not exactly sure, but I think the difference with this indirection is that the new framework is dynamically linked, and the original Strings library was statically linked (twice).

@saltyskip
Copy link

Anyone able to find the root cause of this issue?

@RobertDresler
Copy link
Author

@saltyskip Creating two different targets overcomes the problem (see my question on SO). Eventough it doesnt solve it as I would like to, I don't know any better solution so far.

If you need to have targets A and A_watchOS, and you have target B which is imported by both iOS and watchOS app targets, you can create B which imports A and A_watchOS based on platform condition in SPM.

@realityworks
Copy link

This is a blocker for us. We have two schemes and one target. Fails because it thinks it needs to build for both schemes...

image

Reverting to R.swift 6.

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

No branches or pull requests

6 participants