jarvisbox

Objective-C 轉 Swift 轉換器

在瀏覽器中將 Objective-C 程式碼轉換為 Swift 5.9,NS* 型別、@property、類別宣告及訊息傳送自動翻譯,100% 本地端執行,無需上傳。

100% client-side · no upload · works offline

Swift 5.9 output

Paste Objective-C code and click "Convert to Swift" — output appears here.

How to use

  1. Paste your Objective-C .m or .h file contents into the input panel, or click Load example to try the built-in sample.
  2. Click Convert to Swift — the conversion runs instantly in your browser with no data sent to any server.
  3. Click Copy to copy the Swift 5.9 output. Review any // TODO: lines for patterns that need manual attention, then paste into Xcode.

Related use cases

Related developer tools

常見問題

Does my Objective-C code get uploaded to any server?
No. The conversion runs entirely in your browser using JavaScript. Your source code never leaves your device — no server, no upload, no account required. The converter works offline once the page has loaded.
What Objective-C patterns does this converter support?
The converter handles the most common Objective-C-to-Swift migrations: NS* type replacements (NSString → String, BOOL → Bool, NSInteger → Int, NSArray → [Any], NSDictionary → [String: Any]), @property declarations, @interface and @implementation class structures, method signatures with Objective-C selector labels translated to Swift parameter labels, message sends ([obj method:arg] → obj.method(arg)), #import directives, NSLog → print, and YES/NO/NULL → true/false/nil. Complex patterns such as blocks, preprocessor macros, and @synchronized are left with // TODO: comments so you can handle them manually.
Will the converted Swift code compile immediately?
Not always — no browser-based rule-based tool can guarantee 100% compilable output for every Objective-C file. Treat the output as a strong head start that eliminates the most repetitive find-and-replace work. You will still need to add Swift error handling, verify pointer-ownership semantics, and adapt patterns that have no direct Swift equivalent (preprocessor macros, @synchronized, KVO). Look for // TODO: lines the converter inserts to flag anything that needs manual review.
How does this compare to Swiftify?
Swiftify offers deeper AI-powered conversion via a cloud API but requires an account and limits free conversions, with Swift 5+ output gated behind a paid plan. This tool is 100% client-side and unlimited — ideal for quick migrations, code reviews, and learning the Objective-C/Swift mapping without sending your proprietary code to a third-party server.
Which Swift version does the output target?
The converter targets Swift 5.9 syntax — the default as of Xcode 15. It uses modern Swift idioms: value types where appropriate, optional chaining, and Swift 5 method-label conventions. The output is compatible with Swift 5.0+ in practice.

Last updated:

回報這個工具的問題