開源的 Obj-C至 Swift 轉換器:objc2swift

jopen 9年前發布 | 7K 次閱讀 Apple Swift開發 objc2swift

objc2swift

Try the online version at objc2swift.yahoo-labs.jp

Project Goal

We created objc2swift for our own good, to reduce the redundant task when rewriting Obj-C code to Swift.

Generally, rewriting process consists of two phases: first simply replacing the syntax from Obj-C to Swift, then adopting new features that are introduced to Swift.

objc2swift is aimed at reducing the first half of the process, so that we can focus more on the creative / intellectual work.

Please do not expect complete conversion.

Features

  • Merges@interfaceand@implementationand create a single Swiftclass.
  • Converts properties, including those that have it's own getter/setter in the implementation.
  • Converts message-send to method-call.
  • Converts init-process such as[[MyThing alloc] initWithThing:...]intoMyThing(thing: ...).
  • Converts corresponding types and functions:NSInteger->Int,NSLog->print
  • ...and more!

Quick Start

CLI

Build jar:

$ git clone https://github.com/yahoojapan/objc2swift.git
$ cd objc2swift
$ ./gradlew jar

Create an alias, and pass the Obj-C source files you want to convert.

$ alias objc2swift='java -jar /path/to/objc2swift/build/libs/objc2swift-1.0.jar' $ objc2swift src/test/resources/sample.*

WEB-UI

Install typesafe-activator, and run.

$ brew install typesafe-activator
$ cd web/
$ activator run

Accesslocalhost:9000, and there you are!

項目主頁:http://www.baiduhome.net/lib/view/home/1450791594245

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!