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

Unsupported attribute 'objc' #490

Open
luigigre opened this issue May 8, 2024 · 4 comments
Open

Unsupported attribute 'objc' #490

luigigre opened this issue May 8, 2024 · 4 comments
Labels

Comments

@luigigre
Copy link

luigigre commented May 8, 2024

Hi, upgrading to 2.0 made the script give out errors on classes that were mocked correctly before when using @objc and @objcMembers

Example:
@objc protocol SomeProtocol { }
@objcMembers class SomeClass: NSObject, SomeProtocol {}

Running this script will throw
Unsupported attribute 'objc'
Unsupported attribute 'objcMembers'

And these classes will be skipped from the mocking phase.
The same classes were correctly mocked on 1.10.3.

Did something change that needs to be addressed on my side? Any help or clarification is appreciated

@MatyasKriz
Copy link
Collaborator

Hey, @luigigre. Thanks for pointing this out! It seems like this was undocumented behavior (and not part of the unit tests the project has) and I must have missed it when porting all the functionalities to SwiftSyntax.

I'll get right to it, it shouldn't be hard to add back.

@MatyasKriz MatyasKriz added the bug label May 8, 2024
@MatyasKriz
Copy link
Collaborator

MatyasKriz commented May 8, 2024

I've looked into it and even in 1.10.4 the @objc attributes are not propagated to the generated mocks for me, do you see @objc or @objcMembers in the generated mocks code in 1.10.3? I found out that I can't easily propagate the @objc and @objcMembers attributes into the generated mocks because of the helper structs and classes which have to take the attributes into account as well.

I've also checked the implementation and the Unsupported attribute message doesn't ignore the whole method/class. It just ignores the attribute itself, I've adjusted the wording.

One more thing I've added in 2.0.1 is more logging about which files are being processed when passing the --verbose flag to the generator, when you pass the --verbose flag, is the @objc class you're not seeing is present anywhere in the logs? What about its file name?

@luigigre
Copy link
Author

luigigre commented May 8, 2024

Yes you're right, the message "unsupported attribute" was throwing me off but apparently that's not actually my problem, since the class appears to be mocked but the same tests are not compiling, it's throwing a lot of "unterminated string literal" in the GeneratedMocks file, I'm investigating it so if necessary I will open a separate issue with more details

@MatyasKriz
Copy link
Collaborator

If you could share an example of the code that generates uncompilable mocks, that would be most appreciated as I'd add it to the tests and fix it.

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

No branches or pull requests

2 participants