R.swift: [Question] Swift New Build System can't handle R.swift on Travis

Created on 12 Dec 2017  ·  13Comments  ·  Source: mac-cain13/R.swift

As in title, I've turned on New Build System on my repository, but it has failed with following error:

❌  error: missing input '/Users/travis/build/drwalcore/trckr/R.generated.swift' and no rule to build it
❌  error: cannot build '/Users/travis/Library/Developer/Xcode/DerivedData/trckr-fobgqgzdhufvsjbtgcuwuruufjhf/Build/Intermediates.noindex/trckr.build/Debug-iphonesimulator/trckr.build/Objects-normal/x86_64/AppDelegate.o' due to missing input

I've run and tested it locally and R.swift was processed flawlessly. Maybe it's not R.swift related, so I am sorry for that 🤖
After turning off New Build System it is working again!

Most helpful comment

Hi, guys! I using GitLab for CI, but i have same issue with Xcode 10.
I solved it. I added into R.swift build phase, one line to Output Files - path to R.generated.swft
$(PROJECT_DIR)/R.generated.swift
Now it works fine with CI and Xcode 10.

All 13 comments

I don't have any experience with R.swift + Travis. But like you I can build with R.swift and the New Build System just fine.

So I'm assuming that this is indeed a Travis issue.
Are you sure Travis is doing a clean build? Or is it reusing cached build results from a previous build with the Standard Build System?

Thank You for a response, I will look for issues on Travis side. I am pretty sure Travis CI makes a clean build every time the build starts. I will make some research, and I will be really glad to help to resolve this issue, to be prepared for official New Build System usage along with R.swift and Travis duo!

I found this problem too. I believed the problem is you didn't keep R.generated.swift in your repository. You can reproduce this by deleting R.generated.swift and choosing New Build System then it will build fail on 1st time and it will build success on the next time.
You can either add R.generated.swift to your repository or add rswift generate in your build script.

This is a clever solution, thank You for the response. I will definitely give it a try.

Assuming that this is solved now, so I will close this one.

@AwaisFayyaz what do You mean? Everything is written there...
https://github.com/mac-cain13/R.swift#cocoapods-recommended

I had another "missing input" error. I was confused with this. sorry, removed my comment. you can also remove your reply. after that i will remove this message.

BTW, i just learned about R.swift. Cool

No worries :)

Adding generated source files to the repo is not a nice solution.

Better solution: in the run script phase just specify the generated file as an output file. That will satisfy the new Xcode build system which needs that information to properly parallelize and schedule build tasks.

From the release notes:

If an output file which is generated by a shell script is used as an input elsewhere in the build (for example, to another shell script), then that output must be declared as an explicit output by the script that generates it; otherwise the build system may attempt to search for the file before it has been generated, causing the build to fail.

https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes/build_system_release_notes_for_xcode_10

We observe that adding _only_ the output file is not enough. It will fix running R.swift on a clean build. But on a incremental build it will still fail to detect changes.

I don't understand why Xcode 10 makes the assumption this is okay. I would think that no inputs defined means that we should be runned always, but it seems that is not the case. So I'm affraid we need to generate input file lists.

Urgs. That sounds like a bug we should file a Radar for.

In session 408, Apple was pretty clear about when no input files were declared, that the build phase would always be run.

42f827b6-0b8f-497c-a959-1652fadc7333

https://developer.apple.com/wwdc18/408

Hi, guys! I using GitLab for CI, but i have same issue with Xcode 10.
I solved it. I added into R.swift build phase, one line to Output Files - path to R.generated.swft
$(PROJECT_DIR)/R.generated.swift
Now it works fine with CI and Xcode 10.

Note that only adding R.generated.swift as an Output File to the R.swift build step is not sufficient.
As this means the builds step is only run once during incremental builds. Since the output file already exists in subsequent builds.

For continued discussion on this topic, see:
https://github.com/mac-cain13/R.swift/issues/456

Was this page helpful?
0 / 5 - 0 ratings