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

Swift name annotations #593

Closed
wants to merge 1 commit into from

Conversation

robertjpayne
Copy link

Changes in this pull request

This adds NS_SWIFT_NAME annotations to all public API's to provide cleaner integration into Swift:

  • Removes the need to prefix classes in Swift code, instead rely on Swift module name spacing
  • Adds more argument labels to C function API's like IGListDiff([], [], .equality) => ListDiff(oldArray: [], newArray: [], option: .equality)

While this is a large API change it should be as easy as:

  • Find and replace (IGList)([^K]) to List$2 in Xcode with a scope set to Swift
  • Build and follow compiler's auto fix corrections for C API's or any missed renames

I have not updated the documentation to reflect this yet, I am totally willing to do so but before I sink that amount of time into it I wanted to see if the Instagram team is even open to this change!

Checklist

  • All tests pass. Demo project builds and runs.
  • I added tests, an experiment, or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have reviewed the contributing guide
  • I have updated the documentation

@iglistkit-bot
Copy link

iglistkit-bot commented Mar 29, 2017

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@jessesquires jessesquires added this to the 3.0.0 milestone Mar 29, 2017
@jessesquires
Copy link
Contributor

@robertjpayne Nice! 👍 🥇

Glanced through this and looks pretty good.

cc @rnystrom I'm down for this, but it will be a huge breaking change for 3.0 (but that's probably OK)

@robertjpayne
Copy link
Author

robertjpayne commented Mar 29, 2017

@jessesquires the only think that is actually kinda frustrating is I sort of feel like IGListSectionController should be renamed to IGListBaseSectionController because it always get's subclassed and having it as ListSectionController will probably cause a bit of chaos for anyone that has subclassed it for their own base implementation.

EDIT: actually it's probably better the other way around, to do ListBaseSectionController in app code and leave IGListKit alone.

Copy link
Contributor

@rnystrom rnystrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jessesquires @robertjpayne What do you think about updating the guides that use Swift as well? Do that in a follow up or now?

I'm so down w/ this though!

CHANGELOG.md Outdated
@@ -9,6 +9,23 @@ This release closes the [3.0.0 milestone](https://github.com/Instagram/IGListKit

### Breaking Changes

- Added Swift annotation names removing IGL prefixes from API's and improving those of C functions. [Robert Payne](https://github.com/robertjpayne)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you link to the PR? See other changelog entries as an example

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be done now!

@robertjpayne
Copy link
Author

I think it's probably wise to update the guides at the same time -- I may need a few days to get there though busy end of the week.

@jessesquires
Copy link
Contributor

@robertjpayne - No worries!

@robertjpayne
Copy link
Author

@jessesquires @rnystrom So the documentation is auto generated, I'm not super familiar with Jazzy so I'm not going to touch that, I would hope it can auto-generate the Swift API's vs the ObjC apis?

As far as the guides go, do we assume they are all written for Swift users? I'm curious about what should happen to documentation lines like:

You subclass IGListSectionController and conform to the IGListSectionType protocol.

@jessesquires
Copy link
Contributor

jessesquires commented Apr 1, 2017

@robertjpayne Hm, that's a good point.


We should leave the prefixes for everything, except example docs, etc. that use Swift. So that means we should leave header doc comments alone.

Actually... jazzy might handle this correctly since it will show ObjC and Swift APIs. I won't know for sure until this is merged and I can run the docs scripts to see.

Maybe let's hold off on this for now -- @rnystrom and I can take care of refining docs for the release.

@robertjpayne
Copy link
Author

@jessesquires sounds good -- lemme know if I can help with anything else!

@rnystrom
Copy link
Contributor

rnystrom commented Apr 2, 2017

@robertjpayne ack, mind rebasing? Should just be replacing ListCollectionView with UICollectionView in all the demos.

@jessesquires
Copy link
Contributor

Sorry for those merge conflicts 😊

@facebook-github-bot
Copy link
Contributor

@robertjpayne updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@robertjpayne updated the pull request - view changes

@robertjpayne
Copy link
Author

Alright @jessesquires @rnystrom should be up to date with master now ( ran all the tests and built all the examples ) -- apologies the merge was rather manual instead of a clean rebase because I didn't really feel like using diff merge on every example file!

Also updated the changeling with a link to this PR!

@robertjpayne
Copy link
Author

Can we get Travis to re-test? I think the timeouts are invalid -- locally all the tests are passing…

@jessesquires
Copy link
Contributor

👍

@facebook-github-bot
Copy link
Contributor

@robertjpayne updated the pull request - view changes

Copy link
Contributor

@jessesquires jessesquires left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 🎉

@facebook-github-bot
Copy link
Contributor

@robertjpayne updated the pull request - view changes

@rnystrom
Copy link
Contributor

@jessesquires should we still try to do this for 3.0? Huge rebase necessary. Prepping for documentation updates if we're going to do it.

Tbh I could go either way. I like the idea, but it does make communication a little trickier (ObjC vs Swift language). I'm still on board tho.

@jessesquires
Copy link
Contributor

@rnystrom - yeah I still think this is a good change for Swift clients. The foundation overlays from Apple do this for certain classes. (NSData --> Data, NSUserDefaults --> UserDefaults, etc.)

As long as all that's happening is removing the IG prefix, I think we're ok regarding communication.

@robertjpayne
Copy link
Author

There was a few API changes on the C methods (just added argument labels) but Xcode adds "FIXME"'s for any of those it breaks.

I could have left the argument labels off but I felt it actually helped explain the parameters IGListDiff(...)

@jessesquires
Copy link
Contributor

jessesquires commented Apr 21, 2017

Thanks @robertjpayne ! 💯

do you mind rebasing and fixing conflicts, then we'll get this imported and merged?

@robertjpayne
Copy link
Author

@jessesquires when is it best to land? I can rebase it again (it's actually easier to just use the regex I have to redo it than rebase it). Are you planning on merging some day specific this week so I can line it up to avoid another rebase?

@rnystrom
Copy link
Contributor

rnystrom commented Apr 25, 2017

@robertjpayne we can land at any time (we manually click a button), so its on me not merging this fast enough. If you want to, rebase & push your changes then tweet/DM me and I'll init a land. Sorry for the constant rebasing 😞

Also we don't have anything to land today, so it's a good day for us to get this in

@rnystrom rnystrom mentioned this pull request May 1, 2017
15 tasks
@facebook-github-bot
Copy link
Contributor

@robertjpayne updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@rnystrom has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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

Successfully merging this pull request may close these issues.

5 participants