mac-cain13 / R.swift

Strong typed, autocompleted resources like images, fonts and segues in Swift projects
MIT License
9.5k stars 763 forks source link

RswiftResources no such module error #805

Open alessiolapenna opened 1 year ago

alessiolapenna commented 1 year ago

I'm trying to migrate R.swift to the latest version using the plugin import method. On local workstations it works fine. Even the archive is completed correctly. But when i run this in the Github action that we use for CI it can never complete an archive. The r.generated file is correctly written, but when compiled it cannot find the RswiftResources module, causing the compilation process to fail.

Screenshot 2023-02-09 alle 09 01 03

Screenshot 2023-02-09 alle 09 01 40

I tried using a project or switching to a workspace. Tried messing with various build settings, but nothing seems to work.

From what I can see the plugin is configured correctly as it has no problem locally in debug or archive. Maybe there is some "fixed" path that is necessary and when running in CI there is some problem with the location where this library is created and located?

Zeropointer11 commented 1 year ago

I have the same issue hope there is a solution soon. as a side node the issue is also when you run the xcodebuild command locally

xcodebuild -workspace ./MyApp.xcworkspace -scheme MyApp -sdk 'iphoneos16.2' -destination 'generic/platform=iOS' -archivePath MyApp.xcarchive -skipPackagePluginValidation clean archive
jujuforce commented 1 year ago

Got the same issue, please help.

AndreiAvram123 commented 1 year ago

I got this issue as well on my local machine

zvonedev commented 1 year ago

I have the same problems for last two days, did anyone managed to fix it or is there a planned fix by the package owners itself?

Zeropointer11 commented 1 year ago

i figured out it happens when you build the executableTarget() for the plugin when you remove the build plugin the archive is working. I think thats the case because the Plugin is Compiled for macOS to execute and the archive is a build for iOS.

A possible workaround would be to include the executable target prebuild in the Package.swift SwiftLint had the same problem and they fixed it with that approach.

 .binaryTarget(
            name: "SwiftLintBinary",
            url: "https://github.com/realm/SwiftLint/releases/download/0.50.3/SwiftLintBinary-macos.artifactbundle.zip",
            checksum: "abe7c0bb505d26c232b565c3b1b4a01a8d1a38d86846e788c4d02f0b1042a904"
        )
tomlokhorst commented 1 year ago

Removing the -sdk 'iphoneos16.2' option from xcodebuild should fix the issue. The app will still be build for iOS because of the specified destination.

We could indeed think about shipping a prebuilt binary, if only to avoid this scenario, because multiple people have already run into this.

alessiolapenna commented 1 year ago

I think that shipping a prebuild binary is the solution to go IMHO. SwiftLint solved the same issue in the same way and it works well indeed.

garethlloyd1994 commented 1 year ago

Is there any update for a solution for this? Or is there a workaround?

This is currently blocking us from using Firebase Test Labs with our CI as this requires code to be built using xcodebuild with the SDK set to -sdk iphoneos.

alessiolapenna commented 1 year ago

In my case the xcode build command doesn't contain the -sdk parameter so the workaround doesn't work for me. Is there any way we can have this fixed in the future?

My command is this: xcodebuild -resolvePackageDependencies -scheme Prod -project App.xcodeproj -configuration ProdRelease

tomlokhorst commented 1 year ago

A workaround is to not use the build plugin, but instead run the command plugin manually.

alessiolapenna commented 1 year ago

This is not gonna help when on CI. I can build correctly when i'm doing it locally. even when archiving locally. the problem arises only when building on CI (Github Actions)

dzhurov commented 2 days ago

I had the same issue. Archive worked fine locally but failed on CI (GitHub actions + Fastlane). The issue was solved after removing sdk parameter from the fastlane build_ios_app function call.