Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Compiling Objective-C into C++ with Visual Studio

Compiling Objective-C into C++ with Visual Studio

While there were rumors that Microsoft would be adopting Android for the Windows 10 platform, no one expected the announcement that iOS applications would also be adopted. This is made possible, by combining C2 with Clang.

Compiler Support

Google and Apple both use Clang for their C++ frontend. In order to make their code run on Windows, Microsoft had to combine Clang with C2, the backend for the Visual C++ compiler.

Apple’s Objective-C also uses Clang for the frontend. So once the Clang was setup for C2, they also gained the ability to parse and compile Objective-C.

IDE Support

Objective-C in Visual Studio has support for syntax highlighting, code completion, and debugging support. C++ and C# files can be included in the same project, allowing programs to directly make calls across the boundary. The compiler will handle all of the marshalling so the developer just sees normal function calls.

Most Objective-C projects will start as XCode projects, so Visual Studio includes the ability to import that project type. The VS and XCode project files can live the folder, allowing you to work in both IDEs on the same project.

Mixed Mode Projects

Windows offers new APIs to Objective-C applications such as Live Tiles. In order to ensure code can continue to be shared between both platforms, Microsoft is offering the ability to use runtime checks to see if the Windows API is available prior to invoking it. Alternately, you can explicitly use preprocessor directives to segregate platform specific code from shared code.

Runtime Behaviors

By default the Objective-C runtime on Windows detects application’s original platform to determine behavior. For example, if you port an iPhone application then it will default to running in a narrow window while an iPad application runs in a normal window.

All of this behavior can be overridden by the application when needed.

iOS API Compatibility

Windows 10 is supporting a “reasonable subset” of the iOS APIs. It does not track a particular version of iOS, but instead looks at metrics to see which APIs are most commonly used. For the first version, the APIs Microsoft focused on include:

  • Games: OpenGL, OpenAL, and Sensors are well supported.
  • UI: UIKit, CoreAnimation, CoreGraphics, CoreText, Touch
  • Objective-C: ARC, Blocks, Foundation

For features such as share, notifications, and StoreKit, developers need to choose between keeping the iOS APIs or switching to the Windows alternative. If you keep the iOS APIs, Windows will provide a compatibility layer so that the APIs will just work. The benefit of switching is that you gain access to advanced Windows features.


Microsoft’s official stance on Swift is “No comment at this time”. Unofficially, they want to support it but are currently too busy working on getting Objective-C ready for the fall to dedicate resources for Swift.

Rate this Article