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

Slather doesn't look for schemes in workspace #191

Closed
yakimant opened this issue Apr 13, 2016 · 14 comments
Closed

Slather doesn't look for schemes in workspace #191

yakimant opened this issue Apr 13, 2016 · 14 comments

Comments

@yakimant
Copy link

I run slather like this:

slather coverage --build-directory Output/DerivedData --input-format profdata --source-directory Source --workspace App.xcworkspace --scheme App App.xcodeproj

And got this:

Slathering...
No shared scheme named 'App' found in /Users/yakimant/Workspace/company/ios/App/App.xcodeproj

        Are you sure your project is generating coverage? Make sure you enable code coverage in the Test section of your Xcode scheme.
        Did you specify your Xcode scheme? (--scheme or 'scheme' in .slather.yml)
        If you're using a workspace, did you specify it? (--workspace or 'workspace' in .slather.yml)

/Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/project.rb:331:in `find_binary_file': No shared scheme named 'App' found in /Users/yakimant/Workspace/company/ios/App/App.xcodeproj (StandardError)
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/project.rb:314:in `configure_binary_file'
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/project.rb:221:in `configure'
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/command/coverage_command.rb:46:in `execute'
        from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb:11:in `execute'
        from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:132:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/bin/slather:15:in `<top (required)>'
        from /usr/bin/slather:23:in `load'
        from /usr/bin/slather:23:in `<main>'

It looks like it doesn't look for schemes inside workspace, only in project (find_binary_file method).

Here is my configuration:

⇒  xcodebuild -workspace App.xcworkspace -list
Information about workspace "App":
    Schemes:
        App
        App1
        App2
⇒  xcodebuild -project App.xcodeproj -list
Information about project "App":
    Targets:
        App
        App1
        App2

    Build Configurations:
        Debug
        Calabash
        Release
        Beta
        Distribution

    If no build configuration is specified and -scheme is not passed then "Release" is used.

    This project contains no schemes.
@yakimant
Copy link
Author

If I don't set Scheme, I got the following:

Slathering...
undefined method `children' for nil:NilClass

        Are you sure your project is generating coverage? Make sure you enable code coverage in the Test section of your Xcode scheme.
        Did you specify your Xcode scheme? (--scheme or 'scheme' in .slather.yml)
        If you're using a workspace, did you specify it? (--workspace or 'workspace' in .slather.yml)

/Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.28.2/lib/xcodeproj/project.rb:515:in `products': undefined method `children' for nil:NilClass (NoMethodError)
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/project.rb:138:in `first_product_name'
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/project.rb:150:in `profdata_coverage_dir'
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/project.rb:363:in `find_binary_file'
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/project.rb:314:in `configure_binary_file'
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/project.rb:221:in `configure'
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/lib/slather/command/coverage_command.rb:46:in `execute'
        from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb:11:in `execute'
        from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:132:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/slather-2.1.0/bin/slather:15:in `<top (required)>'
        from /usr/bin/slather:23:in `load'
        from /usr/bin/slather:23:in `<main>'

@ksuther
Copy link
Contributor

ksuther commented Apr 13, 2016

The xcodeproj gem doesn't support reading schemes from workspaces, as far as I know. At this time you need to use a scheme in the project for it to be read.

@yakimant
Copy link
Author

Ok, I see. Do you know, why do we have --workspace key?

@ksuther
Copy link
Contributor

ksuther commented Apr 13, 2016

Xcode computes its derived data path based a combination of the scheme and workspace. Many people use CocoaPods with a workspace but define schemes in the project, so passing both is necessary for slather to work automatically.

@yakimant
Copy link
Author

And maybe you know, if there is a way to point to coverage file and binary file without playing around project/workspace/scheme?

@ksuther
Copy link
Contributor

ksuther commented Apr 13, 2016

Take a look at slather coverage --help. You can specify --binary-file and --build-directory.

@yakimant
Copy link
Author

I've tried, it's looking to project anyway and got this undefined methodchildren' for nil:NilClass` issue I've mentioned in second comment here. Anyway, it looks like another issue.

As for this issue (looking for scheme in project, not in workspace) I have 2 thoughts:

  • Looking to the code throwing this error No shared scheme named 'App' found in, I see:
schemes_path = Xcodeproj::XCScheme.shared_data_dir(self.path)
xcscheme_path = "#{schemes_path + self.scheme}.xcscheme"

But in workspace folder I also see these files:

App.xcworkspace/xcshareddata/xcschemes/App.xcscheme
App.xcworkspace/xcshareddata/xcschemes/App1.xcscheme
App.xcworkspace/xcshareddata/xcschemes/App2.xcscheme
  • Looks like xcodeproj/workspace supports schemes

These just my thoughts, I'll come back as soon as I got some time.

@joshrlesch
Copy link
Contributor

Im getting the same thing about my scheme existing.

Running this command in the root of my project.
slather coverage --scheme App --workspace App.xcworkspace App.xcodeproj

This was working before updating.

Slathering...
`<PBXBuildFile UUID=`12E6206F1BA7982800A73062`>` attempted to initialize an object with an unknown UUID. `256C5B50192B0A95002426EC` for attribute: `file_ref`. This can be the result of a merge and  the unknown UUID is being discarded.
No scheme named 'App' found in /Users/josh.lesch/Documents/github/example/App.xcodeproj

    Are you sure your project is generating coverage? Make sure you enable code coverage in the Test section of your Xcode scheme.
    Did you specify your Xcode scheme? (--scheme or 'scheme' in .slather.yml)
    If you're using a workspace, did you specify it? (--workspace or 'workspace' in .slather.yml)

/Users/josh.lesch/.rvm/gems/ruby-2.2.1/bundler/gems/slather-5a974dcde107/lib/slather/project.rb:337:in `find_binary_file': No scheme named 'App' found in /Users/josh.lesch/Documents/github/example/App.xcodeproj (StandardError)
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/bundler/gems/slather-5a974dcde107/lib/slather/project.rb:314:in `configure_binary_file'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/bundler/gems/slather-5a974dcde107/lib/slather/project.rb:221:in `configure'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/bundler/gems/slather-5a974dcde107/lib/slather/command/coverage_command.rb:46:in `execute'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb:11:in `execute'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/gems/clamp-0.6.5/lib/clamp/command.rb:132:in `run'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/bundler/gems/slather-5a974dcde107/bin/slather:15:in `<top (required)>'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/bin/slather:23:in `load'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/bin/slather:23:in `<main>'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
    from /Users/josh.lesch/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'

@yakimant
Copy link
Author

What about such fix?

if self.workspace
  projectOrWorkspace = self.workspace
else
  projectOrWorkspace = self.path
end

schemes_path = Xcodeproj::XCScheme.shared_data_dir(projectOrWorkspace)

Works fine for me, should I make a PR?

@ksuther
Copy link
Contributor

ksuther commented Apr 13, 2016

If that gets things working then a PR is definitely welcome.

@joshrlesch
Copy link
Contributor

@yakimant Any progress on this?

@yakimant
Copy link
Author

@joshrlesch, I'm new to slather code. This was a preliminary solution, which worked for me.
I can make a PR with code like this or spend a bit more time for testing, writing test looking to Xcodeproj::XCScheme code and so on.

@ksuther
Copy link
Contributor

ksuther commented Apr 17, 2016

Should be fixed in #193.

@yakimant
Copy link
Author

Thank you, @ksuther!

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

No branches or pull requests

3 participants