Search code examples
xcodexcode10swiftlintsourcery

Xcode 10, sourcery & swiftlint build phases order


After updating to Xcode 10 there are some issues with initial project configurations. The steps look like this:

  1. Generating some files using Sourcery
  2. Linting with SwiftLint
  3. Build

And configuration works like this:

enter image description here

And this was working fine in Xcode 9, but apparently, it's not working under Xcode 10 build system. The issue is if I download repository (.generated files are not a part of the repository). And hit build it will show me results like:

... Using configuration file at '.sourcery.yml' Scanning sources... Found 239 types. Loading templates... Loaded 9 templates. Generating code... Finished. Processing time 0.491948962211609 seconds ...

So sourcery works ok, then linting:

Linting 'FromResponse.generated.swift' (1/186)

Works fine as well as a process, but in the end, build will fail with:

error: Build input files cannot be found: '/path/Generated/FromResponse.generated.swift', ...

So it's strange since a files are physically there and according to build settings file should be compiled later than generating them. How should I approach sourcery in build process then?


Solution

  • We are able to "fix" this in a similar way as this Github issue:

    https://github.com/mac-cain13/R.swift/issues/438#issuecomment-416982928

    We have to add each of the generated files by Sourcery to the output folder and it will get picked up by the Xcode correctly.

    enter image description here