diff --git a/platforms/ios/build_framework.py b/platforms/ios/build_framework.py
index 4d4f7e3d03848769aaea902319d010c19c7b865b..5039a75b7ec901c4ab85db7306ca7c8bbf0d8f17 100755
--- a/platforms/ios/build_framework.py
+++ b/platforms/ios/build_framework.py
@@ -25,7 +25,18 @@ The script should handle minor OpenCV updates efficiently
 However, opencv2.framework directory is erased and recreated on each run.
 """
 
-import glob, re, os, os.path, shutil, string, sys
+import glob, re, os, os.path, shutil, string, sys, exceptions, subprocess
+
+def execute(cmd):
+    try:
+        print >>sys.stderr, "Executing:", cmd
+        retcode = subprocess.call(cmd, shell=True)
+        if retcode < 0:
+            raise Exception("Child was terminated by signal:", -retcode)
+        elif retcode > 0:
+            raise Exception("Child returned:", retcode)
+    except OSError as e:
+        raise Exception("Execution failed:", e)
 
 def build_opencv(srcroot, buildroot, target, arch):
     "builds OpenCV for device or simulator"
@@ -44,17 +55,17 @@ def build_opencv(srcroot, buildroot, target, arch):
                 "-DCMAKE_INSTALL_PREFIX=install") % (srcroot, target)
     # if cmake cache exists, just rerun cmake to update OpenCV.xproj if necessary
     if os.path.isfile(os.path.join(builddir, "CMakeCache.txt")):
-        os.system("cmake %s ." % (cmakeargs,))
+        execute("cmake %s ." % (cmakeargs,))
     else:
-        os.system("cmake %s %s" % (cmakeargs, srcroot))
+        execute("cmake %s %s" % (cmakeargs, srcroot))
 
     for wlib in [builddir + "/modules/world/UninstalledProducts/libopencv_world.a",
                  builddir + "/lib/Release/libopencv_world.a"]:
         if os.path.isfile(wlib):
             os.remove(wlib)
 
-    os.system("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 -parallelizeTargets ARCHS=%s -jobs 8 -sdk %s -configuration Release -target ALL_BUILD" % (arch, target.lower()))
-    os.system("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 ARCHS=%s -sdk %s -configuration Release -target install install" % (arch, target.lower()))
+    execute("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 -parallelizeTargets ARCHS=%s -jobs 8 -sdk %s -configuration Release -target ALL_BUILD" % (arch, target.lower()))
+    execute("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 ARCHS=%s -sdk %s -configuration Release -target install install" % (arch, target.lower()))
     os.chdir(currdir)
 
 def put_framework_together(srcroot, dstroot):
@@ -82,7 +93,7 @@ def put_framework_together(srcroot, dstroot):
 
     # make universal static lib
     wlist = " ".join(["../build/" + t + "/lib/Release/libopencv_world.a" for t in targetlist])
-    os.system("lipo -create " + wlist + " -o " + dstdir + "/opencv2")
+    execute("lipo -create " + wlist + " -o " + dstdir + "/opencv2")
 
     # copy Info.plist
     shutil.copyfile(tdir0 + "/ios/Info.plist", dstdir + "/Resources/Info.plist")
@@ -97,10 +108,13 @@ def put_framework_together(srcroot, dstroot):
 def build_framework(srcroot, dstroot):
     "main function to do all the work"
 
-    targets = ["iPhoneOS", "iPhoneOS", "iPhoneOS", "iPhoneSimulator", "iPhoneSimulator"]
-    archs = ["armv7", "armv7s", "arm64", "i386", "x86_64"]
-    for i in range(len(targets)):
-        build_opencv(srcroot, os.path.join(dstroot, "build"), targets[i], archs[i])
+    targets = [("armv7", "iPhoneOS"),
+               ("armv7s", "iPhoneOS"),
+               ("arm64", "iPhoneOS"),
+               ("i386", "iPhoneSimulator"),
+               ("x86_64", "iPhoneSimulator")]
+    for t in targets:
+        build_opencv(srcroot, os.path.join(dstroot, "build"), t[1], t[0])
 
     put_framework_together(srcroot, dstroot)
 
@@ -110,4 +124,8 @@ if __name__ == "__main__":
         print "Usage:\n\t./build_framework.py <outputdir>\n\n"
         sys.exit(0)
 
-    build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")), os.path.abspath(sys.argv[1]))
+    try:
+        build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")), os.path.abspath(sys.argv[1]))
+    except Exception as e:
+        print >>sys.stderr, e
+        sys.exit(1)
diff --git a/platforms/ios/cmake/Modules/Platform/iOS.cmake b/platforms/ios/cmake/Modules/Platform/iOS.cmake
index e021aca55f7825eefbcf24b1c2b1e0ff938bb837..3a80e84ae10e5559770b9816b2db6c77fa23d3ae 100644
--- a/platforms/ios/cmake/Modules/Platform/iOS.cmake
+++ b/platforms/ios/cmake/Modules/Platform/iOS.cmake
@@ -39,8 +39,9 @@ set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSI
 set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
 
 # Hidden visibilty is required for cxx on iOS
-set (CMAKE_C_FLAGS "")
-set (CMAKE_CXX_FLAGS "-stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")
+set (no_warn "-Wno-unused-function -Wno-overloaded-virtual")
+set (CMAKE_C_FLAGS "${no_warn}")
+set (CMAKE_CXX_FLAGS "-stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden ${no_warn}")
 
 set (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math")