1OpenCV iOS Hello {#tutorial_hello} 2================ 3 4Goal 5---- 6 7In this tutorial we will learn how to: 8 9- Link OpenCV framework with Xcode 10- How to write simple Hello World application using OpenCV and Xcode. 11 12Linking OpenCV iOS 13------------------ 14 15Follow this step by step guide to link OpenCV to iOS. 16 17-# Create a new XCode project. 18-# Now we need to link *opencv2.framework* with Xcode. Select the project Navigator in the left 19 hand panel and click on project name. 20-# Under the TARGETS click on Build Phases. Expand Link Binary With Libraries option. 21-# Click on Add others and go to directory where *opencv2.framework* is located and click open 22-# Now you can start writing your application. 23 24![](images/linking_opencv_ios.png) 25 26Hello OpenCV iOS Application 27---------------------------- 28 29Now we will learn how to write a simple Hello World Application in Xcode using OpenCV. 30 31- Link your project with OpenCV as shown in previous section. 32- Open the file named *NameOfProject-Prefix.pch* ( replace NameOfProject with name of your 33 project) and add the following lines of code. 34 @code{.m} 35 #ifdef __cplusplus 36 #import <opencv2/opencv.hpp> 37 #endif 38 @endcode 39 ![](images/header_directive.png) 40 41- Add the following lines of code to viewDidLoad method in ViewController.m. 42 @code{.m} 43 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Hello!" message:@"Welcome to OpenCV" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil]; 44 [alert show]; 45 @endcode 46 ![](images/view_did_load.png) 47 48- You are good to run the project. 49 50Output 51------ 52 53![](images/output.png) 54 55Changes for XCode5+ and iOS8+ 56----------------------------- 57 58With the newer XCode and iOS versions you need to watch out for some specific details 59 60- The *.m file in your project should be renamed to *.mm. 61- You have to manually include AssetsLibrary.framework into your project, which is not done anymore by default. 62