37
GitHub - zoejessica/AccessControlKitty: Xcode extension - quickly change access...
source link: https://github.com/zoejessica/AccessControlKitty
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
AccessControlKitty
Xcode extension to change the access control level of Swift code selection
Download from the Mac App Store
Features
- Works on selected Swift code to switch between
public
,private
,fileprivate
,internal
or no access control modifier. Choose an option from the new Access Level of Selection item at the bottom of Xcode's Editor menu: - Increment access levels in selected code. So,
private
andfileprivate
code becomesinternal
,internal
becomespublic
, and anypublic
code stays as is. - Decrement access levels.
private
code stays as is,fileprivate
andinternal
becomeprivate
, andpublic
code becomesinternal
. - Create API – changes all
internal
code topublic
, exposing it as API for your framework - Remove API – similarly, changes all
public
code to beinternal
, removing its visibility as API - Set all appropriate access modifiers to one level
- Remove access notation entirely
- Setters with overriden access levels (for example,
private(set) internal var
) are treated separately: when incrementing/decrementing access, or making/removing API, overridden setters maintain their current access level. If the underlying entity ends up with the same access level as the overriden setter, the explicit override is removed. When setting code to a single access level, the explicit setter override is removed so the entire entity is set to the desired level.
Caveats
- It’s not particularly smart, so for example it doesn’t know if a function can’t be made public because it relies on an internal type. Or if a subclass can't be made public because its superclass isn't public. And it certainly can't reason about anything going on in any other file. It just operates on the bits of selected Swift code that could, grammatically speaking, have an access control modifier.
- It also doesn’t support
open
orfinal
for the moment, mostly because it’s a bit more work and just ship it already, and partly because I sort of feel those notations should require a bit more forethought when planning a framework.
To install:
Available to download now on the Mac App Store. If you prefer to noodle around yourself:
- Download the Xcode project
- Archive the Mac app target
- From the Organizer window, which should open automatically, click
Distribute
and export the created archive using the optionCopy
to use locally. Save wherever you like. - Launch the app
- The extension will now be available in System Preferences, under the Extensions pane, listed as an Xcode Source Editor extension. Activate!
- After an Xcode restart, find it under the Editor menu - it only works on selected Swift code
- For even more radness, you can bind keyboard shortcuts to the menu commands
Bugs & feedback:
- Please create an issue or tweet @zoejessica.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK