R.swift: First build always fails using the new build system with Xcode 10 Beta 6

Created on 20 Aug 2018  路  17Comments  路  Source: mac-cain13/R.swift

Hi,

Using the new build system (the default setting) with Xcode 10 Beta 6 results in the first build failing. Subsequent builds pass.

Configuration

  • Xcode 10 Beta 6
  • R.swift added via cocoapods
  • R.swift build script as follows $PODS_ROOT/R.swift/rswift" "generate" "$SRCROOT

Result
error: Build input file cannot be found: '/Project/R.generated.swift'

On a local machine, this is not a problem, as we can build again. However, on a CI environment such as Buddybuild, the build continuously fails as it performs a clean build every time.

Most helpful comment

We have solved this by defining R.generated.swift as an output file, as follows:

screen shot 2018-08-29 at 15 50 20

All 17 comments

Is your "Run Script" build phase _before_ the "Compile Sources" phase?

screen shot 2018-08-20 at 17 36 05

Hi @tomlokhorst. Yes, our run script phase is before the compile sources phase.

Just to confirm: I can reproduce this behaviour (with the example ResourceApp project in this repository)

I haven't looked into why this happens. It appears the "Compile Sources" step doesn't wait for the "R.swift" to finish.

Thanks for the update @tomlokhorst

I'm also running into this.

Workaround for Bitrise: if you run the build twice, setting Do a clean Xcode build before the archive? to no in one workflow, the second build will succeed.

I'm also having this issue. It seems that Xcode 10 has changed something here with Compile Sources.

Wondering if it helps if we define R.generated.swift as an output file of the R.swift step. Maybe that hints Xcode that it should wait for the R.swift step to finish.

Also; it sounds like a Xcode bug to me, because I think that the default should keep working as is.

@mac-cain13 Nope, that doesn't help. I actually have my own step to auto generate some code and it fails as well. Or even with Sourcery.

I think there is something going on with new build system as it's being used in new Xcode 10.

We have solved this by defining R.generated.swift as an output file, as follows:

screen shot 2018-08-29 at 15 50 20

Thanks @superpeteblaze That worked! ;)

For others who may come across this issue - this solution (defining an output file) worked for us as well. Defining the final output seems to have given the new build system enough of a hint to ensure it has that file in place before attempting a compilation.

@tomlokhorst I think this issue can be closed, as it seems to just be caused by Xcode 10's build system changes.

Lets leave it open for now.
At the minimum we should update the documentation to detail how to set the output file.

Also worth investigating; Should the project.pbxproj file (and other files) be listed in the input files?

I've found that having an Output file listed but no input files seems to make Xcode skip over the step pretty consistently which means it doesn't get updated even when needed.

I've found the same thing; R.swift only runs once when there's only an output file listed.

I tried adding a (manually created) list of input files (.xcfilelist), that seems to work.
But if we have R.swift generate that file, it won't be updated when (for example) a new images is added to an Assets Catalog.

I haven't yet investigated further, but we need to find a solution for this.

I was thinking that it might need to be a multi-step process. My thoughts were:

  1. Input file: xcproject
    Output file: RswiftDependencies.xcfilelist
    In this it would need to determine the relevant files that R.swift cares about. This would allow R.swift to know as storyboards, xib etc are added, though I am not sure how this could deal with your example of images in asset catalogs. (Somewhat related https://github.com/SwiftGen/SwiftGen/issues/441)
  1. Input file list: RswiftDependencies.xcfilelist
    Output file: R.generated.swift
    This would be the current step

Please continue this discussion here: https://github.com/mac-cain13/R.swift/issues/456

Was this page helpful?
0 / 5 - 0 ratings

Related issues

appcelerate picture appcelerate  路  6Comments

tomlokhorst picture tomlokhorst  路  3Comments

alexpersian picture alexpersian  路  6Comments

romk1n picture romk1n  路  6Comments

andreadelfante picture andreadelfante  路  6Comments