An Xcode Plugin to convert Objective-C to Swift

Related tags

Tools XCSwiftr
Overview

XCSwiftr

Alcatraz compatible License

Convert Objective-C code into Swift from within Xcode. This plugin uses the Java applet of objc2swift to do the conversion.

Noticed that the translation is not always accurate? Does it fail at times? Please consider opening an issue in https://github.com/yahoojapan/objc2swift/issues/new.

Features

Missing Features

  • Language syntax highlight, hopefully with Xcode's current configured theme
  • Auto-convert while typing from the left pane
  • Set minimum size for each outlet presented in the modal window
  • Test coverage

How to use

Select any Objective-C snippet you would like to convert and right click on it.

contextual menu

Click on "Convert to Swift". A modal window will be presented, with the left pane for Objective-C and the left one, for Swift.

main view

Install

Install through Alcatraz, the package manager for Xcode.

Alternatively, clone the project:

  1. Build the project to install the plugin. The plugin will be installed in ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XCSwiftr.xcplugin.

  2. Restart Xcode so the plugin bundle is loaded.

License

(The MIT License)

Copyright (c) 2016 Ignacio Romero Zurbuchen [email protected]

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.

You might also like...
Swift CLI for strong-typing images, colors, storyboards, fonts and localizations

Shark Shark is a Swift command line tool that generates type safe enums for your images, colors, storyboards, fonts and localizations. Because Shark r

Strong typed, autocompleted resources like images, fonts and segues in Swift projects
Strong typed, autocompleted resources like images, fonts and segues in Swift projects

R.swift Get strong typed, autocompleted resources like images, fonts and segues in Swift projects Why use this? It makes your code that uses resources

SwiftGen is a tool to automatically generate Swift code for resources of your projects
SwiftGen is a tool to automatically generate Swift code for resources of your projects

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

Laurine - Localization code generator written in Swift. Sweet!
Laurine - Localization code generator written in Swift. Sweet!

Author's note: Thanks everyone for making Laurine the TOP trending Swift repository in the world - this is amazing and very heart-warming! But this is

swiftenv allows you to easily install, and switch between multiple versions of Swift.
swiftenv allows you to easily install, and switch between multiple versions of Swift.

Swift Version Manager swiftenv allows you to easily install, and switch between multiple versions of Swift. This project was heavily inspired by pyenv

Swift autocompleter for Sublime Text, via the adorable SourceKitten framework
Swift autocompleter for Sublime Text, via the adorable SourceKitten framework

SwiftKitten SwiftKitten is a Swift autocompleter for Sublime Text, via the adorable SourceKitten framework. Faster than XCode ! This package is new an

Xcode-streamdeck-plugin - A Stream Deck plugin for Xcode
Xcode-streamdeck-plugin - A Stream Deck plugin for Xcode

Stream Deck Xcode Plugin This repository contains a Stream Deck plugin to add so

JSPatch bridge Objective-C and Javascript using the Objective-C runtime. You can call any Objective-C class and method in JavaScript by just including a small engine. JSPatch is generally used to hotfix iOS App.

JSPatch 中文介绍 | 文档 | JSPatch平台 请大家不要自行接入 JSPatch,统一接入 JSPatch 平台,让热修复在一个安全和可控的环境下使用。原因详见 这里 JSPatch bridges Objective-C and JavaScript using the Object

LinkedLog is a Xcode plugin that includes a Xcode PCH header file template that adds the macros `LLog` and `LLogF` and parses their output to link from the console to the corresponding file and line.
LinkedLog is a Xcode plugin that includes a Xcode PCH header file template that adds the macros `LLog` and `LLogF` and parses their output to link from the console to the corresponding file and line.

LinkedLog Xcode Plugin LinkedLog is a Xcode plugin that includes a Xcode PCH file template that adds the macros LLog and LLogF. The LLog macro will wo

Xcode plugin that brings ⇧⌘T from AppCode over to Xcode

Aviator An Xcode Plugin that brings ⇧⌘T over to Xcode This minimal plugin allows you to use the key combo ⇧⌘T to toggle between source and test files.

This Xcode plugin shows Xcode app version in the Dock and App Switcher icon
This Xcode plugin shows Xcode app version in the Dock and App Switcher icon

Xcode Icon Version Tired of this Xcode icon always showing multiple times in your App Switch with no help watshoever as to which version you are curre

Swift-lint-plugin - A SwiftPM plugin that adds a linting command

SwiftLintPlugin This is a SwiftPM plugin that adds a lint command. SwiftPM plugi

Plugin-spell-timer - Spell Timer Plugin for Outlander

Spell Timer Plugin for Outlander This plugin provides variables for spells from

Cordova-plugin-saveimage - This plugin helps you save images

cordova-plugin-saveimage This plugin helps you save images on iOS/Android Instal

YapDB is a collection/key/value store with a plugin architecture. It's built atop sqlite, for Swift & objective-c developers.
YapDB is a collection/key/value store with a plugin architecture. It's built atop sqlite, for Swift & objective-c developers.

YapDatabase is a collection/key/value store and so much more. It's built atop sqlite, for Swift & Objective-C developers, targeting macOS, iOS, tvOS &

SwiftLint Plugin for Xcode.
SwiftLint Plugin for Xcode.

SwiftLint Xcode Plugin Demo Usage Set SwiftLint Path default: Default path is /usr/local/bin/swiftlint relative: Relative path with the current projec

A git plugin for real-world xcode versioning workflow.
A git plugin for real-world xcode versioning workflow.

git-xcp The most simplest, safe, and fully automatic git plugin for versioning workflow of real-world xcode projects. Current working or draft content

Nef-plugin - 🔌 an Xcode extension to use nef features easily
Nef-plugin - 🔌 an Xcode extension to use nef features easily

This project provides an extension for Xcode to integrate some nef features directly in the IDE. Using the core of nef, you can export snippets from y

Xcode plugin that moves the instruction pointer to the selected line
Xcode plugin that moves the instruction pointer to the selected line

SFJumpToLine Xcode plugin that moves the instruction pointer to the selected line. Install: Install via Alcatraz Or clone and build the project, then

Comments
  • Old

    Old "C-style" for-loop

    screen shot 2016-04-11 at 7 19 23 pm In Swift 3.0, C-style for-loops will be deprecated, so instead of this:
    // Generated by XCSwiftr
    for var i = 1; i <= 10; i++ {
        print("\(i)")
    }
    

    It should be the swift-style for-loop:

    for i in 0...10 {
         print("\(i)")
    }
    
    opened by lfarah 3
  • Can't translate any objc to swift.

    Can't translate any objc to swift.

    Exception in thread "main" java.lang.NoClassDefFoundError: java/nio/file/Paths at jp.co.yahoo.objc2swift.Main$ValidFile$.unapply(Main.scala:64) at jp.co.yahoo.objc2swift.Main$$anonfun$findFiles$1.apply(Main.scala:86) at jp.co.yahoo.objc2swift.Main$$anonfun$findFiles$1.apply(Main.scala:72) at scala.collection.immutable.List.flatMap(List.scala:327) at jp.co.yahoo.objc2swift.Main$.findFiles(Main.scala:72) at jp.co.yahoo.objc2swift.Main$.main(Main.scala:34) at jp.co.yahoo.objc2swift.Main.main(Main.scala) Caused by: java.lang.ClassNotFoundException: java.nio.file.Paths at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 7 more

    opened by ajsantander 1
  • Syntax Highlighting support

    Syntax Highlighting support

    Hi. Thanks for the plugin! Its great! I was wondering if you'd consider adding syntax highlighting via SourceKit since its simple enough. I've actually used it for a couple of pet projects. I'd be more than happy to submit a PR to add syntax highlight via SourceKit https://github.com/soffes/SyntaxKit . I haven't worked with Xcode plugins before and not sure if its easy and/or good practice dealing w/ cocoa pods. Although we could vendor SyntaxKit via git submodules as you've done with objc2swift java project. Let me know if you're open to this and I'll be more than happy to start working on a PR.

    Thanks again :)

    enhancement 
    opened by hamin 1
Owner
Ignacio Romero Zurbuchen
iOS Dev. Designer. Sometimes I contribute to open source.
Ignacio Romero Zurbuchen
Soulful docs for Swift & Objective-C

jazzy is a command-line utility that generates documentation for Swift or Objective-C About Both Swift and Objective-C projects are supported. Instead

Realm 7.2k Jan 3, 2023
Objective-c code Apple style documentation set generator.

About appledoc IMPORTANT NOTICE: collaborators needed appledoc is command line tool that helps Objective-C developers generate Apple-like source code

tomaz 4.2k Dec 20, 2022
Script to support easily using Xcode Asset Catalog in Swift.

Misen Misen is a script to support using Xcode Asset Catalog in Swift. Features Misen scans sub-directories in the specified Asset Catalog and creates

Kazunobu Tasaka 123 Jun 29, 2022
Automatically build and rebuild Xcode image catalogs for app icons, universal images, and more

Better asset workflow for iOS developers. Generate Xcode image catalogs for iOS / OSX app icons, universal images, and more.

Dotan J. Nahum 822 Dec 21, 2022
Xcode storyboards diff and merge tool.

StoryboardMerge Storyboard diff and merge tool which: compares and merges two storyboard files, provides an automatic merge-facility, The storyboardin

null 238 Sep 12, 2022
Xcode .appiconset generator for Adobe Illustrator.

Creating AppIcon sets from Adobe Illustrator This repo is rewrited from original repo https://github.com/CaryChamplin/CreatingIconsFromAI. Just genera

gitmerge 73 Nov 9, 2020
An Xcode plug-in to format your code using SwiftLint.

SwiftLintXcode An Xcode plug-in to format your code using SwiftLint. Runs swiftlint autocorrect --path CURRENT_FILE before *.swift file is saved. IMPO

Yuya Tanaka 348 Sep 18, 2022
Xcode-compatible build tool.

xcbuild xcbuild is an Xcode-compatible build tool with the goal of providing faster builds, better documentation of the build process and running on m

Meta Archive 2k Dec 11, 2022
An executable that can be called from a Run Script Build Phase that makes comments such as // TODO: or // SERIOUS: appear in Xcode's Issue Navigator giving them project-wide visibility.

XcodeIssueGenerator An executable that can be called from a Run Script Build Phase that makes comments such as // TODO: or // SERIOUS: appear in Xcode

Wunderman Thompson Apps 143 Oct 11, 2022
This repository contains rules for Bazel that can be used to generate Xcode projects

rules_xcodeproj This repository contains rules for Bazel that can be used to generate Xcode projects. If you run into any problems with these rules, p

BuildBuddy 233 Dec 28, 2022