ashfurrow / Nimble-Snapshots

Nimble matchers for FBSnapshotTestCase.
https://medium.com/cocoaacademymag/unit-testing-uiview-with-nimble-snapshot-651a7c5a5e93
MIT License
319 stars 102 forks source link

Type 'XCTContext' has no member 'runActivity' #258

Closed verodanilova closed 1 year ago

verodanilova commented 1 year ago

Hey! After the update to v. 9.5.0, our snapshot tests target doesn't work because of a compiler error:

***/Pods/Nimble-Snapshots/Nimble_Snapshots/HaveValidSnapshot.swift:105:20: error: type 'XCTContext' has no member 'runActivity'
        XCTContext.runActivity(named: name) { activity in
        ~~~~~~~~~~ ^~~~~~~~~~~

Could you please check what's wrong? ๐Ÿ™

ashfurrow commented 1 year ago

Hi @verodanilova, sorry to hear you're having trouble. I need some more information to help us track this down.

Can you confirm your integration with the library? CocoaPods, right? Anything weird in your Podfile? Which previous version were you using that did work? 9.4.0? Xcode and iOS target deployment versions? Thanks!

verodanilova commented 1 year ago

Hey @ashfurrow ! Thanks for your answer.

verodanilova commented 1 year ago

Hey @ashfurrow ! Do you have any news so far?

ashfurrow commented 1 year ago

Hi. Sorry I donโ€™t have the capacity to work on this right now. Iโ€™d welcome a pull request but I canโ€™t troubleshoot right now.

verodanilova commented 1 year ago

Hey! No problem! Then I will wait for your answer as soon as you have time ๐Ÿ™

hfehrmann commented 1 year ago

Hi @verodanilova!

Do you mind to publish a minimum working example showing the failure? That way, other people could take a look if they have time.

verodanilova commented 1 year ago

Hey @hfehrmann ! I'd love to, but I can't because it's a commercial project and I'm forbidden to share the code, sorry ๐Ÿ˜ž

hfehrmann commented 1 year ago

@verodanilova I was thinking in sharing an example project, without any private code.

anton-plebanovich commented 1 year ago

I am not sure what the core reason is, but this PR helped me to solve the issue https://github.com/pointfreeco/swift-snapshot-testing/pull/455/files

For some reason Nimble-Snapshots does not have ENABLE_TESTING_SEARCH_PATHS enabled. A local project workaround is

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if target.name == 'Nimble-Snapshots'
        config.build_settings['ENABLE_TESTING_SEARCH_PATHS'] = 'YES'
      end
    end
  end
end

To fix the core issue we need to update the podspec file from

  s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO' }

to

  s.pod_target_xcconfig = { 
    'ENABLE_BITCODE' => 'NO',
    'ENABLE_TESTING_SEARCH_PATHS' => 'YES',
  }

Here is an example of how it was done in the Nimble https://github.com/Quick/Nimble/blob/main/Nimble.podspec

And here is a pull request https://github.com/ashfurrow/Nimble-Snapshots/pull/276