From e62bdf0984d84f3a91cfc1875a31f73453c884e8 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 1 Oct 2017 03:43:00 +0200 Subject: [PATCH 01/13] Create dynamic framework from arch dylibs --- create-openssl-framework.sh | 58 ++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index 605a171..c5ebe2f 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash FWNAME=openssl @@ -12,15 +12,57 @@ if [ -d $FWNAME.framework ]; then rm -rf $FWNAME.framework fi -if [ "$1" == "dynamic" ]; then - LIBTOOL_FLAGS="-dynamic -undefined dynamic_lookup -ios_version_min 8.0" -else - LIBTOOL_FLAGS="-static" -fi - echo "Creating $FWNAME.framework" mkdir -p $FWNAME.framework/Headers -libtool -no_warning_for_no_symbols $LIBTOOL_FLAGS -o $FWNAME.framework/$FWNAME lib/libcrypto.a lib/libssl.a + +if [ "$1" == "dynamic" ]; then + DEVELOPER=`xcode-select -print-path` + FW_EXEC_NAME="${FWNAME}.framework/${FWNAME}" + INSTALL_NAME="@rpath/${FW_EXEC_NAME}" + COMPAT_VERSION="1.0.0" + CURRENT_VERSION="1.0.0" + + LIBTOOL_FLAGS="-dynamic -lSystem -ios_version_min 8.0" + RX='([A-z]+)([0-9]+(\.[0-9]+)*)-([A-z0-9]+)\.sdk' + + cd bin + for TARGETDIR in `ls -d *.sdk`; do + if [[ $TARGETDIR =~ $RX ]]; then + PLATFORM="${BASH_REMATCH[1]}" + SDKVERSION="${BASH_REMATCH[2]}" + ARCH="${BASH_REMATCH[4]}" + fi + + echo "Assembling .dylib for $ARCH" + + CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" + CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" + SDK="${CROSS_TOP}/SDKs/${CROSS_SDK}" + + #cd $TARGETDIR + #libtool $LIBTOOL_FLAGS -L"$SDK/usr/lib/" -install_name $INSTALL_NAME -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION lib/*.a -o $FWNAME.dylib + + TARGETOBJ="${TARGETDIR}/obj" + rm -rf $TARGETOBJ + mkdir $TARGETOBJ + cd $TARGETOBJ + ar -x ../lib/libcrypto.a + ar -x ../lib/libssl.a + cd .. + ld obj/*.o -dylib -lSystem -ios_version_min 8.0 -L"$SDK/usr/lib/" -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib + install_name_tool -id $INSTALL_NAME $FWNAME.dylib + + cd .. + done + cd .. + + lipo -create bin/*/$FWNAME.dylib -output $FWNAME.framework/$FWNAME + rm bin/*/$FWNAME.dylib +else + LIBTOOL_FLAGS="-static" + libtool $LIBTOOL_FLAGS -o $FWNAME.framework/$FWNAME lib/libcrypto.a lib/libssl.a +fi + cp -r include/$FWNAME/* $FWNAME.framework/Headers/ DIR="$(cd "$(dirname "$0")" && pwd)" From dd9a625aa563d60c150cf7038806f86483dae3c8 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 1 Oct 2017 13:53:23 +0200 Subject: [PATCH 02/13] Normalize supporting files in Xcode project --- OpenSSL-for-iOS.xcodeproj/project.pbxproj | 24 +++++++++---------- ...OS-Bridging-Header.h => Bridging-Header.h} | 0 ...{OpenSSL-for-iOS-Info.plist => Info.plist} | 0 ...{OpenSSL-for-iOS-Prefix.pch => Prefix.pch} | 0 4 files changed, 12 insertions(+), 12 deletions(-) rename OpenSSL-for-iOS/{OpenSSL-for-iOS-Bridging-Header.h => Bridging-Header.h} (100%) rename OpenSSL-for-iOS/{OpenSSL-for-iOS-Info.plist => Info.plist} (100%) rename OpenSSL-for-iOS/{OpenSSL-for-iOS-Prefix.pch => Prefix.pch} (100%) diff --git a/OpenSSL-for-iOS.xcodeproj/project.pbxproj b/OpenSSL-for-iOS.xcodeproj/project.pbxproj index d6bd5f6..f6e52ca 100644 --- a/OpenSSL-for-iOS.xcodeproj/project.pbxproj +++ b/OpenSSL-for-iOS.xcodeproj/project.pbxproj @@ -43,7 +43,7 @@ /* Begin PBXFileReference section */ 2A1DDC8E1BFB1DF600F7722A /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = ""; }; - 2A3820FE1BFB5EEA00328618 /* OpenSSL-for-iOS-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OpenSSL-for-iOS-Bridging-Header.h"; sourceTree = ""; }; + 2A3820FE1BFB5EEA00328618 /* Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = ""; }; 2A3820FF1BFB5EEB00328618 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 2A3821011BFB607A00328618 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 2A8A9A6F1BFA59F7002944B4 /* OpenSSL-for-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OpenSSL-for-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -56,8 +56,8 @@ 533ED2FF1528C4840005C6FA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 533ED3011528C4840005C6FA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 533ED3031528C4840005C6FA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - 533ED3071528C4840005C6FA /* OpenSSL-for-iOS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OpenSSL-for-iOS-Info.plist"; sourceTree = ""; }; - 533ED30D1528C4840005C6FA /* OpenSSL-for-iOS-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OpenSSL-for-iOS-Prefix.pch"; sourceTree = ""; }; + 533ED3071528C4840005C6FA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 533ED30D1528C4840005C6FA /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 533ED32A1528C53B0005C6FA /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = lib/libcrypto.a; sourceTree = ""; }; 533ED32B1528C53B0005C6FA /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = lib/libssl.a; sourceTree = ""; }; 534FB2AD180975D700B5F868 /* Icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icons.xcassets; sourceTree = ""; }; @@ -174,9 +174,9 @@ 533ED3061528C4840005C6FA /* Supporting Files */ = { isa = PBXGroup; children = ( - 533ED3071528C4840005C6FA /* OpenSSL-for-iOS-Info.plist */, - 533ED30D1528C4840005C6FA /* OpenSSL-for-iOS-Prefix.pch */, - 2A3820FE1BFB5EEA00328618 /* OpenSSL-for-iOS-Bridging-Header.h */, + 533ED3071528C4840005C6FA /* Info.plist */, + 533ED30D1528C4840005C6FA /* Prefix.pch */, + 2A3820FE1BFB5EEA00328618 /* Bridging-Header.h */, ); name = "Supporting Files"; sourceTree = ""; @@ -554,8 +554,8 @@ ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Prefix.pch"; - INFOPLIST_FILE = "OpenSSL-for-iOS/OpenSSL-for-iOS-Info.plist"; + GCC_PREFIX_HEADER = "OpenSSL-for-iOS/Prefix.pch"; + INFOPLIST_FILE = "$(SRCROOT)/OpenSSL-for-iOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -563,7 +563,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OpenSSL; - SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 3.0; WRAPPER_EXTENSION = app; @@ -577,8 +577,8 @@ ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Prefix.pch"; - INFOPLIST_FILE = "OpenSSL-for-iOS/OpenSSL-for-iOS-Info.plist"; + GCC_PREFIX_HEADER = "OpenSSL-for-iOS/Prefix.pch"; + INFOPLIST_FILE = "$(SRCROOT)/OpenSSL-for-iOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -586,7 +586,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OpenSSL; - SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/Bridging-Header.h"; SWIFT_VERSION = 3.0; WRAPPER_EXTENSION = app; }; diff --git a/OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h b/OpenSSL-for-iOS/Bridging-Header.h similarity index 100% rename from OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h rename to OpenSSL-for-iOS/Bridging-Header.h diff --git a/OpenSSL-for-iOS/OpenSSL-for-iOS-Info.plist b/OpenSSL-for-iOS/Info.plist similarity index 100% rename from OpenSSL-for-iOS/OpenSSL-for-iOS-Info.plist rename to OpenSSL-for-iOS/Info.plist diff --git a/OpenSSL-for-iOS/OpenSSL-for-iOS-Prefix.pch b/OpenSSL-for-iOS/Prefix.pch similarity index 100% rename from OpenSSL-for-iOS/OpenSSL-for-iOS-Prefix.pch rename to OpenSSL-for-iOS/Prefix.pch From 10b342fb7ef673b7f4f609f7121146f1ac9e30c7 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 1 Oct 2017 14:02:31 +0200 Subject: [PATCH 03/13] Create frameworks for both iPhone and AppleTV --- assets/AppleTV/Info.plist | 1 + assets/iPhone/Info.plist | 1 + build-libssl.sh | 8 +++--- create-openssl-framework.sh | 57 +++++++++++++++++++++++++------------ 4 files changed, 45 insertions(+), 22 deletions(-) create mode 120000 assets/AppleTV/Info.plist create mode 120000 assets/iPhone/Info.plist diff --git a/assets/AppleTV/Info.plist b/assets/AppleTV/Info.plist new file mode 120000 index 0000000..776c8e5 --- /dev/null +++ b/assets/AppleTV/Info.plist @@ -0,0 +1 @@ +../../OpenSSL-for-tvOS/Info.plist \ No newline at end of file diff --git a/assets/iPhone/Info.plist b/assets/iPhone/Info.plist new file mode 120000 index 0000000..f3fb677 --- /dev/null +++ b/assets/iPhone/Info.plist @@ -0,0 +1 @@ +../../OpenSSL-for-iOS/Info.plist \ No newline at end of file diff --git a/build-libssl.sh b/build-libssl.sh index d7f0d68..5fb7bfa 100755 --- a/build-libssl.sh +++ b/build-libssl.sh @@ -473,15 +473,15 @@ fi # Build iOS library if selected for build if [ ${#LIBSSL_IOS[@]} -gt 0 ]; then echo "Build library for iOS..." - lipo -create ${LIBSSL_IOS[@]} -output "${CURRENTPATH}/lib/libssl.a" - lipo -create ${LIBCRYPTO_IOS[@]} -output "${CURRENTPATH}/lib/libcrypto.a" + lipo -create ${LIBSSL_IOS[@]} -output "${CURRENTPATH}/lib/libssl-iPhone.a" + lipo -create ${LIBCRYPTO_IOS[@]} -output "${CURRENTPATH}/lib/libcrypto-iPhone.a" fi # Build tvOS library if selected for build if [ ${#LIBSSL_TVOS[@]} -gt 0 ]; then echo "Build library for tvOS..." - lipo -create ${LIBSSL_TVOS[@]} -output "${CURRENTPATH}/lib/libssl-tvOS.a" - lipo -create ${LIBCRYPTO_TVOS[@]} -output "${CURRENTPATH}/lib/libcrypto-tvOS.a" + lipo -create ${LIBSSL_TVOS[@]} -output "${CURRENTPATH}/lib/libssl-AppleTV.a" + lipo -create ${LIBCRYPTO_TVOS[@]} -output "${CURRENTPATH}/lib/libcrypto-AppleTV.a" fi # Copy include directory diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index c5ebe2f..1be2e4a 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -1,19 +1,19 @@ #!/bin/bash FWNAME=openssl +FWDIR=frameworks if [ ! -d lib ]; then echo "Please run build-libssl.sh first!" exit 1 fi -if [ -d $FWNAME.framework ]; then - echo "Removing previous $FWNAME.framework copy" - rm -rf $FWNAME.framework +if [ -d $FWDIR ]; then + echo "Removing previous $FWNAME.framework copies" + rm -rf $FWDIR fi -echo "Creating $FWNAME.framework" -mkdir -p $FWNAME.framework/Headers +ALL_SYSTEMS=("iPhone" "AppleTV") if [ "$1" == "dynamic" ]; then DEVELOPER=`xcode-select -print-path` @@ -22,7 +22,6 @@ if [ "$1" == "dynamic" ]; then COMPAT_VERSION="1.0.0" CURRENT_VERSION="1.0.0" - LIBTOOL_FLAGS="-dynamic -lSystem -ios_version_min 8.0" RX='([A-z]+)([0-9]+(\.[0-9]+)*)-([A-z0-9]+)\.sdk' cd bin @@ -39,8 +38,14 @@ if [ "$1" == "dynamic" ]; then CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" SDK="${CROSS_TOP}/SDKs/${CROSS_SDK}" + if [[ $PLATFORM == AppleTV* ]]; then + MIN_SDK="-tvos_version_min 9.0" + else + MIN_SDK="-ios_version_min 8.0" + fi + #cd $TARGETDIR - #libtool $LIBTOOL_FLAGS -L"$SDK/usr/lib/" -install_name $INSTALL_NAME -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION lib/*.a -o $FWNAME.dylib + #libtool -dynamic -lSystem $MIN_SDK -L"$SDK/usr/lib/" -install_name $INSTALL_NAME -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION lib/*.a -o $FWNAME.dylib TARGETOBJ="${TARGETDIR}/obj" rm -rf $TARGETOBJ @@ -49,27 +54,43 @@ if [ "$1" == "dynamic" ]; then ar -x ../lib/libcrypto.a ar -x ../lib/libssl.a cd .. - ld obj/*.o -dylib -lSystem -ios_version_min 8.0 -L"$SDK/usr/lib/" -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib + ld obj/*.o -dylib -lSystem $MIN_SDK -L"$SDK/usr/lib/" -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib install_name_tool -id $INSTALL_NAME $FWNAME.dylib cd .. done cd .. - lipo -create bin/*/$FWNAME.dylib -output $FWNAME.framework/$FWNAME + for SYS in ${ALL_SYSTEMS[@]}; do + SYSDIR=$FWDIR/$SYS + + # FIXME: skip if no device objects + + echo "Creating framework for $SYS" + mkdir -p $SYSDIR/$FWNAME.framework/Headers + lipo -create bin/${SYS}*/$FWNAME.dylib -output $SYSDIR/$FWNAME.framework/$FWNAME + cp -r include/$FWNAME/* $SYSDIR/$FWNAME.framework/Headers/ + cp -L assets/$SYS/Info.plist $SYSDIR/$FWNAME.framework/Info.plist + echo "Created $SYSDIR/$FWNAME.framework" + done + rm bin/*/$FWNAME.dylib else - LIBTOOL_FLAGS="-static" - libtool $LIBTOOL_FLAGS -o $FWNAME.framework/$FWNAME lib/libcrypto.a lib/libssl.a + for SYS in ${ALL_SYSTEMS[@]}; do + SYSDIR=$FWDIR/$SYS + + # FIXME: skip if no device objects + + echo "Creating framework for $SYS" + mkdir -p $SYSDIR/$FWNAME.framework/Headers + libtool -static -o $SYSDIR/$FWNAME.framework/$FWNAME lib/libcrypto-$SYS.a lib/libssl-$SYS.a + cp -r include/$FWNAME/* $SYSDIR/$FWNAME.framework/Headers/ + cp -L assets/$SYS/Info.plist $SYSDIR/$FWNAME.framework/Info.plist + echo "Created $SYSDIR/$FWNAME.framework" + done fi -cp -r include/$FWNAME/* $FWNAME.framework/Headers/ - -DIR="$(cd "$(dirname "$0")" && pwd)" -cp $DIR/"OpenSSL-for-iOS/OpenSSL-for-iOS-Info.plist" $FWNAME.framework/Info.plist -echo "Created $FWNAME.framework" - -check_bitcode=`otool -arch arm64 -l $FWNAME.framework/$FWNAME | grep __bitcode` +check_bitcode=`otool -arch arm64 -l $FWDIR/iPhone/$FWNAME.framework/$FWNAME | grep __bitcode` if [ -z "$check_bitcode" ] then echo "INFO: $FWNAME.framework doesn't contain Bitcode" From 4dd2bd9d675e18cfbb8f65d5d6e04c53c0cff7ff Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 1 Oct 2017 20:41:49 +0200 Subject: [PATCH 04/13] Specify -arch in ld to fix page size crash --- create-openssl-framework.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index 1be2e4a..58cb9ec 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -54,7 +54,7 @@ if [ "$1" == "dynamic" ]; then ar -x ../lib/libcrypto.a ar -x ../lib/libssl.a cd .. - ld obj/*.o -dylib -lSystem $MIN_SDK -L"$SDK/usr/lib/" -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib + ld obj/*.o -dylib -lSystem -arch $ARCH $MIN_SDK -L"$SDK/usr/lib/" -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib install_name_tool -id $INSTALL_NAME $FWNAME.dylib cd .. From 2ed8b30de7d0c3ee7bf157e7531c5e97caa4a045 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 1 Oct 2017 21:38:48 +0200 Subject: [PATCH 05/13] Adjust Xcode project and Travis-CI to latest fixes --- OpenSSL-for-iOS.xcodeproj/project.pbxproj | 40 ++++++++++++----------- travis-build.sh | 4 +-- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/OpenSSL-for-iOS.xcodeproj/project.pbxproj b/OpenSSL-for-iOS.xcodeproj/project.pbxproj index f6e52ca..7543aec 100644 --- a/OpenSSL-for-iOS.xcodeproj/project.pbxproj +++ b/OpenSSL-for-iOS.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 0EA706651F817CCC001E4F88 /* libcrypto-iPhone.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EA706611F817CCB001E4F88 /* libcrypto-iPhone.a */; }; + 0EA706661F817CCC001E4F88 /* libssl-iPhone.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EA706621F817CCB001E4F88 /* libssl-iPhone.a */; }; + 0EA706681F817CE5001E4F88 /* libcrypto-AppleTV.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EA706601F817CCB001E4F88 /* libcrypto-AppleTV.a */; }; + 0EA706691F817CE5001E4F88 /* libssl-AppleTV.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EA706631F817CCC001E4F88 /* libssl-AppleTV.a */; }; 2A1DDC8F1BFB1DF600F7722A /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2A1DDC8E1BFB1DF600F7722A /* ViewController.xib */; }; 2A3821001BFB5EEB00328618 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A3820FF1BFB5EEB00328618 /* AppDelegate.swift */; }; 2A3821021BFB607A00328618 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A3821011BFB607A00328618 /* ViewController.swift */; }; @@ -15,13 +19,9 @@ 2A8A9A7E1BFA59F7002944B4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2A8A9A7D1BFA59F7002944B4 /* Assets.xcassets */; }; 2A8A9A851BFA5AFF002944B4 /* ViewController~tv.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2A8A9A841BFA5AFF002944B4 /* ViewController~tv.xib */; }; 2A8A9A871BFA5B6A002944B4 /* FSOpenSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = D1E97EE2A904D58DAE4231E2 /* FSOpenSSL.m */; }; - 2A8A9A8A1BFA5B85002944B4 /* libcrypto-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A8A9A881BFA5B85002944B4 /* libcrypto-tvOS.a */; }; - 2A8A9A8B1BFA5B85002944B4 /* libssl-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A8A9A891BFA5B85002944B4 /* libssl-tvOS.a */; }; 533ED3001528C4840005C6FA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED2FF1528C4840005C6FA /* UIKit.framework */; }; 533ED3021528C4840005C6FA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED3011528C4840005C6FA /* Foundation.framework */; }; 533ED3041528C4840005C6FA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED3031528C4840005C6FA /* CoreGraphics.framework */; }; - 533ED32C1528C53B0005C6FA /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED32A1528C53B0005C6FA /* libcrypto.a */; }; - 533ED32D1528C53B0005C6FA /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED32B1528C53B0005C6FA /* libssl.a */; }; 534FB2AE180975D700B5F868 /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 534FB2AD180975D700B5F868 /* Icons.xcassets */; }; 53572A4D183AAFFE00B21832 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 53572A4C183AAFFE00B21832 /* XCTest.framework */; }; 53572A4E183AAFFE00B21832 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED3011528C4840005C6FA /* Foundation.framework */; }; @@ -42,6 +42,10 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 0EA706601F817CCB001E4F88 /* libcrypto-AppleTV.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libcrypto-AppleTV.a"; path = "lib/libcrypto-AppleTV.a"; sourceTree = ""; }; + 0EA706611F817CCB001E4F88 /* libcrypto-iPhone.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libcrypto-iPhone.a"; path = "lib/libcrypto-iPhone.a"; sourceTree = ""; }; + 0EA706621F817CCB001E4F88 /* libssl-iPhone.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libssl-iPhone.a"; path = "lib/libssl-iPhone.a"; sourceTree = ""; }; + 0EA706631F817CCC001E4F88 /* libssl-AppleTV.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libssl-AppleTV.a"; path = "lib/libssl-AppleTV.a"; sourceTree = ""; }; 2A1DDC8E1BFB1DF600F7722A /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = ""; }; 2A3820FE1BFB5EEA00328618 /* Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = ""; }; 2A3820FF1BFB5EEB00328618 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -50,16 +54,12 @@ 2A8A9A7D1BFA59F7002944B4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 2A8A9A7F1BFA59F7002944B4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 2A8A9A841BFA5AFF002944B4 /* ViewController~tv.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "ViewController~tv.xib"; sourceTree = ""; }; - 2A8A9A881BFA5B85002944B4 /* libcrypto-tvOS.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libcrypto-tvOS.a"; path = "lib/libcrypto-tvOS.a"; sourceTree = ""; }; - 2A8A9A891BFA5B85002944B4 /* libssl-tvOS.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libssl-tvOS.a"; path = "lib/libssl-tvOS.a"; sourceTree = ""; }; 533ED2FB1528C4840005C6FA /* OpenSSL.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OpenSSL.app; sourceTree = BUILT_PRODUCTS_DIR; }; 533ED2FF1528C4840005C6FA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 533ED3011528C4840005C6FA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 533ED3031528C4840005C6FA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 533ED3071528C4840005C6FA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 533ED30D1528C4840005C6FA /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; - 533ED32A1528C53B0005C6FA /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = lib/libcrypto.a; sourceTree = ""; }; - 533ED32B1528C53B0005C6FA /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = lib/libssl.a; sourceTree = ""; }; 534FB2AD180975D700B5F868 /* Icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icons.xcassets; sourceTree = ""; }; 53572A4B183AAFFE00B21832 /* OpenSSL-for-iOS_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OpenSSL-for-iOS_Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 53572A4C183AAFFE00B21832 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; @@ -79,8 +79,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2A8A9A8B1BFA5B85002944B4 /* libssl-tvOS.a in Frameworks */, - 2A8A9A8A1BFA5B85002944B4 /* libcrypto-tvOS.a in Frameworks */, + 0EA706681F817CE5001E4F88 /* libcrypto-AppleTV.a in Frameworks */, + 0EA706691F817CE5001E4F88 /* libssl-AppleTV.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -89,10 +89,10 @@ buildActionMask = 2147483647; files = ( 533ED3001528C4840005C6FA /* UIKit.framework in Frameworks */, + 0EA706661F817CCC001E4F88 /* libssl-iPhone.a in Frameworks */, 533ED3021528C4840005C6FA /* Foundation.framework in Frameworks */, 533ED3041528C4840005C6FA /* CoreGraphics.framework in Frameworks */, - 533ED32C1528C53B0005C6FA /* libcrypto.a in Frameworks */, - 533ED32D1528C53B0005C6FA /* libssl.a in Frameworks */, + 0EA706651F817CCC001E4F88 /* libcrypto-iPhone.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -144,10 +144,10 @@ 533ED2FE1528C4840005C6FA /* Frameworks */ = { isa = PBXGroup; children = ( - 2A8A9A881BFA5B85002944B4 /* libcrypto-tvOS.a */, - 2A8A9A891BFA5B85002944B4 /* libssl-tvOS.a */, - 533ED32A1528C53B0005C6FA /* libcrypto.a */, - 533ED32B1528C53B0005C6FA /* libssl.a */, + 0EA706601F817CCB001E4F88 /* libcrypto-AppleTV.a */, + 0EA706611F817CCB001E4F88 /* libcrypto-iPhone.a */, + 0EA706631F817CCC001E4F88 /* libssl-AppleTV.a */, + 0EA706621F817CCB001E4F88 /* libssl-iPhone.a */, 533ED2FF1528C4840005C6FA /* UIKit.framework */, 533ED3011528C4840005C6FA /* Foundation.framework */, 533ED3031528C4840005C6FA /* CoreGraphics.framework */, @@ -349,7 +349,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ ! -f lib/libcrypto.a ]; then\n echo \"error: Please run ./build-libssl.h first\"\n exit 1\nfi"; + shellScript = "if [ ! -f lib/libcrypto-iPhone.a ]; then\n echo \"error: Please run ./build-libssl.h first\"\n exit 1\nfi"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -428,7 +428,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.OpenSSL-for-tvOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; - SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/Bridging-Header.h"; SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; @@ -460,7 +460,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.OpenSSL-for-tvOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; - SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/Bridging-Header.h"; SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; @@ -560,6 +560,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/lib\"", + "$(PROJECT_DIR)/lib", ); PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OpenSSL; @@ -583,6 +584,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/lib\"", + "$(PROJECT_DIR)/lib", ); PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OpenSSL; diff --git a/travis-build.sh b/travis-build.sh index e6ddb6e..b420886 100755 --- a/travis-build.sh +++ b/travis-build.sh @@ -29,12 +29,12 @@ wait ${PID_TARGETS} # Verify/prepare 1.1.0 build dir xcrun -sdk iphoneos lipo -info ./lib/*.a | log_output "TARGETS" ../create-openssl-framework.sh | log_output "TARGETS" -xcrun -sdk iphoneos lipo -info openssl.framework/openssl | log_output "TARGETS" +xcrun -sdk iphoneos lipo -info frameworks/iPhone/openssl.framework/openssl | log_output "TARGETS" cp -r ../OpenSSL-for-* . # Back to main dir cd .. xcrun -sdk iphoneos lipo -info ./lib/*.a | log_output "ARCHS " ./create-openssl-framework.sh | log_output "ARCHS " -xcrun -sdk iphoneos lipo -info openssl.framework/openssl | log_output "ARCHS " +xcrun -sdk iphoneos lipo -info frameworks/iPhone/openssl.framework/openssl | log_output "ARCHS " From 0b43dc37cd9170bb43102cdc9f664abc92ac78d7 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 1 Oct 2017 21:58:45 +0200 Subject: [PATCH 06/13] Improve .dylib assembling log --- create-openssl-framework.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index 58cb9ec..0b3e7a4 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -32,7 +32,7 @@ if [ "$1" == "dynamic" ]; then ARCH="${BASH_REMATCH[4]}" fi - echo "Assembling .dylib for $ARCH" + echo "Assembling .dylib for $PLATFORM $SDKVERSION ($ARCH)" CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" From 688565ad026d2606a86e9216ca3da132a19a8977 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 1 Oct 2017 23:39:00 +0200 Subject: [PATCH 07/13] Hardcode fw Info.plist as vars spoil codesign --- assets/AppleTV/Info.plist | 31 +++++++++++++++++++++- assets/iPhone/Info.plist | 55 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 84 insertions(+), 2 deletions(-) mode change 120000 => 100644 assets/AppleTV/Info.plist mode change 120000 => 100644 assets/iPhone/Info.plist diff --git a/assets/AppleTV/Info.plist b/assets/AppleTV/Info.plist deleted file mode 120000 index 776c8e5..0000000 --- a/assets/AppleTV/Info.plist +++ /dev/null @@ -1 +0,0 @@ -../../OpenSSL-for-tvOS/Info.plist \ No newline at end of file diff --git a/assets/AppleTV/Info.plist b/assets/AppleTV/Info.plist new file mode 100644 index 0000000..37b9ac4 --- /dev/null +++ b/assets/AppleTV/Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + openssl + CFBundleIdentifier + org.openssl.OpenSSL + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + openssl + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + arm64 + + + diff --git a/assets/iPhone/Info.plist b/assets/iPhone/Info.plist deleted file mode 120000 index f3fb677..0000000 --- a/assets/iPhone/Info.plist +++ /dev/null @@ -1 +0,0 @@ -../../OpenSSL-for-iOS/Info.plist \ No newline at end of file diff --git a/assets/iPhone/Info.plist b/assets/iPhone/Info.plist new file mode 100644 index 0000000..5379f12 --- /dev/null +++ b/assets/iPhone/Info.plist @@ -0,0 +1,54 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + openssl + CFBundleExecutable + openssl + CFBundleIcons + + CFBundleIcons~ipad + + CFBundleIdentifier + org.openssl.OpenSSL + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + openssl + CFBundlePackageType + APPL + CFBundleShortVersionString + 3.1 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationExitsOnSuspend + + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarStyle + UIStatusBarStyleDefault + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + From f0af25dd74e275d9773533fd6a6bac556edf4c8c Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 10 Oct 2017 12:57:23 +0200 Subject: [PATCH 08/13] Use proper, bare Info.plist for frameworks --- assets/AppleTV/Info.plist | 12 +++--------- assets/iPhone/Info.plist | 38 ++++---------------------------------- 2 files changed, 7 insertions(+), 43 deletions(-) diff --git a/assets/AppleTV/Info.plist b/assets/AppleTV/Info.plist index 37b9ac4..897ebbb 100644 --- a/assets/AppleTV/Info.plist +++ b/assets/AppleTV/Info.plist @@ -13,18 +13,12 @@ CFBundleName openssl CFBundlePackageType - APPL + FMWK CFBundleShortVersionString 1.0 - CFBundleSignature - ???? CFBundleVersion 1 - LSRequiresIPhoneOS - - UIRequiredDeviceCapabilities - - arm64 - + MinimumOSVersion + 9.0 diff --git a/assets/iPhone/Info.plist b/assets/iPhone/Info.plist index 5379f12..246ce20 100644 --- a/assets/iPhone/Info.plist +++ b/assets/iPhone/Info.plist @@ -4,14 +4,8 @@ CFBundleDevelopmentRegion en - CFBundleDisplayName - openssl CFBundleExecutable openssl - CFBundleIcons - - CFBundleIcons~ipad - CFBundleIdentifier org.openssl.OpenSSL CFBundleInfoDictionaryVersion @@ -19,36 +13,12 @@ CFBundleName openssl CFBundlePackageType - APPL + FMWK CFBundleShortVersionString - 3.1 - CFBundleSignature - ???? + 1.0 CFBundleVersion 1 - LSRequiresIPhoneOS - - UIApplicationExitsOnSuspend - - UIRequiredDeviceCapabilities - - armv7 - - UIStatusBarStyle - UIStatusBarStyleDefault - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - + MinimumOSVersion + 8.0 From a30ce6204435bce65f99e0101904550f2f4e5fb7 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 14 Oct 2017 18:40:53 +0200 Subject: [PATCH 09/13] Use -syslibroot instead of raw -L for SDK ref --- create-openssl-framework.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index 0b3e7a4..bed9b65 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -45,7 +45,7 @@ if [ "$1" == "dynamic" ]; then fi #cd $TARGETDIR - #libtool -dynamic -lSystem $MIN_SDK -L"$SDK/usr/lib/" -install_name $INSTALL_NAME -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION lib/*.a -o $FWNAME.dylib + #libtool -dynamic -lSystem $MIN_SDK -syslibroot $SDK -install_name $INSTALL_NAME -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION lib/*.a -o $FWNAME.dylib TARGETOBJ="${TARGETDIR}/obj" rm -rf $TARGETOBJ @@ -54,7 +54,7 @@ if [ "$1" == "dynamic" ]; then ar -x ../lib/libcrypto.a ar -x ../lib/libssl.a cd .. - ld obj/*.o -dylib -lSystem -arch $ARCH $MIN_SDK -L"$SDK/usr/lib/" -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib + ld obj/*.o -dylib -lSystem -arch $ARCH $MIN_SDK -syslibroot $SDK -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib install_name_tool -id $INSTALL_NAME $FWNAME.dylib cd .. From 684c23e5656c4eceff6a03501f9ef69a5aa14968 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 17 Oct 2017 21:23:25 +0200 Subject: [PATCH 10/13] Embed Bitcode in dynamic framework, improve script https://github.com/keeshux/OpenSSL-Framework/pull/2 - Fix framework type check in check_bitcode() - Disable pipefail as it seems to stop in otool when fw is static --- create-openssl-framework.sh | 117 +++++++++++++++++++++++++----------- 1 file changed, 81 insertions(+), 36 deletions(-) diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index bed9b65..7da0b18 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -1,21 +1,50 @@ #!/bin/bash -FWNAME=openssl -FWDIR=frameworks +set -eu +#set -euxo pipefail + +if [ $# == 0 ]; then + echo "Usage: `basename $0` static|dynamic" + exit 1 +fi if [ ! -d lib ]; then echo "Please run build-libssl.sh first!" exit 1 fi -if [ -d $FWDIR ]; then +FWTYPE=$1 +FWNAME=openssl +FWROOT=frameworks + +if [ -d $FWROOT ]; then echo "Removing previous $FWNAME.framework copies" - rm -rf $FWDIR + rm -rf $FWROOT fi ALL_SYSTEMS=("iPhone" "AppleTV") +ALL_BITCODE_ARCHS=("arm64" "arm64") -if [ "$1" == "dynamic" ]; then +function check_bitcode() { + local FWDIR=$1 + local BITCODE_ARCH=$2 + + if [[ $FWTYPE == static ]]; then + BITCODE_PATTERN="__bitcode" + else + BITCODE_PATTERN="__LLVM" + fi + + if otool -arch $BITCODE_ARCH -l "$FWDIR/$FWNAME" | grep -q "${BITCODE_PATTERN}"; then + #BITCODE_MATCHES=$(otool -arch $BITCODE_ARCH -l "$FWDIR/$FWNAME" | grep -c "${BITCODE_PATTERN}") + #if [[ $BITCODE_MATCHES -gt 0 ]]; then + echo "INFO: $FWDIR contains Bitcode" + else + echo "INFO: $FWDIR doesn't contain Bitcode" + fi +} + +if [ $FWTYPE == "dynamic" ]; then DEVELOPER=`xcode-select -print-path` FW_EXEC_NAME="${FWNAME}.framework/${FWNAME}" INSTALL_NAME="@rpath/${FW_EXEC_NAME}" @@ -25,7 +54,7 @@ if [ "$1" == "dynamic" ]; then RX='([A-z]+)([0-9]+(\.[0-9]+)*)-([A-z0-9]+)\.sdk' cd bin - for TARGETDIR in `ls -d *.sdk`; do + for TARGETDIR in `ls -d *.sdk`; do if [[ $TARGETDIR =~ $RX ]]; then PLATFORM="${BASH_REMATCH[1]}" SDKVERSION="${BASH_REMATCH[2]}" @@ -38,7 +67,7 @@ if [ "$1" == "dynamic" ]; then CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" SDK="${CROSS_TOP}/SDKs/${CROSS_SDK}" - if [[ $PLATFORM == AppleTV* ]]; then + if [[ $PLATFORM == "AppleTV"* ]]; then MIN_SDK="-tvos_version_min 9.0" else MIN_SDK="-ios_version_min 8.0" @@ -54,46 +83,62 @@ if [ "$1" == "dynamic" ]; then ar -x ../lib/libcrypto.a ar -x ../lib/libssl.a cd .. - ld obj/*.o -dylib -lSystem -arch $ARCH $MIN_SDK -syslibroot $SDK -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib + + ld obj/*.o \ + -dylib \ + -bitcode_bundle \ + -lSystem \ + -arch $ARCH \ + $MIN_SDK \ + -syslibroot $SDK \ + -compatibility_version $COMPAT_VERSION \ + -current_version $CURRENT_VERSION \ + -application_extension \ + -o $FWNAME.dylib install_name_tool -id $INSTALL_NAME $FWNAME.dylib cd .. done cd .. - for SYS in ${ALL_SYSTEMS[@]}; do - SYSDIR=$FWDIR/$SYS + for SYS_IDX in ${!ALL_SYSTEMS[@]}; do + SYS=${ALL_SYSTEMS[$SYS_IDX]} + SYSDIR="$FWROOT/$SYS" + FWDIR="$SYSDIR/$FWNAME.framework" + DYLIBS=(bin/${SYS}*/$FWNAME.dylib) + BITCODE_ARCH=${ALL_BITCODE_ARCHS[$SYS_IDX]} - # FIXME: skip if no device objects - - echo "Creating framework for $SYS" - mkdir -p $SYSDIR/$FWNAME.framework/Headers - lipo -create bin/${SYS}*/$FWNAME.dylib -output $SYSDIR/$FWNAME.framework/$FWNAME - cp -r include/$FWNAME/* $SYSDIR/$FWNAME.framework/Headers/ - cp -L assets/$SYS/Info.plist $SYSDIR/$FWNAME.framework/Info.plist - echo "Created $SYSDIR/$FWNAME.framework" + if [[ ${#DYLIBS[@]} -gt 0 && -e ${DYLIBS[0]} ]]; then + echo "Creating framework for $SYS" + mkdir -p $FWDIR/Headers + lipo -create ${DYLIBS[@]} -output $FWDIR/$FWNAME + cp -r include/$FWNAME/* $FWDIR/Headers/ + cp -L assets/$SYS/Info.plist $FWDIR/Info.plist + echo "Created $FWDIR" + check_bitcode $FWDIR $BITCODE_ARCH + else + echo "Skipped framework for $SYS" + fi done rm bin/*/$FWNAME.dylib else - for SYS in ${ALL_SYSTEMS[@]}; do - SYSDIR=$FWDIR/$SYS + for SYS_IDX in ${!ALL_SYSTEMS[@]}; do + SYS=${ALL_SYSTEMS[$SYS_IDX]} + SYSDIR="$FWROOT/$SYS" + FWDIR="$SYSDIR/$FWNAME.framework" + BITCODE_ARCH=${ALL_BITCODE_ARCHS[$SYS_IDX]} - # FIXME: skip if no device objects - - echo "Creating framework for $SYS" - mkdir -p $SYSDIR/$FWNAME.framework/Headers - libtool -static -o $SYSDIR/$FWNAME.framework/$FWNAME lib/libcrypto-$SYS.a lib/libssl-$SYS.a - cp -r include/$FWNAME/* $SYSDIR/$FWNAME.framework/Headers/ - cp -L assets/$SYS/Info.plist $SYSDIR/$FWNAME.framework/Info.plist - echo "Created $SYSDIR/$FWNAME.framework" + if [[ -e lib/libcrypto-$SYS.a && -e lib/libssl-$SYS.a ]]; then + echo "Creating framework for $SYS" + mkdir -p $FWDIR/Headers + libtool -static -o $FWDIR/$FWNAME lib/libcrypto-$SYS.a lib/libssl-$SYS.a + cp -r include/$FWNAME/* $FWDIR/Headers/ + cp -L assets/$SYS/Info.plist $FWDIR/Info.plist + echo "Created $FWDIR" + check_bitcode $FWDIR $BITCODE_ARCH + else + echo "Skipped framework for $SYS" + fi done fi - -check_bitcode=`otool -arch arm64 -l $FWDIR/iPhone/$FWNAME.framework/$FWNAME | grep __bitcode` -if [ -z "$check_bitcode" ] -then - echo "INFO: $FWNAME.framework doesn't contain Bitcode" -else - echo "INFO: $FWNAME.framework contains Bitcode" -fi From 8fd9082487be4607aa9b272f2175b4778037d5de Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Wed, 18 Oct 2017 09:12:55 +0200 Subject: [PATCH 11/13] Remove redundant -arch from Bitcode check --- create-openssl-framework.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index 7da0b18..2b88ed7 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -23,11 +23,9 @@ if [ -d $FWROOT ]; then fi ALL_SYSTEMS=("iPhone" "AppleTV") -ALL_BITCODE_ARCHS=("arm64" "arm64") function check_bitcode() { local FWDIR=$1 - local BITCODE_ARCH=$2 if [[ $FWTYPE == static ]]; then BITCODE_PATTERN="__bitcode" @@ -35,8 +33,8 @@ function check_bitcode() { BITCODE_PATTERN="__LLVM" fi - if otool -arch $BITCODE_ARCH -l "$FWDIR/$FWNAME" | grep -q "${BITCODE_PATTERN}"; then - #BITCODE_MATCHES=$(otool -arch $BITCODE_ARCH -l "$FWDIR/$FWNAME" | grep -c "${BITCODE_PATTERN}") + if otool -l "$FWDIR/$FWNAME" | grep -q "${BITCODE_PATTERN}"; then + #BITCODE_MATCHES=$(otool -l "$FWDIR/$FWNAME" | grep -c "${BITCODE_PATTERN}") #if [[ $BITCODE_MATCHES -gt 0 ]]; then echo "INFO: $FWDIR contains Bitcode" else @@ -101,12 +99,10 @@ if [ $FWTYPE == "dynamic" ]; then done cd .. - for SYS_IDX in ${!ALL_SYSTEMS[@]}; do - SYS=${ALL_SYSTEMS[$SYS_IDX]} + for SYS in ${ALL_SYSTEMS[@]}; do SYSDIR="$FWROOT/$SYS" FWDIR="$SYSDIR/$FWNAME.framework" DYLIBS=(bin/${SYS}*/$FWNAME.dylib) - BITCODE_ARCH=${ALL_BITCODE_ARCHS[$SYS_IDX]} if [[ ${#DYLIBS[@]} -gt 0 && -e ${DYLIBS[0]} ]]; then echo "Creating framework for $SYS" @@ -115,7 +111,7 @@ if [ $FWTYPE == "dynamic" ]; then cp -r include/$FWNAME/* $FWDIR/Headers/ cp -L assets/$SYS/Info.plist $FWDIR/Info.plist echo "Created $FWDIR" - check_bitcode $FWDIR $BITCODE_ARCH + check_bitcode $FWDIR else echo "Skipped framework for $SYS" fi @@ -123,11 +119,9 @@ if [ $FWTYPE == "dynamic" ]; then rm bin/*/$FWNAME.dylib else - for SYS_IDX in ${!ALL_SYSTEMS[@]}; do - SYS=${ALL_SYSTEMS[$SYS_IDX]} + for SYS in ${ALL_SYSTEMS[@]}; do SYSDIR="$FWROOT/$SYS" FWDIR="$SYSDIR/$FWNAME.framework" - BITCODE_ARCH=${ALL_BITCODE_ARCHS[$SYS_IDX]} if [[ -e lib/libcrypto-$SYS.a && -e lib/libssl-$SYS.a ]]; then echo "Creating framework for $SYS" @@ -136,7 +130,7 @@ else cp -r include/$FWNAME/* $FWDIR/Headers/ cp -L assets/$SYS/Info.plist $FWDIR/Info.plist echo "Created $FWDIR" - check_bitcode $FWDIR $BITCODE_ARCH + check_bitcode $FWDIR else echo "Skipped framework for $SYS" fi From 15d5c28c08265b99751eec105a44f0e696963a26 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Wed, 18 Oct 2017 09:17:35 +0200 Subject: [PATCH 12/13] Restore pipefail by replacing grep -q Tip by @nicph --- create-openssl-framework.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index 2b88ed7..6574d16 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -1,7 +1,6 @@ #!/bin/bash -set -eu -#set -euxo pipefail +set -euo pipefail if [ $# == 0 ]; then echo "Usage: `basename $0` static|dynamic" @@ -33,9 +32,7 @@ function check_bitcode() { BITCODE_PATTERN="__LLVM" fi - if otool -l "$FWDIR/$FWNAME" | grep -q "${BITCODE_PATTERN}"; then - #BITCODE_MATCHES=$(otool -l "$FWDIR/$FWNAME" | grep -c "${BITCODE_PATTERN}") - #if [[ $BITCODE_MATCHES -gt 0 ]]; then + if otool -l "$FWDIR/$FWNAME" | grep "${BITCODE_PATTERN}" >/dev/null; then echo "INFO: $FWDIR contains Bitcode" else echo "INFO: $FWDIR doesn't contain Bitcode" From ba666f250783fd0298da25af9042f1f29bddb092 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Wed, 18 Oct 2017 09:20:26 +0200 Subject: [PATCH 13/13] Use same condition order --- create-openssl-framework.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index 6574d16..a637761 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -26,10 +26,10 @@ ALL_SYSTEMS=("iPhone" "AppleTV") function check_bitcode() { local FWDIR=$1 - if [[ $FWTYPE == static ]]; then - BITCODE_PATTERN="__bitcode" - else + if [[ $FWTYPE == "dynamic" ]]; then BITCODE_PATTERN="__LLVM" + else + BITCODE_PATTERN="__bitcode" fi if otool -l "$FWDIR/$FWNAME" | grep "${BITCODE_PATTERN}" >/dev/null; then