Eerror when executing in xcode

I can execute without problem from Android Studio but when executing from xcode I get the error

  • What went wrong:

Cannot run Project.afterEvaluate(Action) when the project is already evaluated.

  • Try:

Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is:

org.gradle.api.InvalidUserCodeException: Cannot run Project.afterEvaluate(Action) when the project is already evaluated.

We had a similar problem with our multi-module project, building OK from command line or Android Studio, but not from Xcode. We were able to work around it by adding the following to build.gradle in our MOE module (I assume this tweaks the order the modules are evaluated):

project.afterEvaluate {
  // Hack to work around errors relating to afterEvaluate
  moeMainDebugIphoneosXcodeBuild.mustRunAfter noOp
  moeMainDebugIphonesimulatorXcodeBuild.mustRunAfter noOp
  moeMainReleaseIphoneosXcodeBuild.mustRunAfter noOp
  moeMainReleaseIphonesimulatorXcodeBuild.mustRunAfter noOp
}
task noOp {
  doLast {
    println "NoOp"
  }
}
2 Likes

Perfect, bug fixed.

Thank you