Still Using Objective-C in 2025? Build a Powerful macOS Clock in VSCode
While many developers have shifted their focus to Swift and modern frameworks, Objective-C is often seen as a language of the past. However, in low-level applications, macOS desktop development, and even scenarios involving integration with IoT devices, Objective-C continues to demonstrate its flexibility and efficiency. In this article, I’ll show you how to build a macOS desktop clock app using Objective-C with VSCode in 2025 — laying the groundwork for future expansion into IoT integration.

Contents
Why Choose Objective-C?
Although Swift is the official language promoted by Apple, Objective-C still has irreplaceable value. Many existing macOS and iOS frameworks are still written in Objective-C, and its runtime efficiency and mature ecosystem remain unmatched. If you’ve worked with Apple app development, particularly older projects or internal tools, Objective-C is still a very common language.
Additionally, Objective-C’s powerful dynamic runtime system and concise syntax allow it to remain competitive in many system-level development scenarios.
Why Not Choose Xcode? Why Choose VSCode for Development?
While most Apple developers are accustomed to using Xcode to develop applications, VSCode is an excellent alternative for those who prefer to customize their workflows. VSCode is lightweight and supports extensive extensions, making it the editor of choice for many developers.
VSCode supports multiple languages and toolchains, and it works seamlessly with both Objective-C and C++. Its flexibility and customization options allow you to avoid the framework restrictions imposed by some IDEs, while easily managing large projects.
Development Environment
Before getting started, make sure the following tools are installed:
- VSCode (Download)
- C++ Compiler (GCC / Clang / MSVC)
- CMake Tools Extension for VSCode
- Install Xcode Command Line Tools
Developing Objective-C applications requires some tools from Apple. Open the terminal and run the following command to install the Xcode command-line tools:
xcode-select --install
Create a C++ Project in VSCode
Create a folder named MacClockApp and open it in VSCode. Then set up the following file structure inside the folder:
MacClockApp/
├── CMakeLists.txt # CMake configuration
├── main.mm # Main app file (includes C++ time logic)
Create the macOS Clock Application
In VSCode, create a new folder as the root directory of your project, and set up the file structure as described above.
n the project folder, create a file named main.mm
and paste the following code into it:
#import <Cocoa/Cocoa.h>
#include <ctime>
#include <sstream>
// C++: Get current time as HH:MM:SS
std::string getCurrentTime() {
time_t now = time(nullptr);
tm *ltm = localtime(&now);
std::ostringstream oss;
oss << (ltm->tm_hour < 10 ? "0" : "") << ltm->tm_hour << ":"
<< (ltm->tm_min < 10 ? "0" : "") << ltm->tm_min << ":"
<< (ltm->tm_sec < 10 ? "0" : "") << ltm->tm_sec;
return oss.str();
}
// App delegate
@interface ClockAppDelegate : NSObject <NSApplicationDelegate>
@property (strong) NSWindow *window;
@property (strong) NSTextField *label;
@property (strong) NSTimer *timer;
@end
@implementation ClockAppDelegate
// Quit app when window is closed
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
return YES;
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Create window
NSRect frame = NSMakeRect(0, 0, 600, 200);
self.window = [[NSWindow alloc] initWithContentRect:frame
styleMask:(NSWindowStyleMaskTitled |
NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable)
backing:NSBackingStoreBuffered
defer:NO];
[self.window setTitle:@"Big Clock"];
[self.window center];
// Create label
self.label = [[NSTextField alloc] initWithFrame:NSMakeRect(50, 50, 500, 100)];
[self.label setBezeled:NO];
[self.label setDrawsBackground:NO];
[self.label setEditable:NO];
[self.label setSelectable:NO];
[self.label setAlignment:NSTextAlignmentCenter];
// Set large font
NSFont *font = [NSFont systemFontOfSize:100.0];
[self.label setFont:font];
[[self.window contentView] addSubview:self.label];
// Start timer to update clock every second
self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateTime)
userInfo:nil
repeats:YES];
[self.window makeKeyAndOrderFront:nil];
[self updateTime];
}
// Update label with current time
- (void)updateTime {
std::string timeStr = getCurrentTime();
NSString *time = [NSString stringWithUTF8String:timeStr.c_str()];
[self.label setStringValue:time];
}
@end
// Main entry point
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSApplication *app = [NSApplication sharedApplication];
ClockAppDelegate *delegate = [[ClockAppDelegate alloc] init];
[app setDelegate:delegate];
return NSApplicationMain(argc, argv);
}
}
Configure CMakeLists.txt
In the root of your project folder, create a file named CMakeLists.txt
and add the following content to set up the CMake project:
cmake_minimum_required(VERSION 3.16)
project(MacClockApp LANGUAGES C CXX OBJCXX)
# Set C++ and Objective-C++ standards
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_OBJCXX_STANDARD 17)
# Build the app executable
add_executable(MacClockApp
main.mm
)
# Link the Cocoa framework for macOS GUI apps
target_link_libraries(MacClockApp
"-framework Cocoa"
)
Compile and Run
Open the Command Palette
Press Cmd + Shift + P
(or Ctrl + Shift + P
on Windows/Linux), type:
CMake: Build
Then press Enter. CMake will automatically create a build/
folder and complete the compilation process.
Run the Application (macOS only)
In the terminal, run the following command:
./build/MacClockApp
Final Result
When you successfully run ./build/MacClockApp
, you should see a clean and simple window displaying the current time, looking something like this:

Conclusion
While many new developers choose Swift or other modern languages for macOS and iOS development, Objective-C remains a powerful and invaluable tool. Through this article, you not only learned how to develop a macOS application using VSCode and CMake but also demonstrated that, even in 2025, Objective-C can still provide a robust development experience.