npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

objc2swift

v0.2.1

Published

Objective-C to Swift Converter

Downloads

37

Readme

Objc2Swift.js npm version

Objc2Swift.js is an Objective-C to Swift converter written in JavaScript. (Live Demo)

This project is still highly experimenal and does not aim to provide human-less conversion. However, the most of Objective-C code can be converted to proper Swift code with less compilation errors.

Note: the author currently has no plan to support full features of Swift 3 or greater.

Features

  • Generate good-looking Swift 2.1 code from Objective-C code.
  • Full Objective-C parser which accepts large source code, not for toy-problem.
  • Preserve indents and comments in the original Objective-C code.
  • Reduce compilation errors with semantics analysis. See the Document for detail.
  • Command-line version supports #import delective with pre-compiled header cache.

Install

$ npm install -g objc2swift

Then, run the objc2swift command with --init option to setup the default configuration.

$ objc2swift --init ios

Note that the parameter ios means to setup objc2swift for using Xcode's iOS SDK. If you want to target other SDK, use osx, tvos or watchos.

Convert

Pass the target source file to the command. The conversion result will be written to the current directory with extension .swift.

$ objc2swift foo.m

The first conversion is very slow since there is no pre-compiled header cache. It will be speed-up later.

By default, the command searches user headers from the current directory and its subdirectories. To import more headers, use -I option can be used to specifiy include paths. For example,

$ objc2swift -I ~/git/myproject/ foo.m

The path specified by -I is recursively traversed.

Configuration

The default config path is ~/.objc2swift/config.json. A typical content of config.json is like following. If you want to add user header search path permanently instead of -I, add the path to includePaths array.

{
    "systemIncludePaths": [
        "${Xcode.app}/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks",
        "${Xcode.app}/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include",
        "${Xcode.app}/Contents/Developer/Platforms/iPhoneOS.platform/usr/lib/clang/3.5/include"
    ],
    "includePaths": []
}

How to Build

git clone https://github.com/okaxaki/objc2swift.git
cd objc2swift
npm install
npm run build