From 3f826877c12531578a1fe885cbab572a36358b4a Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 13 Nov 2020 23:46:49 +0100 Subject: [PATCH 1/5] Skip lipo -create for static libs Can't merge same arch for multiple platforms (e.g. iPhone Simulator arm64 and iOS arm64). Also not needed for frameworks creation, which is the primary goal of the scripts. --- build-libssl.sh | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/build-libssl.sh b/build-libssl.sh index 183f9fd..9422b4a 100755 --- a/build-libssl.sh +++ b/build-libssl.sh @@ -525,41 +525,6 @@ LIBCRYPTO_TVOS=() source "${SCRIPTDIR}/scripts/build-loop-targets.sh" -# 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-iPhone.a" - lipo -create ${LIBCRYPTO_IOS[@]} -output "${CURRENTPATH}/lib/libcrypto-iPhone.a" -fi - -#Build macOS library if selected for build -if [ ${#LIBSSL_MACOS[@]} -gt 0 ]; then - echo "Build library for macOS..." - lipo -create ${LIBSSL_MACOS[@]} -output "${CURRENTPATH}/lib/libssl-MacOSX.a" - lipo -create ${LIBCRYPTO_MACOS[@]} -output "${CURRENTPATH}/lib/libcrypto-MacOSX.a" -fi - -#Build Catalyst library if selected for build -if [ ${#LIBSSL_CATALYST[@]} -gt 0 ]; then - echo "Build library for Catalyst..." - lipo -create ${LIBSSL_CATALYST[@]} -output "${CURRENTPATH}/lib/libssl-Catalyst.a" - lipo -create ${LIBCRYPTO_CATALYST[@]} -output "${CURRENTPATH}/lib/libcrypto-Catalyst.a" -fi - -# Build tvOS library if selected for build -if [ ${#LIBSSL_WATCHOS[@]} -gt 0 ]; then - echo "Build library for watchOS..." - lipo -create ${LIBSSL_WATCHOS[@]} -output "${CURRENTPATH}/lib/libssl-Watch.a" - lipo -create ${LIBCRYPTO_WATCHOS[@]} -output "${CURRENTPATH}/lib/libcrypto-Watch.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-AppleTV.a" - lipo -create ${LIBCRYPTO_TVOS[@]} -output "${CURRENTPATH}/lib/libcrypto-AppleTV.a" -fi - # Copy include directory cp -R "${INCLUDE_DIR}" "${CURRENTPATH}/include/" From 0c61811aedcae2f946a36259d1570d49b604dcf0 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 14 Nov 2020 15:07:43 +0100 Subject: [PATCH 2/5] Produce XCFramework from per-platform frameworks 1. Produce one framework per platform 2. Merge archs (lipo) into same platform framework 3. Assemble fat frameworks into XCFramework For more information: - https://github.com/balthisar/openssl-xcframeworks - https://developer.apple.com/forums/thread/666335 --- .gitignore | 1 + assets/AppleTVOS | 1 + assets/AppleTVSimulator | 1 + assets/WatchOS | 1 + assets/WatchSimulator | 1 + assets/iPhoneOS | 1 + assets/iPhoneSimulator | 1 + create-openssl-framework.sh | 31 ++++++++++++++++++++++++++++--- 8 files changed, 35 insertions(+), 3 deletions(-) create mode 120000 assets/AppleTVOS create mode 120000 assets/AppleTVSimulator create mode 120000 assets/WatchOS create mode 120000 assets/WatchSimulator create mode 120000 assets/iPhoneOS create mode 120000 assets/iPhoneSimulator diff --git a/.gitignore b/.gitignore index ab0744a..ed43e38 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ bin src lib +frameworks include/openssl *.gz *.framework diff --git a/assets/AppleTVOS b/assets/AppleTVOS new file mode 120000 index 0000000..f7173f1 --- /dev/null +++ b/assets/AppleTVOS @@ -0,0 +1 @@ +AppleTV \ No newline at end of file diff --git a/assets/AppleTVSimulator b/assets/AppleTVSimulator new file mode 120000 index 0000000..f7173f1 --- /dev/null +++ b/assets/AppleTVSimulator @@ -0,0 +1 @@ +AppleTV \ No newline at end of file diff --git a/assets/WatchOS b/assets/WatchOS new file mode 120000 index 0000000..8d43823 --- /dev/null +++ b/assets/WatchOS @@ -0,0 +1 @@ +Watch \ No newline at end of file diff --git a/assets/WatchSimulator b/assets/WatchSimulator new file mode 120000 index 0000000..8d43823 --- /dev/null +++ b/assets/WatchSimulator @@ -0,0 +1 @@ +Watch \ No newline at end of file diff --git a/assets/iPhoneOS b/assets/iPhoneOS new file mode 120000 index 0000000..9856d0d --- /dev/null +++ b/assets/iPhoneOS @@ -0,0 +1 @@ +iPhone \ No newline at end of file diff --git a/assets/iPhoneSimulator b/assets/iPhoneSimulator new file mode 120000 index 0000000..9856d0d --- /dev/null +++ b/assets/iPhoneSimulator @@ -0,0 +1 @@ +iPhone \ No newline at end of file diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index ecdaa82..c053af7 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -21,7 +21,8 @@ if [ -d $FWROOT ]; then rm -rf $FWROOT fi -ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX" "Catalyst" "Watch") +#ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX" "Catalyst" "Watch") +ALL_SYSTEMS=("iPhoneOS" "iPhoneSimulator" "AppleTVOS" "AppleTVSimulator" "MacOSX" "Catalyst" "WatchOS" "WatchSimulator") function check_bitcode() { local FWDIR=$1 @@ -212,11 +213,17 @@ else for SYS in ${ALL_SYSTEMS[@]}; do SYSDIR="$FWROOT/$SYS" FWDIR="$SYSDIR/$FWNAME.framework" + LIBS_CRYPTO=(bin/${SYS}*/lib/libcrypto.a) + LIBS_SSL=(bin/${SYS}*/lib/libssl.a) - if [[ -e lib/libcrypto-$SYS.a && -e lib/libssl-$SYS.a ]]; then + if [[ ${#LIBS_CRYPTO[@]} -gt 0 && -e ${LIBS_CRYPTO[0]} && ${#LIBS_SSL[@]} -gt 0 && -e ${LIBS_SSL[0]} ]]; then echo "Creating framework for $SYS" + mkdir -p $FWDIR/lib + lipo -create ${LIBS_CRYPTO[@]} -output $FWDIR/lib/libcrypto.a + lipo -create ${LIBS_SSL[@]} -output $FWDIR/lib/libssl.a + libtool -static -o $FWDIR/$FWNAME $FWDIR/lib/*.a + rm -rf $FWDIR/lib 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 MIN_SDK_VERSION=$(get_min_sdk "$FWDIR/$FWNAME") @@ -252,5 +259,23 @@ for SYS in ${ALL_SYSTEMS[@]}; do ln -s "Versions/Current/openssl" ln -s "Versions/Current/Headers" ln -s "Versions/Current/Resources" + + cd ../../.. fi done + +build_xcframework() { + local FRAMEWORKS=($FWROOT/*/$FWNAME.framework) + local ARGS= + for ARG in ${FRAMEWORKS[@]}; do + ARGS+="-framework ${ARG} " + done + + echo + xcodebuild -create-xcframework $ARGS -output "$FWROOT/$FWNAME.xcframework" + + # These intermediate frameworks are silly, and not needed any more. + #find ${FWROOT} -mindepth 1 -maxdepth 1 -type d -not -name "$FWNAME.xcframework" -exec rm -rf '{}' \; +} + +build_xcframework From 519ec9de7c1dc0a8526b2921ee6d9fe8b07bd3ce Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 14 Nov 2020 15:46:28 +0100 Subject: [PATCH 3/5] Update podspec to use XCFramework Drop redundant template. --- OpenSSL-Apple.podspec | 9 +++------ OpenSSL-Apple.podspec.template | 27 --------------------------- 2 files changed, 3 insertions(+), 33 deletions(-) delete mode 100755 OpenSSL-Apple.podspec.template diff --git a/OpenSSL-Apple.podspec b/OpenSSL-Apple.podspec index 40c32b8..f479379 100755 --- a/OpenSSL-Apple.podspec +++ b/OpenSSL-Apple.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| openssl_version = "1.1.1h" - openssl_targets = "ios-sim-cross-x86_64 ios64-cross-arm64 ios64-cross-arm64e macos64-x86_64 macos64-arm64 mac-catalyst-arm64" - script_version = "7" + openssl_targets = "ios-sim-cross-x86_64 ios-sim-cross-arm64 ios64-cross-arm64 ios64-cross-arm64e macos64-x86_64 macos64-arm64 mac-catalyst-x86_64 mac-catalyst-arm64" + script_version = "8" s.name = "OpenSSL-Apple" s.version = "#{openssl_version}.#{script_version}" @@ -18,10 +18,7 @@ Pod::Spec.new do |s| CMD s.ios.deployment_target = "12.0" - s.ios.vendored_frameworks = "frameworks/iPhone/openssl.framework" - s.ios.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } - s.ios.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } s.osx.deployment_target = "10.15" - s.osx.vendored_frameworks = "frameworks/MacOSX/openssl.framework" + s.vendored_frameworks = "frameworks/openssl.xcframework" s.requires_arc = false end diff --git a/OpenSSL-Apple.podspec.template b/OpenSSL-Apple.podspec.template deleted file mode 100755 index d4ea145..0000000 --- a/OpenSSL-Apple.podspec.template +++ /dev/null @@ -1,27 +0,0 @@ -Pod::Spec.new do |s| - openssl_version = "%OPENSSL-VERSION%" - openssl_targets = "ios-sim-cross-x86_64 ios64-cross-arm64 ios64-cross-arm64e macos64-x86_64 macos64-arm64 mac-catalyst-arm64" - script_version = "7" - - s.name = "OpenSSL-Apple" - s.version = "#{openssl_version}.#{script_version}" - s.summary = "A script for compiling OpenSSL for Apple Devices" - s.authors = "Felix Schulze", "Davide De Rosa", "Ezat Hashim" - - s.homepage = "https://github.com/keeshux/openssl-apple.git" - s.source = { :git => s.homepage.to_s, :tag => "v#{script_version}" } - s.license = { :type => 'Apache', :file => 'LICENSE' } - - s.prepare_command = <<-CMD -./build-libssl.sh --version="#{openssl_version}" --targets="#{openssl_targets}" -./create-openssl-framework.sh dynamic - CMD - - s.ios.deployment_target = "12.0" - s.ios.vendored_frameworks = "frameworks/iPhone/openssl.framework" - s.ios.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } - s.ios.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } - s.osx.deployment_target = "10.15" - s.osx.vendored_frameworks = "frameworks/MacOSX/openssl.framework" - s.requires_arc = false -end From 8ed4b35737613c286ef24f417579c2f958bb785a Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 14 Nov 2020 17:54:34 +0100 Subject: [PATCH 4/5] Update Demo with XCFramework --- Demo.xcodeproj/project.pbxproj | 18 ++++++++++++++++++ Podfile.lock | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Demo.xcodeproj/project.pbxproj b/Demo.xcodeproj/project.pbxproj index 63b5ce2..69727f1 100644 --- a/Demo.xcodeproj/project.pbxproj +++ b/Demo.xcodeproj/project.pbxproj @@ -134,6 +134,7 @@ 0EF4C83B254B2DDE0030F3CE /* Sources */, 0EF4C83C254B2DDE0030F3CE /* Frameworks */, 0EF4C83D254B2DDE0030F3CE /* Resources */, + 5E422EBA5A955FA396AE01A7 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -220,6 +221,23 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 5E422EBA5A955FA396AE01A7 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Demo/Pods-Demo-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Demo/Pods-Demo-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Demo/Pods-Demo-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; E779C03A2743FDC34CB79861 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/Podfile.lock b/Podfile.lock index 2bf0c72..9b5a34f 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - OpenSSL-Apple (1.1.1h.7) + - OpenSSL-Apple (1.1.1h.8) DEPENDENCIES: - OpenSSL-Apple (from `.`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: "." SPEC CHECKSUMS: - OpenSSL-Apple: ea3144c521f4d5f620bc911686ddc42f48ae17d8 + OpenSSL-Apple: 70990157548ecf94885310231aff52db698e1077 PODFILE CHECKSUM: 46de088b71467a12879d73c36eda858ad56ed167 From 9c4458af56f6c1191edb24e5e12ac9d01b48f69f Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 15 Nov 2020 19:14:10 +0100 Subject: [PATCH 5/5] Raise CI timeout further --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a66bac4..5e73050 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,4 +12,4 @@ branches: install: - bundle install --jobs=3 --deployment --path=${BUNDLE_PATH:-vendor/bundle} - bundle exec pod repo update - - travis_wait 30 bundle exec pod install + - travis_wait 40 bundle exec pod install