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

MyTypeMock does not conform to protocol NSObjectProtocol #97

Closed
fereshteh-zargaran opened this issue Apr 25, 2020 · 10 comments
Closed

MyTypeMock does not conform to protocol NSObjectProtocol #97

fereshteh-zargaran opened this issue Apr 25, 2020 · 10 comments
Labels
more info needed Further information is requested

Comments

@fereshteh-zargaran
Copy link

fereshteh-zargaran commented Apr 25, 2020

Hi,

In my project, there are supporting source files related to NSObjectProtocol. but the error "MyTypeDelegateMock does not conform to protocol NSObjectProtocol" is not resolved.

protocol DTPhotoViewerControllerDelegate: NSObjectProtocol {
}
protocol MyTypeDelegate: DTPhotoViewerControllerDelegate {
}

In MyProjectMocks.generated.swift file, i have this error:

// MARK: - Mocked MyTypeDelegate

public final class MyTypeDelegateMock: MyProject.MyTypeDelegate, Mockingbird.Mock {
}

@andrewchang-bird
Copy link
Contributor

andrewchang-bird commented Apr 25, 2020

Hi, thanks for reporting. Is DTPhotoViewerControllerDelegate an externally defined type (e.g. from a third-party library or framework)?

@andrewchang-bird andrewchang-bird added the more info needed Further information is requested label Apr 25, 2020
@fereshteh-zargaran
Copy link
Author

Thanks for your response :)
Yes. It is an external library.

@andrewchang-bird
Copy link
Contributor

andrewchang-bird commented Apr 25, 2020

Try adding a supporting source file for DTPhotoViewerControllerDelegate e.g. create a file at MockingbirdSupport/DTPhotoViewer/DTPhotoViewerControllerDelegate.swift with the contents:

import Foundation

protocol DTPhotoViewerControllerDelegate: NSObjectProtocol {}

@fereshteh-zargaran
Copy link
Author

I created a file as the same as you mentioned but in the path:
MockingbirdSupport/Foundation/DTPhotoViewerControllerDelegate.swift
But this error is not fixed.

I will try to change the path.
Thanks.

@fereshteh-zargaran
Copy link
Author

Try adding a supporting source file for DTPhotoViewerControllerDelegate e.g. create a file at MockingbirdSupport/DTPhotoViewer/DTPhotoViewerControllerDelegate.swift with the contents:

import Foundation

protocol DTPhotoViewerControllerDelegate: NSObjectProtocol {}

Unfortunately, it didn't work :(
Do you have any other suggestions?

@andrewchang-bird
Copy link
Contributor

andrewchang-bird commented Apr 26, 2020

Oh, looks like the issue might be that the access level wasn’t public. (Also make sure that you’re importing Foundation in supporting source file or the linker won’t work.)

import Foundation

public protocol DTPhotoViewerControllerDelegate: NSObjectProtocol {}

Edit: I’m fairly confident that the above should work, but if it doesn’t, please post the verbose output from the generator build logs: https://github.com/birdrides/mockingbird/wiki/Debugging-the-Generator

@fereshteh-zargaran
Copy link
Author

I have done all steps but it does not work :(
I attached required files.

Screen Shot 2020-04-26 at 3 43 05 PM

Screen Shot 2020-04-26 at 3 38 56 PM

Screen Shot 2020-04-26 at 4 30 09 PM

Build Bellchat_2020-04-26T15-13-07-.txt

@andrewchang-bird
Copy link
Contributor

andrewchang-bird commented Apr 26, 2020

Thanks for the logs! Since the module name for that library is actually DTPhotoViewerController, the supporting source file should be under MockingbirdSupport/DTPhotoViewerController instead. Sorry for the confusion here—let me know if this solves the issue for you.

@fereshteh-zargaran
Copy link
Author

It is fixed :)
Thanks a lot.

@andrewchang-bird
Copy link
Contributor

Awesome! Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants