• Stars
    star
    991
  • Rank 46,212 (Top 1.0 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Xcode Plugin that Refactors Swift & Objective-C

Refactorator Xcode Plugin

Due to changes in the index database with Xcode 10 this plugin no longer works.

Refactorator is an Xcode plugin for refactoring Swift & now Objective-C code. It will rename public or internal vars, functions, enums etc. For private and local entities use Xcode's existing "Edit All in Scope" functionality.

Stop Press: Refactorator no longer uses SourceKit directly, rather it accesses the SQLite database Xcode compiles using SourceKit. This makes it both faster as it no longer needs to re-index the sources of your project but also means all targets of a project are included in refactoring including code written in Objectve-C.

An improved version of Refactorator is now available as a standalone App avilable here

Icon

To use, download the source for this project and build to install the plugin then restart Xcode. Not used a Plugin before? Use Alcatraz Package Manager to install it. Select a symbol in a Swift source and use "Right-click/Refactor/Swift !" to list places in the target that declare or refer to that symbol. Enter a new value for the identifier in the bottom textfield and press the "Preview" button to view the changes that would be made. Press the "Save" button to save these changes to disk. Use the "Undo" button to revert the changes if need be.

As a by-product of the analysis performed for refactoring, if you have Graphviz installed, you can view an approximate visualisation of the classes in your project and their interrelationships using the "Edit/Refactor/Visualise !" menu item. Initialiser calls are coloured green, ivar references blue, and method calls red:

Icon

Refactorator was originally suggested as being feasible by @Daniel1of1 shortly after Swift came out building on the work by @jpsim on SourceKitten. The last piece of the puzzle was the Open Sourcing of the SourceKit API by Apple as a part of Swift. Source files are parsed using data from the same XPC calls that Xcode uses when it indexes a project and implemented in a daemon process so as not to affect the stability of Xcode. Invaluable in underdstanding the index database was DB Browser for SQLite and the SQLite Swift code was helped along by reference to the excellent SQLite.swift.

MIT License

Copyright (C) 2015 John Holdsworth

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This source includes a header file "sourcekit.h" from Apple's Swift distribution under Apache License v2.0

More Repositories

1

injectionforxcode

Runtime Code Injection for Objective-C & Swift
Objective-C
6,551
star
2

InjectionIII

Re-write of Injection for Xcode in (mostly) Swift
Objective-C
3,995
star
3

Xtrace

Trace Objective-C method calls by class or instance
Objective-C++
1,832
star
4

GitDiff

Highlights deltas against git repo in Xcode
Objective-C
891
star
5

Remote

Control your iPhone from inside Xcode for end-to-end testing.
Objective-C
853
star
6

SwiftTrace

Trace Swift and Objective-C method invocations
Swift
695
star
7

HotReloading

Hot reloading as a Swift Package
Swift
536
star
8

XprobePlugin

Live Memory Browser for Apps & Xcode
Objective-C++
395
star
9

RefactoratorApp

App version of Refactorator plugin
Swift
255
star
10

Accelerator

Inline frameworks of Swift CocoaPods projects for faster launch
Ruby
174
star
11

InjectionApp

Issue Tracking Repo for Injection as an App
Swift
111
star
12

Fortify

Making Swift more robust
Swift
95
star
13

HotSwiftUI

Utilities for Hot Reloading SwiftUI apps.
Swift
94
star
14

Diamond

Diamond - Swift scripting made easy
Objective-C
94
star
15

SwiftPython

Experiments in bridging Swift to Python
Swift
88
star
16

Dynamo

High Performance (nearly)100% Swift Web server supporting dynamic content.
Swift
68
star
17

SwiftRegex

Some regular expression operators for Swift
Swift
67
star
18

NSLinux

NSString and libdispatch compatibility code for Swift on Linux
Swift
47
star
19

InstantSyntax

SwiftSyntax binary frameworks
Swift
47
star
20

InjectionNext

Fourth evolution of Code Injection for Xcode
Swift
47
star
21

WatchkitCurrency

Swift Currency Convertor for iWatch with flexible interface
Swift
40
star
22

TwoWayMirror

Adapt Swift’s Mirror functionality to make it bidirectional.
Swift
38
star
23

InjectionLite

Swift package re-write of InjectionIII app
Swift
34
star
24

Smuggler

Smuggle code bundles into an app running in the Simulator
Objective-C++
32
star
25

SwiftRegex5

5th incarnation of Swift Regex library using generic subscripts
Swift
32
star
26

SwiftAspects

Experiments in Aspects with Swift (Xtrace for Swift)
Assembly
30
star
27

unhide

export symbols with “hidden” visibility for Swift frameworks
Objective-C++
25
star
28

Symbolicate

Symbolicate for OS X
Objective-C
23
star
29

DLKit

A rather subscript oriented interface to the dynamic linker.
Swift
22
star
30

SwiftTryCatch

Try/Catch for Swift?
Swift
15
star
31

ApportablePlugin

Simple Plugin for work with Apportable
Objective-C
14
star
32

Compilertron

InjectionIII for the Swift compiler
C++
14
star
33

SearchLight

SpotLight on Steroids
Objective-C++
14
star
34

siteify

Build web site from a project’s Swift sources.
HTML
13
star
35

SwiftPlugin

A way to import classes from plugins
Swift
12
star
36

SwiftKeyPath

valueForKeyPath: for Swift
Swift
12
star
37

DynamoLinux

100% Swift Linux Web Server
Swift
11
star
38

ProfileSwiftUI

InstrumentSwiftUI
Swift
10
star
39

SwiftUIPlaygrounds

Alternative to Xcode previews.
Swift
9
star
40

SwiftRegex4

Basic regex operations for Swift4
Swift
9
star
41

StringIndex

Sensible indexing into Swift Strings
Swift
8
star
42

SwiftView

Curated Xcode Project as a means of navigating Swift Sources
7
star
43

Parallel

Some primitives for concurrent processing
Swift
6
star
44

Popen

Reading and writing processes and files
Swift
6
star
45

WatchkitSundial

Sundial for Apple Watch
Objective-C
6
star
46

SwiftierJSON

Memory efficient version of SwiftyJSON
Swift
6
star
47

objectivecpp

HTML
5
star
48

YieldGenerator

Python's "yield" generators for Swift
Swift
5
star
49

opaqueify

Greater use of Opaque types (SE0335)
Swift
5
star
50

SwiftMock

Mock structs and classes without code modification for testing.
Swift
4
star
51

Unwrap

Self documenting alternatives to force unwrap operator.
Swift
4
star
52

InjectionScratch

InjectionScratch
Objective-C++
3
star
53

EasyPointer

Rounding off some of the rough edges of Swift's pointer model
Swift
2
star
54

TestRunner

Example of calling Swift methods using name pattern (XCTest?)
Swift
2
star
55

binary-Swallow0

Swift
1
star
56

Character

Integer conversions and operators for Swift Characters.
Swift
1
star
57

ASCII

Facilitating operations on ASCII in Swift
Swift
1
star