cmake

Warrior

// Warrior.h #import <Foundation/Foundation.h> @interface Warrior : NSObject @end

// Warrior.m #import "Warrior.h" @implementation Warrior @end

Armor

// Armor.h #import <Foundation/Foundation.h> @interface Armor : NSObject @end

// Armor.m #import "Armor.h" @implementation Armor @end

main.m

Warrior

// main.m #import <Foundation/Foundation.h> #import "Warrior.h" int main() { Warrior *w = [Warrior new]; NSLog(@"%@", w); return 0; }

cmake

// CMakeLists.txt cmake_minimum_required(VERSION 2.8) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework Foundation") set(SOURCES Warrior.m Armor.m main.m) add_executable(fdecl ${SOURCES})

$ cd directory_with_project $ cmake . # prepare makefile $ make # build

Scanning dependencies of target fdecl [ 33%] Building CXX object CMakeFiles/fdecl.dir/Warrior.m.o [ 66%] Building CXX object CMakeFiles/fdecl.dir/Armor.m.o [100%] Building CXX object CMakeFiles/fdecl.dir/main.m.o Linking CXX executable fdecl [100%] Built target fdecl

// Warrior.h @interface Warrior : NSObject - (void)wearArmor:(Armor *)armor; @end

// Warrior.m #import "Warrior.h" @implementation Warrior { Armor *_armor; } - (void)wearArmor:(Armor *)armor { _armor = armor; } @end

Armor

#include/#import

// Warrior.h #import "Armor.h" @interface Warrior : NSObject - (void)wearArmor:(Armor *)armor; @end

$ make Scanning dependencies of target fdecl [ 33%] Building CXX object CMakeFiles/fdecl.dir/Warrior.m.o [ 66%] Building CXX object CMakeFiles/fdecl.dir/main.m.o Linking CXX executable fdecl [100%] Built target fdecl

Armor

// Armor.h #import <Foundation/Foundation.h> @interface Armor : NSObject - (BOOL)isMagical; @end

// Armor.m #import "Armor.h" @implementation Armor - (BOOL)isMagical { return YES; } @end

$ make Scanning dependencies of target fdecl [ 33%] Building CXX object CMakeFiles/fdecl.dir/Warrior.m.o [ 66%] Building CXX object CMakeFiles/fdecl.dir/Armor.m.o [100%] Building CXX object CMakeFiles/fdecl.dir/main.m.o Linking CXX executable fdecl [100%] Built target fdecl

main.m

Armor

wearArmor:

Armor

#import

Warrior.m

@class Armor;

Warrior.h

// Warrior.h @class Armor; @interface Warrior : NSObject - (void)wearArmor:(Armor *)armor; @end

// Warrior.m #import "Armor.h" @implementation Warrior { Armor *_armor; } - (void)wearArmor:(Armor *)armor { _armor = armor; } @end

isMagical

Armor

$ make

isMagical

// Armor.h #import <Foundation/Foundation.h> @interface Armor : NSObject - (BOOL)isMagical; @end

// Armor.m #import "Armor.h" @implementation Armor - (BOOL)isMagical { return YES; } @end

$ make Scanning dependencies of target fdecl [ 33%] Building CXX object CMakeFiles/fdecl.dir/Warrior.m.o [ 66%] Building CXX object CMakeFiles/fdecl.dir/Armor.m.o Linking CXX executable fdecl [100%] Built target fdecl

@protocol

// Awesome.h @class Awesome; @protocol AwesomeDelegate - (void)awesome:(Awesome *)awesome didFailed:(NSError *)error; @end @interface Awesome : NSObject @property (weak, nonatomic) id delegate; @end // and then include this header into each class that want to be an awesome delegate

// AwesomeDelegate.h @class Awesome; @protocol AwesomeDelegate - (void)awesome:(Awesome *)awesome didFailed:(NSError *)error; @end

// Awesome.h @protocol AwesomeDelegate; @interface Awesome : NSObject @property (weak, nonatomic) id delegate; @end