.M

M File

Objective-C source file
Ask a question
QUICK ANSWER

An M file is most commonly an Objective-C implementation file - the code half of an Objective-C class, used to build macOS and iOS apps. Open it in Xcode on macOS or any code editor such as VS Code. The same .m extension is also used by MATLAB scripts, Mathematica packages, and Maple files, so the contents tell you which it actually is.

Developer: Apple (Objective-C language; originally Stepstone/Brad Cox & Tom Love, 1984) Category: Developer Files Open standard MIME: text/x-objcsrc
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Jul 1, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the M file format?

.m is a plain-text file format used for storing source code written in the Objective-C programming language. A closely related extension, .mm, supports Objective-C mixed with C++ (Objective-C++). .m files are commonly found on Mac or Windows machines used for developing macOS and iOS applications. Each .m implementation file pairs with a companion .h header of the same base name, which holds the class interface declarations.

Objective-C is a programming language that adds object-oriented capabilities to the C language. Objective-C uses the Cocoa and Cocoa Touch frameworks and is mainly used for writing apps for Apple devices. Unlike C++, Objective-C is a strict superset of ANSI C. An .m file typically begins with #import directives (e.g. #import <Foundation/Foundation.h>) and contains @implementation ... @end blocks defining a class's methods. Since 2011, Automatic Reference Counting (ARC) automates memory management, removing the need for manual retain and release calls. .m files are compiled by clang inside Xcode. Since Apple introduced Swift in 2014, Objective-C is no longer the default for new projects, but .m files remain widespread in legacy codebases and in mixed Swift/Objective-C work.

Security & safety

RISK: LOW

A .m file is plain source code - it does nothing until compiled and run, so the file itself is low risk. The normal source-code cautions apply: read before you build, since compiling and executing unknown code can do anything the resulting program is allowed to do, and source from untrusted repositories may hide malicious logic. There is no macro or auto-execution mechanism in a .m file by merely opening it in an editor. (If the .m turns out to be MATLAB rather than Objective-C, the same advice holds - don't run untrusted scripts.)

Format details

in a nutshell
FULL NAMEObjective-C source fileaka Objective-C implementation file, Objective-C class implementation (.m)
DEVELOPERApple (Objective-C language; originally Stepstone/Brad Cox & Tom Love, 1984)since Objective-C language 1984; .m as the standard implementation-file extension since the NeXTSTEP era (late 1980s)
MIME TYPEtext/x-objcsrc
TYPEPlain-text source code
STANDARDOpen · royalty-free
This extension is also used by…
  • MATLAB script / function file (.m) - Plain-text MATLAB code - scripts and functions for MathWorks MATLAB/Octave; the most common .m file in scientific/engineering use, a different language entirely.
  • Wolfram Mathematica package (.m) - A Wolfram Language package/source file (also seen as .wl) holding definitions, opened by Mathematica.
  • Maple input/.m library file - Maple uses .m for its internal (often binary) library/save files and Maple input code.

Programs that open M files

Windows3 apps
Notepad Open-source Open the .m as plain text/code with C-family syntax highlighting for quick viewing on Windows.
Visual Studio Code Free Open the .m to view/edit with syntax highlighting (install an Objective-C extension). Note: building Apple apps needs macOS/Xcode; on Windows VS Code is for reading/editing the source.
gVim / Vim Open-source Open the .m as a text/code file. Lightweight editor with Objective-C syntax support. (db lists gVim as recommended - valid as a generic code editor.)
macOS3 apps
Apple Xcode Free The native tool: open the project/.m to edit, build and debug Objective-C. Includes the clang compiler and Interface Builder.
BBEdit Freemium Mac text editor with Objective-C syntax highlighting for viewing/editing .m files.
Visual Studio Code Free Edit Objective-C with extensions; pair with the command-line clang/Xcode tools to build.
Linux2 apps
Visual Studio Code Free Edit Objective-C source; build with clang/GNUstep if you're targeting GNUstep rather than Apple platforms.
Vim / jEdit Open-source Open the .m as a code file. jEdit and Vim both highlight Objective-C; build via GNUstep + clang.

Technical details

deep spec
File typePlain-text source code (no binary component)
MIME typetext/x-objcsrc (also accepted as text/plain)
Character encodingUTF-8 or ASCII-compatible; historically also Mac Roman or Latin-1
File signature (magic bytes)None - identified by .m extension only; plain text with no binary header
Typical file structure#import directives followed by one or more @implementation ... @end blocks
Companion header file.h file of the same base name holds the class interface (@interface ... @end)
Key syntax tokens@implementation, @end, @property, @synthesize, #import, - (returnType)methodName
Compilerclang (LLVM); historically gcc before Apple switched in 2012
Memory management modelManual Reference Counting (MRC) or Automatic Reference Counting (ARC, since Xcode 4.2 / 2011)
Associated frameworksCocoa (macOS), Cocoa Touch (iOS/iPadOS)
Typical file sizeA few hundred bytes to several hundred KB of source text
Objective-C++ variant.mm extension used when Objective-C code must interoperate with C++
Associated platformsmacOS, iOS, iPadOS (primary); GNUstep enables use on Linux and Windows
IDE and build toolingApple Xcode (primary IDE); clang and xcodebuild also used from the command line
ReleasedObjective-C language 1984; .m as the standard implementation-file extension since the NeXTSTEP era (late 1980s)
Latest versionObjective-C 2.0 (2006, Mac OS X 10.5); language is stable, now largely supplanted by Swift
Open standardYes · royalty-free
Specificationdeveloper.apple.com

M conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with M files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about M files.

Frequently asked questions

What is a .m file?
In this database it's an Objective-C source file - the implementation (.m) half of an Objective-C class, used for macOS/iOS development. It's plain text. Note the .m extension is also used by MATLAB, Mathematica and Maple, which are different languages.
How do I open a .m file?
Open it in any code editor: Xcode on macOS (the native tool, with compiler), or Visual Studio Code, Vim, BBEdit or Notepad++ on any OS for viewing/editing. It's just text.
Is a .m file Objective-C or MATLAB?
Both languages use .m. Tell them apart by the contents: Objective-C has #import directives and @implementation/@end blocks (and a sibling .h file); MATLAB has 'function' definitions and matrix math. The creating program also indicates which it is.
What's the difference between a .m and a .h file?
They're two halves of an Objective-C class: the .h header declares the interface (@interface - what methods exist), and the .m implementation contains the actual code (@implementation). The .m #imports its .h.
Can I convert Objective-C (.m) to Swift?
Not automatically in any reliable way - migrating to Swift is a manual rewrite. Xcode supports mixed Objective-C/Swift projects via bridging headers so you can migrate gradually rather than all at once.
Do I need a Mac to work with .m (Objective-C) files?
To build Apple apps, yes - Xcode and the iOS/macOS SDKs are macOS-only. You can read and edit the .m source on any OS (VS Code, Vim), and GNUstep+clang lets you compile Objective-C on Linux/Windows for non-Apple targets.

References

1Apple - Programming with Objective-Cdeveloper.apple.com
2Apple - Xcodedeveloper.apple.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.MDMarkdown Document
4.BINCD/DVD Disc Image (BIN/CUE)
5.PARTPartial Download File
6.RPMSGRestricted Permission Message
7.NOMEDIAAndroid No-Media Marker File
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.DBSQLite Database File

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z