Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xcodeproj cannot see schemes in the workspace container (error is "Couldn't find specified scheme") #12113

Closed
loufranco opened this issue Mar 21, 2018 · 12 comments

Comments

Projects
None yet
4 participants
@loufranco
Copy link
Contributor

commented Mar 21, 2018

In 2.85.0 everything worked for me. When I updated to 2.86.0, gym could not find my schemes.

I debugged and I see that the root cause is xcodeproj's Workspace.schemes does not load xcscheme files that are in the workspace container

I made a simple ruby script

require 'xcodeproj'
project_path = './Trellis.xcworkspace/'
workspace = Xcodeproj::Workspace.new_from_xcworkspace(project_path)
workspace.load_schemes(project_path)
print workspace.schemes

I ran it

{"Pods"=>"/Users/lfranco/src/ios/Trellis.xcworkspace/Pods/Pods.xcodeproj", "TrelloUIKit"=>"/Users/lfranco/src/ios/Trellis.xcworkspace/TrelloUIKit/TrelloUIKit.xcodeproj", "Trellis"=>"/Users/lfranco/src/ios/Trellis.xcworkspace/Trellis.xcodeproj"}

But, I have all of these schemes:

20:27 $ find Trellis.xcworkspace -name '*.xcscheme'
Trellis.xcworkspace/xcshareddata/xcschemes/Trello Today Widget.xcscheme
Trellis.xcworkspace/xcshareddata/xcschemes/Trellis.xcscheme
Trellis.xcworkspace/xcshareddata/xcschemes/Trello Watch App.xcscheme
Trellis.xcworkspace/xcshareddata/xcschemes/Trello Share Extension.xcscheme
Trellis.xcworkspace/xcshareddata/xcschemes/Trello Watch Notification.xcscheme
Trellis.xcworkspace/xcshareddata/xcschemes/Trellis Ad Hoc.xcscheme
Trellis.xcworkspace/xcshareddata/xcschemes/Trello Notification Service Extension.xcscheme
Trellis.xcworkspace/xcshareddata/xcschemes/Trello Stickers.xcscheme
Trellis.xcworkspace/xcshareddata/xcschemes/TrelloEnterprise.xcscheme

I realize the bug is in xcodeproj, but I think you should think of reverting. I am going to report to them as well, but it will take time to update, I think.

As an alternative, you could load the workspace schemes and add them to the list generated in project.rb schemes method.

To make this a little easier to find in searches, this is the error I get from gym:

Couldn't find specified scheme 'Trellis Ad Hoc'.
-- | --
Multiple schemes found but you haven't specified one.
Since this is a CI, please pass one using the `scheme` option
Couldn't find any schemes in this project, make sure that the scheme is shared if you are using a workspace
Open Xcode, click on `Manage Schemes` and check the `Shared` box for the schemes you want to use
Afterwards make sure to commit the changes into version control
@loufranco

This comment has been minimized.

Copy link
Contributor Author

commented Mar 21, 2018

Here is a simple workspace that reproduces the issue

WorkspaceSchemes.zip

Run

ruby xc.rb

and see that it doesn't list WorkspaceSchemesScheme which is

./WorkspaceSchemes.xcworkspace/xcshareddata/xcschemes/WorkspaceSchemesScheme.xcscheme

Also, open the project and manage schemes to see that it is there and shared.

If you run

fastlane gym

you will see that it isn't listed

@loufranco

This comment has been minimized.

Copy link
Contributor Author

commented Mar 21, 2018

I reported to xcodeproj: CocoaPods/Xcodeproj#557

@Statusgman

This comment has been minimized.

Copy link

commented Mar 21, 2018

I have the same issue. In 2.85.0 everything is OK. In 2.86.0 scan can't list all schemes in my workspace.

@nakiostudio

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2018

Exact same issue here - happy to give more details if needed.

@loufranco

This comment has been minimized.

Copy link
Contributor Author

commented Mar 21, 2018

@Statusgman @nakiostudio

  1. Do you use a workspace?
  2. Are the missing schemes set to have the workspace as their container (not a project) -- check in Manage Schemes? (or check by finding the .xcscheme files -- are they in the workspace folder)
@Statusgman

This comment has been minimized.

Copy link

commented Mar 21, 2018

  1. A am using workspace
  2. Yes, missing scheme have this workspace as container. And this scheme is inside workspace directory too.
@loufranco

This comment has been minimized.

Copy link
Contributor Author

commented Mar 21, 2018

@Statusgman You might want to check out my fix: https://github.com/loufranco/fastlane/tree/fix-scheme-load-from-workspace-container

And see if it works for you. I am working on getting this PR approved.

@Statusgman

This comment has been minimized.

Copy link

commented Mar 21, 2018

@loufranco I checked your PR, and it fixes my issue. All schemes from workspace are visible for "scan" now! 👍

@zapjonny

This comment has been minimized.

Copy link

commented Mar 22, 2018

Not sure if this relates to my problem, but after updating fastlane for the first time in maybe 2 weeks, doing gym(scheme: "balbla", xxx) does not work anymore - gym suddenly began asking what target I want to build, even though that information should be in the scheme, right?
Maybe I should try https://github.com/loufranco/fastlane/tree/fix-scheme-load-from-workspace-container ?
Yes I am using a workspace.

@loufranco

This comment has been minimized.

Copy link
Contributor Author

commented Mar 22, 2018

@zapjonny if "balbla.xcscheme" is under the workspace folder, then my PR will fix that.

@loufranco loufranco changed the title xcodeproj cannot see schemes in the workspace container xcodeproj cannot see schemes in the workspace container (error is "Couldn't find specified scheme") Mar 22, 2018

@zapjonny

This comment has been minimized.

Copy link

commented Mar 23, 2018

Turned out my schemes were not under the workspace container, but inside one of the projects. I have some more debugging to do...

@zapjonny

This comment has been minimized.

Copy link

commented Mar 23, 2018

I found the problem of my issue, which was different.

(
I am using get_version_number in my fastfile and all of a sudden it started to require the target parameter in my case. If it wasn't specified in the fastfile, in the get_version_number call like get_version_number(target: 'mytarget') it would interactively prompt the user... which in my case was an automated script :-P So this was not an issue with gym at all in the first place.
)

@fastlane fastlane locked and limited conversation to collaborators May 22, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.