Skip to content

Commit bfa0bdb

Browse files
committed
update versions
1 parent c968b81 commit bfa0bdb

File tree

4 files changed

+113
-12
lines changed

4 files changed

+113
-12
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## OpenSSL for iOS and Mac OS X (Intel & Apple Silicon M1) & Catalyst - arm64 / x86_64
1+
## OpenSSL for iOS, visionOS, macOS (Intel & Apple Silicon M1) & Catalyst - arm64 / x86_64
22

33
Supported 3.2.X versions: 3.2.1, 3.2.0
44

@@ -11,13 +11,14 @@ Supported 1.1.1X versions: 1.1.1w, 1.1.1v, 1.1.1u, 1.1.1t, 1.1.1s, 1.1.1q, 1.1.1
1111

1212
Use the appropriate tag or branch to choose a version.
1313

14-
This repository provides a universal script for building static OpenSSL libraries for use in iOS and macOS applications.
15-
The actual library version is taken from https://github.com/openssl/openssl with an appropriate tag like 'OpenSSL_1_1_1t' or 'openssl-3.1.0'
14+
This repository provides a universal script for building static OpenSSL libraries for use in iOS, visionOS, and macOS & Catalyst applications.
15+
The actual library version is taken from https://github.com/openssl/openssl with an appropriate tag like 'OpenSSL_1_1_1w' or 'openssl-3.2.1'
1616

1717
## Prerequisites
1818
1) Xcode must be installed because xcodebuild is used to create xcframeworks
1919
2) ```xcode-select -p``` must point to Xcode app developer directory (by default e.g. /Applications/Xcode.app/Contents/Developer). If it points to CommandLineTools directory you should execute:
2020
```sudo xcode-select --reset``` or ```sudo xcode-select -s /Applications/Xcode.app/Contents/Developer```
21+
3) For the creation of visionOS related artifacts and their integration into the resulting xcframeworks, XROS.platform and XRSimulator.platform should be available in the folder: /Applications/Xcode.app/Contents/Developer/Platforms
2122

2223
## How to build?
2324
- Manually

openssl-iosx.podspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
Pod::Spec.new do |s|
22
s.name = "openssl-iosx"
33
s.version = "3.2.1.0"
4-
s.summary = "OpenSSL"
4+
s.summary = "OpenSSL libraries for macOS, iOS, and visionOS, including both arm64 and x86_64 builds for macOS, Mac Catalyst, iOS Simulator, and visionOS Simulator."
55
s.homepage = "https://github.com/apotocki/openssl-iosx"
66
s.license = "Apache"
77
s.author = { "Alexander Pototskiy" => "alex.a.potocki@gmail.com" }
88
s.social_media_url = "https://www.linkedin.com/in/alexander-pototskiy"
99
s.osx.deployment_target = "11.0"
1010
s.ios.deployment_target = "13.4"
11+
s.visionos.deployment_target = "1.0"
1112
s.osx.pod_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
1213
s.ios.pod_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
14+
s.visionos.pod_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
1315
s.static_framework = true
1416
s.prepare_command = "sh scripts/build.sh"
1517
s.source = { :git => "https://github.com/apotocki/openssl-iosx.git", :tag => "#{s.version}" }

scripts/15-ios.conf.patch

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@@ -32,6 +32,23 @@
2+
inherit_from => [ "ios-common" ],
3+
CC => "xcrun -sdk iphonesimulator cc",
4+
},
5+
+ "xros-common" => {
6+
+ template => 1,
7+
+ inherit_from => [ "darwin-common" ],
8+
+ sys_id => "visionOS",
9+
+ disable => [ "engine", "async" ],
10+
+ },
11+
+ "xros-xcrun" => {
12+
+ inherit_from => [ "xros-common", asm("aarch64_asm") ],
13+
+ CC => "xcrun -sdk xros cc",
14+
+ cflags => add("-arch arm64 -fno-common"),
15+
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
16+
+ perlasm_scheme => "ios64",
17+
+ },
18+
+ "xrossimulator-xcrun" => {
19+
+ inherit_from => [ "xros-common" ],
20+
+ CC => "xcrun -sdk xrsimulator cc",
21+
+ },
22+
# It takes three prior-set environment variables to make it work:
23+
#
24+
# CROSS_COMPILE=/where/toolchain/is/usr/bin/ [note ending slash]

scripts/build.sh

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,28 @@ THREAD_COUNT=$(sysctl hw.ncpu | awk '{print $2}')
66
HOST_ARC=$( uname -m )
77
XCODE_ROOT=$( xcode-select -print-path )
88
OPENSSL_VER=openssl-3.2.1
9+
#MACOSX_VERSION_ARM=12.3
10+
#MACOSX_VERSION_X86_64=10.13
911
################## SETUP END
10-
#DEVSYSROOT=$XCODE_ROOT/Platforms/iPhoneOS.platform/Developer
11-
#SIMSYSROOT=$XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer
12+
#IOSSYSROOT=$XCODE_ROOT/Platforms/iPhoneOS.platform/Developer
13+
#IOSSIMSYSROOT=$XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer
1214
MACSYSROOT=$XCODE_ROOT/Platforms/MacOSX.platform/Developer
15+
XROSSYSROOT=$XCODE_ROOT/Platforms/XROS.platform/Developer
16+
XROSSIMSYSROOT=$XCODE_ROOT/Platforms/XRSimulator.platform/Developer
17+
1318
BUILD_DIR="$( cd "$( dirname "./" )" >/dev/null 2>&1 && pwd )"
19+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1420

1521
if [ "$HOST_ARC" = "arm64" ]; then
1622
FOREIGN_ARC=x86_64
23+
FOREIGN_BUILD_FLAGS="" && [ ! -z "${MACOSX_VERSION_X86_64}" ] && FOREIGN_BUILD_FLAGS="-mmacosx-version-min=$MACOSX_VERSION_X86_64"
24+
NATIVE_BUILD_FLAGS="" && [ ! -z "${MACOSX_VERSION_ARM}" ] && NATIVE_BUILD_FLAGS="-mmacosx-version-min=$MACOSX_VERSION_ARM"
1725
else
1826
FOREIGN_ARC=arm64
27+
FOREIGN_BUILD_FLAGS="" && [ ! -z "${MACOSX_VERSION_ARM}" ] && FOREIGN_BUILD_FLAGS="-mmacosx-version-min=$MACOSX_VERSION_ARM"
28+
NATIVE_BUILD_FLAGS="" && [ ! -z "${MACOSX_VERSION_X86_64}" ] && NATIVE_BUILD_FLAGS="-mmacosx-version-min=$MACOSX_VERSION_X86_64"
1929
fi
20-
30+
FOREIGN_BUILD_FLAGS="-arch $FOREIGN_ARC $FOREIGN_BUILD_FLAGS"
2131

2232
if [[ ! -d $BUILD_DIR/frameworks ]]; then
2333

@@ -28,6 +38,14 @@ fi
2838

2939
pushd $OPENSSL_VER
3040

41+
echo patching openssl...
42+
if [ ! -f Configurations/15-ios.conf.orig ]; then
43+
cp -f Configurations/15-ios.conf Configurations/15-ios.conf.orig
44+
else
45+
cp -f Configurations/15-ios.conf.orig Configurations/15-ios.conf
46+
fi
47+
patch Configurations/15-ios.conf $SCRIPT_DIR/15-ios.conf.patch
48+
3149
function arc()
3250
{
3351
if [[ $1 == arm* ]]; then
@@ -43,7 +61,6 @@ build_catalyst_libs()
4361
{
4462
if [[ ! -d $BUILD_DIR/build/lib.catalyst-$1 ]]; then
4563
./Configure --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$1-cc --target=$(arc $1)-apple-ios13.4-macabi -isysroot $MACSYSROOT/SDKs/MacOSX.sdk
46-
# -I$MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/usr/include/ -isystem $MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/usr/include -iframework $MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/System/Library/Frameworks
4764
make clean
4865
make -j$THREAD_COUNT
4966

@@ -68,6 +85,20 @@ build_sim_libs()
6885
fi
6986
}
7087

88+
build_xrossim_libs()
89+
{
90+
if [[ ! -d $BUILD_DIR/build/lib.xrossim-$1 ]]; then
91+
./Configure --openssldir="$BUILD_DIR/build/ssl" no-shared xrossimulator-xcrun CFLAGS="-arch $1"
92+
make clean
93+
make -j$THREAD_COUNT
94+
95+
mkdir $BUILD_DIR/build/lib.xrossim-$1
96+
cp libssl.a $BUILD_DIR/build/lib.xrossim-$1/
97+
cp libcrypto.a $BUILD_DIR/build/lib.xrossim-$1/
98+
make clean
99+
fi
100+
}
101+
71102
build_ios_libs()
72103
{
73104
if [[ ! -d $BUILD_DIR/build/lib.ios ]]; then
@@ -82,15 +113,29 @@ build_ios_libs()
82113
fi
83114
}
84115

116+
build_xros_libs()
117+
{
118+
if [[ ! -d $BUILD_DIR/build/lib.xros ]]; then
119+
./Configure --openssldir="$BUILD_DIR/build/ssl" no-shared no-dso no-hw no-engine xros-xcrun -fembed-bitcode
120+
make clean
121+
make -j$THREAD_COUNT
122+
123+
mkdir $BUILD_DIR/build/lib.xros
124+
cp libssl.a $BUILD_DIR/build/lib.xros/
125+
cp libcrypto.a $BUILD_DIR/build/lib.xros/
126+
make clean
127+
fi
128+
}
129+
85130
if [[ ! -d $BUILD_DIR/build/lib ]]; then
86-
./Configure --prefix="$BUILD_DIR/build" --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$HOST_ARC-cc
131+
./Configure --prefix="$BUILD_DIR/build" --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$HOST_ARC-cc CFLAGS="$NATIVE_BUILD_FLAGS"
87132
make clean
88133
make -j$THREAD_COUNT
89134
make install
90135
make clean
91136
fi
92137
if [[ ! -d $BUILD_DIR/build/lib.macos ]]; then
93-
./Configure --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$FOREIGN_ARC-cc CFLAGS="-arch $FOREIGN_ARC"
138+
./Configure --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$FOREIGN_ARC-cc CFLAGS="$FOREIGN_BUILD_FLAGS"
94139
make clean
95140
make -j$THREAD_COUNT
96141

@@ -117,14 +162,43 @@ if [[ ! -d $BUILD_DIR/build/lib.iossim ]]; then
117162
lipo -create $BUILD_DIR/build/lib.iossim-x86_64/libcrypto.a $BUILD_DIR/build/lib.iossim-arm64/libcrypto.a -output $BUILD_DIR/build/lib.iossim/libcrypto.a
118163
fi
119164

165+
if [ -d $XROSSIMSYSROOT/SDKs/XRSimulator.sdk ]; then
166+
if [[ ! -d $BUILD_DIR/build/lib.xrossim ]]; then
167+
build_xrossim_libs arm64
168+
build_xrossim_libs x86_64
169+
mkdir $BUILD_DIR/build/lib.xrossim
170+
lipo -create $BUILD_DIR/build/lib.xrossim-x86_64/libssl.a $BUILD_DIR/build/lib.xrossim-arm64/libssl.a -output $BUILD_DIR/build/lib.xrossim/libssl.a
171+
lipo -create $BUILD_DIR/build/lib.xrossim-x86_64/libcrypto.a $BUILD_DIR/build/lib.xrossim-arm64/libcrypto.a -output $BUILD_DIR/build/lib.xrossim/libcrypto.a
172+
fi
173+
fi
174+
120175
build_ios_libs
176+
if [ -d $XROSSYSROOT ]; then
177+
build_xros_libs
178+
fi
121179

122180
mkdir $BUILD_DIR/frameworks
123181

124182
cp -R $BUILD_DIR/build/include $BUILD_DIR/frameworks/Headers
125183

126-
xcodebuild -create-xcframework -library $BUILD_DIR/build/lib.macos/libssl.a -library $BUILD_DIR/build/lib.catalyst/libssl.a -library $BUILD_DIR/build/lib.iossim/libssl.a -library $BUILD_DIR/build/lib.ios/libssl.a -output $BUILD_DIR/frameworks/ssl.xcframework
127-
xcodebuild -create-xcframework -library $BUILD_DIR/build/lib.macos/libcrypto.a -library $BUILD_DIR/build/lib.catalyst/libcrypto.a -library $BUILD_DIR/build/lib.iossim/libcrypto.a -library $BUILD_DIR/build/lib.ios/libcrypto.a -output $BUILD_DIR/frameworks/crypto.xcframework
184+
create_xcframework()
185+
{
186+
LIBARGS="-library $BUILD_DIR/build/lib.macos/lib$1.a \
187+
-library $BUILD_DIR/build/lib.catalyst/lib$1.a \
188+
-library $BUILD_DIR/build/lib.iossim/lib$1.a \
189+
-library $BUILD_DIR/build/lib.ios/lib$1.a"
190+
191+
if [ -d $XROSSIMSYSROOT/SDKs/XRSimulator.sdk ]; then
192+
LIBARGS="$LIBARGS -library $BUILD_DIR/build/lib.xrossim/lib$1.a"
193+
fi
194+
if [ -d $XROSSYSROOT/SDKs/XROS.sdk ]; then
195+
LIBARGS="$LIBARGS -library $BUILD_DIR/build/lib.xros/lib$1.a"
196+
fi
197+
xcodebuild -create-xcframework $LIBARGS -output "$BUILD_DIR/frameworks/$1.xcframework"
198+
}
199+
200+
create_xcframework ssl
201+
create_xcframework crypto
128202

129203
popd
130204

0 commit comments

Comments
 (0)