From 5dd598fc6d00bf66fe6151bb686515f1a866ce7d Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 6 Aug 2013 18:56:36 +0400 Subject: [PATCH 1/2] Fix building the iOS framework after I dropped the VERSION macro. This version uses CMake to generate Info.plist, which should be more reliable than the old approach. --- CMakeLists.txt | 3 ++- cmake/OpenCVGenInfoPlist.cmake | 4 ++++ platforms/ios/Info.plist.in | 4 ++-- platforms/ios/build_framework.py | 18 ++---------------- 4 files changed, 10 insertions(+), 19 deletions(-) create mode 100644 cmake/OpenCVGenInfoPlist.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 46881c453..2ddbd8407 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -497,6 +497,8 @@ include(cmake/OpenCVGenAndroidMK.cmake) # Generate OpenCVŠ”onfig.cmake and OpenCVConfig-version.cmake for cmake projects include(cmake/OpenCVGenConfig.cmake) +# Generate Info.plist for the IOS framework +include(cmake/OpenCVGenInfoPlist.cmake) # ---------------------------------------------------------------------------- # Summary: @@ -891,4 +893,3 @@ ocv_finalize_status() if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree") endif() - diff --git a/cmake/OpenCVGenInfoPlist.cmake b/cmake/OpenCVGenInfoPlist.cmake new file mode 100644 index 000000000..97c674ceb --- /dev/null +++ b/cmake/OpenCVGenInfoPlist.cmake @@ -0,0 +1,4 @@ +if(IOS) + configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.plist.in" + "${CMAKE_BINARY_DIR}/ios/Info.plist") +endif() diff --git a/platforms/ios/Info.plist.in b/platforms/ios/Info.plist.in index 6bcfe862d..b2a3baf52 100644 --- a/platforms/ios/Info.plist.in +++ b/platforms/ios/Info.plist.in @@ -7,9 +7,9 @@ CFBundleIdentifier org.opencv CFBundleVersion - ${VERSION} + ${OPENCV_LIBVERSION} CFBundleShortVersionString - ${VERSION} + ${OPENCV_LIBVERSION} CFBundleSignature ???? CFBundlePackageType diff --git a/platforms/ios/build_framework.py b/platforms/ios/build_framework.py index bc385bb1b..23da296a4 100755 --- a/platforms/ios/build_framework.py +++ b/platforms/ios/build_framework.py @@ -71,15 +71,6 @@ def put_framework_together(srcroot, dstroot): os.makedirs(framework_dir) os.chdir(framework_dir) - # determine OpenCV version (without subminor part) - tdir0 = "../build/" + targetlist[0] - cfg = open(tdir0 + "/cvconfig.h", "rt") - for l in cfg.readlines(): - if l.startswith("#define VERSION"): - opencv_version = l[l.find("\"")+1:l.rfind(".")] - break - cfg.close() - # form the directory tree dstdir = "Versions/A" os.makedirs(dstdir + "/Resources") @@ -91,13 +82,8 @@ def put_framework_together(srcroot, dstroot): wlist = " ".join(["../build/" + t + "/lib/Release/libopencv_world.a" for t in targetlist]) os.system("lipo -create " + wlist + " -o " + dstdir + "/opencv2") - # form Info.plist - srcfile = open(srcroot + "/platforms/ios/Info.plist.in", "rt") - dstfile = open(dstdir + "/Resources/Info.plist", "wt") - for l in srcfile.readlines(): - dstfile.write(l.replace("${VERSION}", opencv_version)) - srcfile.close() - dstfile.close() + # copy Info.plist + shutil.copyfile("../build/ios/Info.plist", dstdir + "/Resources/Info.plist") # make symbolic links os.symlink("A", "Versions/Current") From 16814c7fb186a0788f27d77d021ab27e5e79bc7e Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Fri, 23 Aug 2013 12:51:50 +0400 Subject: [PATCH 2/2] Update build_framework.py --- platforms/ios/build_framework.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platforms/ios/build_framework.py b/platforms/ios/build_framework.py index 23da296a4..cb3788f7d 100755 --- a/platforms/ios/build_framework.py +++ b/platforms/ios/build_framework.py @@ -75,6 +75,7 @@ def put_framework_together(srcroot, dstroot): dstdir = "Versions/A" os.makedirs(dstdir + "/Resources") + tdir0 = "../build/" + targetlist[0] # copy headers shutil.copytree(tdir0 + "/install/include/opencv2", dstdir + "/Headers") @@ -83,7 +84,7 @@ def put_framework_together(srcroot, dstroot): os.system("lipo -create " + wlist + " -o " + dstdir + "/opencv2") # copy Info.plist - shutil.copyfile("../build/ios/Info.plist", dstdir + "/Resources/Info.plist") + shutil.copyfile(tdir0 + "/ios/Info.plist", dstdir + "/Resources/Info.plist") # make symbolic links os.symlink("A", "Versions/Current") @@ -108,4 +109,4 @@ if __name__ == "__main__": print "Usage:\n\t./build_framework.py \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])) \ No newline at end of file + build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")), os.path.abspath(sys.argv[1]))