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

Nest class with @objc renaming #265

Closed
RoCry opened this issue Sep 22, 2016 · 6 comments
Closed

Nest class with @objc renaming #265

RoCry opened this issue Sep 22, 2016 · 6 comments

Comments

@RoCry
Copy link

RoCry commented Sep 22, 2016

enum A {
    @objc(NestB) class B: UIViewController {

    }
}

I can't use A.B in storyboard, so I use NestB instead.

And R.swift will get the Objc name in swift, which is wrong.

Is there a way to fix it?
Or, can I ignore the .storyboard(one or all) in R.swift so I could handle this manually?

@mac-cain13
Copy link
Owner

Interesting, I wasn't aware this construction is possible!

R.swift has no knowledge of your code at this moment, so it is not possible for R.swift to detect that you don't mean to reference NestB, but A.B in this case. The only workaround, other than avoiding specific ObjC names, I can think of is running a search an replace in the R.swift build step.

Personally I see a lot of developers that just put the class at the top level instead of nesting it.

@RoCry
Copy link
Author

RoCry commented Sep 23, 2016

@mac-cain13 Is it possible to offer a option to use parts of R.swift.

Like "$SRCROOT/rswift" "$SRCROOT/Assets" --skip storyboard

@mac-cain13
Copy link
Owner

In issue #250 there is a discussion about disabling features. So it's not there, but we are thinking about it.

@mac-cain13
Copy link
Owner

mac-cain13 commented Sep 29, 2016

I gave this a bit of thought:

  • In my opinion this is an edge case not many user will encounter.
  • It is quite hard to resolve the correct class to use, since we can't detect this alias. Managing alias lists by hand is not something I think would be a nice solution.
  • We could offer a --skip-file path/to/file option that makes sure that file is completely ignored by R.swift. This would offer a workaround for people running into this issue. This --skip-file feature could also solve Don't create nibs for private classes #225.

Unless there are a lot of people running into this I think that skip file would be an okay solution, it at least gives the ability to keep the code "compilable".

@RoCry
Copy link
Author

RoCry commented Oct 6, 2016

The --skip-file solution seems good for most of the cases

@mac-cain13
Copy link
Owner

I'll close this one in favor of #276. I think that will resolve this one as well once implemented.

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

No branches or pull requests

2 participants