Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Fail to do an init for Xcode project which uses SPM because UseModernBuildSystem is hardcoded to NO #112

Open
kyzmitch opened this issue Feb 7, 2022 · 1 comment

Comments

@kyzmitch
Copy link

kyzmitch commented Feb 7, 2022

"-UseModernBuildSystem=NO",

It seems when Xcode project uses Swift Package Manager it must use New Build System, but this setting is hardcoded (see code above). UseModernBuildSystem should be possible to set to YES.

Tried to set it in console with bash variable but it shouldn't help, because it is hardcoded in your script.
Also, wasn't possible to set it using:

$ defaults write com.apple.dt.Xcode UseModernBuildSystem YES

Xcode project uses it, I checked in Workspace settings.

Full error:

$ gryphon init App.xcodeproj/ --target=HttpKit
Error running xcodebuild:
Command line invocation:
    /Applications/Xcode-13.2.0-beta.app/Contents/Developer/usr/bin/xcodebuild -UseModernBuildSystem=NO -project App.xcodeproj -target HttpKit -dry-run

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES
    UseModernBuildSystem = NO

Resolve Package Graph
Packages are not supported when using the legacy build system.
Resolved source packages:
  AlamofireImage: https://github.com/Alamofire/AlamofireImage.git @ 4.2.0
  Alamofire: https://github.com/Alamofire/Alamofire.git @ 5.5.0

xcodebuild: error: Could not resolve package dependencies:
  Packages are not supported when using the legacy build system.
@kyzmitch kyzmitch changed the title Fail to init for project which uses SPM because UseModernBuildSystem is set to NO Fail to do an init for Xcode project which uses SPM because UseModernBuildSystem is set to NO Feb 7, 2022
@kyzmitch kyzmitch changed the title Fail to do an init for Xcode project which uses SPM because UseModernBuildSystem is set to NO Fail to do an init for Xcode project which uses SPM because UseModernBuildSystem is hardcoded to NO Feb 7, 2022
@vinivendra
Copy link
Owner

Hey @kyzmitch, thanks for opening this issue. I didn't know we had this problem with the new build system, but I guess it was bound to happen someday.

I see you already started working on a fix, so let me give you some background that might help you out.

The only reason (as far as I remember) why Gryphon runs xcodebuild is because it needs to know every argument that the Swift compiler needs for a successful compilation of the app. The xcodebuild command compiles the whole app, which includes calling the Swift compiler, and prints those commands to the terminal, which means Gryphon can read that and get all the arguments it needs.

Because Gryphon only needs to know what the compilation command is (but doesn't need to actually run it) it tries to call xcodebuild with the -dry-run option to save time, which means forcing xcodebuild to use the legacy system. That said, in a situation where the new build system is needed, I agree that it would be better to take longer but work correctly than to not work at all. I would, however, add a warning telling the user about the extra time it'll take, just so that they know what they're getting into.

I'll try to add a few comments to your PR to try to steer you in the right direction when I have time, but all in all it looks like a great start 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants