81

I'd like to use the new build system of Xcode 10 for development, but our build in our continuous integration system fails since the xcarchive produced has an issue: the Info.plist in the xcarchive is missing the ApplicationProperties key and the information therein!

It turns out switching back to the legacy build system fixes this. This can be done in the workspace settings (File > Workspace Settings… > Build System). But I would prefer to keep the new build system for development and only use the legacy build system for CI builds.

Is there a way to make xcodebuild use the legacy build system without modifying the workspace?

Naresh
  • 16,698
  • 6
  • 112
  • 113
DarkDust
  • 90,870
  • 19
  • 190
  • 224

5 Answers5

114

There is an (as of yet undocumented) flag in xcodebuild: -UseModernBuildSystem=<value>. The value can be either 0 or NO to use the legacy ("original") build system, or 1 or YES to use the new build system.

For example:

xcodebuild -workspace Foo.xcworkspace -scheme Bar -configuration Release -archivePath /path/to/Foo.xcarchive clean archive -UseModernBuildSystem=NO

(-UseNewBuildSystem=<value> seems to work as well; this flags was introduced in Xcode 9 but I suspect UseModernBuildSystem is going to be the "official" flag for this.)

DarkDust
  • 90,870
  • 19
  • 190
  • 224
  • Do you think this is a bug with Xcode or something else going on where that entry in the plist is missing? – cynistersix Oct 26 '18 at 23:30
  • 1
    @cynistersix: I think so, yes. There seem to be other issues with the new build system as well: for example, if you're using CocoaPods and change a file in a pod the new build system doesn't correctly recompile it, you have to clean the project first. My guess is that since the new buildsystem is an improvement but not perfect yet they also left in the support for the legacy buildsystem. – DarkDust Oct 27 '18 at 08:58
51

Change build system to Legacy Build System from New Build System and vice versa.

Open Xcode --> Select File -->Select Workspace Settings

enter image description here

Change Build System to Legacy Build System from New Build System --> Click Done.

enter image description here

Naresh
  • 16,698
  • 6
  • 112
  • 113
39

To extend DarkDust's answer, in case you're using fastlane for automated builds, additional parameters such as UseModernBuildSystem can be passed through xcargs:

build_app(
   // ... other necessary parameters,
   xcargs: "-UseModernBuildSystem=NO"
)
niko.mikulicic
  • 560
  • 5
  • 7
38

To select Xcode 10's build system:

In Xcode, go to: File -> Project Settings (or Workspace Settings)-> Build System

From there you can select New Build System (Default) or Legacy Build System

Hope this help makes this easier.

oden
  • 3,461
  • 1
  • 31
  • 33
CrazyOne
  • 605
  • 7
  • 13
  • 11
    This will change project settings. The question was about _xcodebuild using the legacy build system **without modifying the workspace**_ – niko.mikulicic Jan 07 '19 at 13:56
  • 2
    True Niko, thanks for clarifying. Hopefully this will help those that do need it otherwise. – CrazyOne Jan 08 '19 at 21:39
14

Currently, I'm using Xcode version 12.0 (12A7209) and follow the below steps and then you can use legacy build mode:

  1. Workspace Setting:

    enter image description here

  2. Set the legacy build mode:

    enter image description here

AmerllicA
  • 29,059
  • 15
  • 130
  • 154
  • how to do for CI – Dipesh Pokhrel Dec 31 '20 at 10:09
  • If we change this to deprecated one, is it a good thing to change this? – sejn Aug 05 '21 at 13:38
  • @sejn, This answer is not about being good or not, if someone needs to change the build type to legacy one, this is the way. – AmerllicA Aug 06 '21 at 14:12
  • @AmerllicA I am getting the below error after changing to Legacy build system. The legacy build system does not support building projects with Swift when SWIFT_ENABLE_LIBRARY_EVOLUTION is enabled. – sejn Aug 07 '21 at 10:45