Skip to content
Skills Library
Programming · Building & coding

xmake-objc

/xmake-objc

Use when building Objective-C or Objective-C++ projects with xmake — `.m` / `.mm` sources, Cocoa / Foundation frameworks via `add_frameworks`, mixing with C++, and targeting macOS / iOS / tvOS.

Licence
Apache-2.0
Last repository change
24.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 24.08.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Use when building Objective-C or Objective-C++ projects with xmake — `.m` / `.mm` sources, Cocoa / Foundation frameworks via `add_frameworks`, mixing with C++, and targeting macOS / iOS / tvOS.

Original author description

Use when building Objective-C or Objective-C++ projects with xmake — `.m` / `.mm` sources, Cocoa / Foundation frameworks via `add_frameworks`, mixing with C++, and targeting macOS / iOS / tvOS.

How it works

  1. 1. Minimal Objective-C project
  2. 2. Objective-C++ (mixing with C++)
  3. 3. Frameworks
  4. 4. Flags
  5. 5. Apple platform targets
  6. 6. Application bundle
  7. 7. Consuming Objective-C from Swift
  8. 8. Pure C ↔ Objective-C
  9. Pitfalls
  10. When to branch out
Original SKILL.md headings · 128 lines, 461 words
SKILL.md preview
---
name: xmake-objc
description: Use when building Objective-C or Objective-C++ projects with xmake — `.m` / `.mm` sources, Cocoa / Foundation frameworks via `add_frameworks`, mixing with C++, and targeting macOS / iOS / tvOS.
---

# Building Objective-C / Objective-C++ with Xmake

Objective-C (`.m`) and Objective-C++ (`.mm`) are first-class in xmake. Primary use case: macOS / iOS / tvOS apps, Cocoa frameworks, and mixed C++ / Objective-C projects.

## 1. Minimal Objective-C project

```lua
add_rules("mode.debug", "mode.release")

target("hello")
    set_kind("binary")
    add_files("src/*.m")
    add_frameworks("Foundation")
```

```objc
// src/main.m
#import <Foundation/Foundation.h>
int main() {
    @autoreleasepool {
        NSLog(@"hello from xmake");
    }
    return 0;
}
```

## 2. Objective-C++ (mixing with C++)

Use `.mm` extension and set the C++ language level:

```lua
target("app")
    set_kind("binary")
    set_languages("c++17")
    add_files("src/*.mm", "src/*.cpp")
    add_frameworks("Foundation", "AppKit")
```

`.mm` files compile with the Objective-C++ front-end — you can freely mix `@interface`/`@implementation` with C++ classes and templates.

## 3. Frameworks

```lua
target("app")
    add_frameworks("Foundation", "Cocoa", "AppKit", "Metal", "MetalKit", "CoreGraphics")
    add_frameworkdirs("/Library/Frameworks", "$(projectdir)/vendor/frameworks")
```

- `add_frameworks(...)` — system or user frameworks (equivalent of `-framework <name>`).
- `add_frameworkdirs(...)` — additional search paths for non-system frameworks.

## 4. Flags

```lua
target("app")
    add_mflags("-fobjc-arc")                    -- Objective-C flag (.m)
    add_mxxflags("-fobjc-arc")                  -- Objective-C++ flag (.mm)
```

`add_mflags` / `add_mxxflags` target `.m` / `.mm` respectively; `add_cxflags` still flows through to both.

ARC is the default in modern Xcode; include `-fobjc-arc` explicitly if you want to be sure.

## 5. Apple platform targets

```bash
xmake f -p macosx  -a arm64
xmake f -p iphoneos -a arm64
xmake f -p iphonesimulator -a arm64
xmake f -p appletvos -a arm64
xmake f -p watchos -a arm64
xmake
```

Pin SDK version and minimum deployment:

```bash
xmake f -p iphoneos --xcode_sdkver=17.2 --target_minver=14.0
```

## 6. Application bundle

For a proper `.app` bundle on macOS:

```lua
target("myapp")
    add_rules("xcode.application")               -- produces .app
    add_files("src/*.m", "res/*.storyboard", "res/*.xcassets")
    add_files("res/Info.plist")
    add_frameworks("Foundation", "AppKit")
```

iOS app:

```lua
target("myapp")
    add_rules("xcode.application")
    set_plat("iphoneos")
    add_files("src/*.m", "res/Info.plist")
    add_frameworks("Foundation", "UIKit")
```

`xcode.application` is a built-in rule that produces a proper bundle with Info.plist, code signing hooks, etc.

## 7. Consuming Objective-C from Swift

See `xmake-swift` — Swift interop picks up Objective-C headers via `set_values("swift.interop", "objc")`.

## 8. Pure C ↔ Objective-C

Objective-C is a strict superset of C, so a `.m` file can `#include <stdio.h>` freely. Pure C headers compile inside `.m`/`.mm` files without extra flags.

## Pitfalls

- **`.mm` without `set_languages("c++XX")`.** Defaults to C++98 which is almost never what you want. Set it explicitly.
- **System frameworks vs SDK version.** `add_frameworks("SwiftUI")` fails on old macOS SDKs. Pin with `--xcode_sdkver=` or gate with `is_plat` + minver.
- **Missing `-fobjc-arc` on old code.** Pre-ARC code uses `retain`/`release`; modern code uses ARC. Don't mix arbitrarily.
- **Info.plist missing from bundle.** `xcode.application` needs an `Info.plist` in `add_files` or it produces a broken bundle.
- **Cross-compile to iOS without Xcode.** Only possible on macOS — iOS SDK is Xcode-only.

## When to branch out

- Apple-platform toolchain / SDK → `xmake-cross-compilation`, `xmake-toolchains`
- Swift interop → `xmake-swift`
- Target basics → `xmake-targets`
- Packaging a .app bundle as .dmg / .ipa → `xmake-xpack`

Versions

The database has no other skills named xmake-objc.

Database snapshot: 13.11.2026 · package version 87806ff3d3fb (SHA-256 digest of the entire package)

Downloads in the last 30 days: 2 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100xmake-swift
    Use when building Swift projects with xmake — binary/library targets with `.swift` sources, Swift ↔ C++/Objective-C interop (`swift.interop` value), Swift module name configuration, and iOS/macOS builds.
  • 100objective-c
    Expert Objective-C assistance covering message passing, runtime dynamic method resolution, ARC, and Foundation/Cocoa. Use when maintaining Apple legacy codebases, developing native iOS/macOS frameworks, or C++ interop.
  • 100xmake-cuda
    Use when building CUDA projects with xmake — `.cu` sources, `--cuda=` / `--cuda_sdkver=` SDK pinning, GPU architecture selection, device linking (`build.cuda.devlink`), and mixing CUDA with C++ targets.
  • 95sentry-cocoa-sdk
    Full Sentry SDK setup for Apple platforms (iOS, macOS, tvOS, watchOS, visionOS). Use when asked to "add Sentry to iOS", "add Sentry to Swift", "install sentry-cocoa", or configure error monitoring, tracing, profiling, session replay, or logging for Apple applications. Supports SwiftUI and UIKit.
  • 100sentry-cocoa-sdk
    Full Sentry SDK setup for Apple platforms (iOS, macOS, tvOS, watchOS, visionOS). Use when asked to "add Sentry to iOS", "add Sentry to Swift", "install sentry-cocoa", or configure error monitoring, tracing, profiling, session replay, logging, or metrics for Apple applications.…
  • 90objective-c
    Objective-C开发专家助手。当用户需要进行Objective-C语言开发、遗留iOS代码维护、ARC内存管理、Block/Category/Protocol使用或Swift混编时调用。

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.