Skip to content

Commit 792f813

Browse files
authored
Merge pull request #7836 from bigbrett/apple-universal-readme-curl-instructions
apple-universal README update: add curl instructions
2 parents b26c34c + 573ade3 commit 792f813

1 file changed

Lines changed: 42 additions & 3 deletions

File tree

IDE/apple-universal/README.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This example shows how to build a wolfSSL static library for Apple targets on al
44
The example was created using Xcode version 14.3.1.
55

66
# Why?
7-
Configuring and building wolfSSL through the `configure` interface can be simpler and more user friendly than manually adding the wolfSSL source files to your project and customizing through `user_settings.h`. Building via `configure` also streamlines integration with other open-source projects that expect an installation directory, such as `cURL`'s `--with-wolfssl` option. Finally, some developer teams might prefer to build wolfSSL once with the desired settings and then distribute it as a library framework for app developers to use. Packaging wolfSSL as a framework makes it highly portable and allows for drag-and-drop integration into Xcode projects without needing to worry about compiling the library every time they build their app.
7+
Configuring and building wolfSSL through the `configure` interface can be simpler and more user friendly than manually adding the wolfSSL source files to your project and customizing through `user_settings.h`. Building via `configure` also streamlines integration with other open-source projects that expect an installation directory, such as `curl`'s `--with-wolfssl` option. Finally, some developer teams might prefer to build wolfSSL once with the desired settings and then distribute it as a library framework for app developers to use. Packaging wolfSSL as a framework makes it highly portable and allows for drag-and-drop integration into Xcode projects without needing to worry about compiling the library every time they build their app.
88

99
However, if you do want to compile wolfSSL from source manually in your Xcode project using `user_settings.h`, see the example in [IDE/XCODE](https://github.com/wolfSSL/wolfssl/tree/master/IDE/XCODE).
1010

@@ -16,7 +16,7 @@ This example consists of a build script and an Xcode example project. The build
1616

1717
To use the build script, you can run it without arguments to build a default configuration, or you can use the `-c` option to pass in a quoted string containing any additional flags to `configure` that you need. Note that `--enable-static --disable-shared` is always passed to `configure` by default. Consider the following usage example, with descriptions in the comments:
1818

19-
```
19+
```sh
2020
# default configuration
2121
./build-wolfssl-framework.sh
2222

@@ -60,7 +60,7 @@ If you are developing on a macOS machine and want to compile wolfSSL to run on m
6060

6161
The generic `configure` invocation required to cross compile a static library for an Apple device is as follows:
6262

63-
```
63+
```sh
6464
./configure --disable-shared --enable-static \
6565
--prefix=${INSTALL_DIR} \
6666
--host=${HOST} \
@@ -89,4 +89,43 @@ Low-level programming in the Apple ecosystem is sparsely documented, and certain
8989

9090
2. Cross compiling for the **iOS simulator** with a min version specifier present (`-miphoneos-version-min`) requires the `-target ${ARCH}-apple-ios-simulator` compiler flag in order to build . It is unclear why this is required, as The GNU documentation claims that the `target` option is only required if cross-compiling a compiler to run on architecture X but emit code for architecture Y (known as a canadian cross-compilation scenario). Regardless, if you do not include a `-target` option, the build will generate a large number of warnings when linking against system libraries with messages like: `ld: warning: building for iOS, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk/usr/lib/libnetwork.tbd) built for iOS Simulator`. It was thought that perhaps the host option should instead be `--host=${ARCH}-apple-ios-simulator` but this is not a valid option, and `configure` will fail with a different error: `checking host system type... Invalid configuration 'arm64-apple-ios-simulator': Kernel 'ios' not known to work with OS 'simulator`. If you do not specify a min iOS version, this is not required. Mysteriously, the other simulators (tvOS, watchOS) do not have this issue....
9191

92+
## Building wolfSSL and curl
93+
94+
Building curl with wolfSSL for Apple targets using configure/autotools can be accomplished with the following procedure:
95+
96+
1. Build wolfSSL as described in the above steps with curl compatibility enabled, either as a framework using the helper script, or as a cross-compiled library for your desired platform
97+
98+
```sh
99+
cd /path/to/wolfssl/IDE/apple-universal
100+
101+
# build wolfSSL as a framework using the helper script
102+
./build-wolfssl-framework.sh -c "--enable-curl"
103+
104+
# or build as a static library for one platform (using iOS as an example)
105+
ARCH=arm64
106+
WOLFSSL_INSTALL=/path/to/output/install/wolfssl-iphoneos-${ARCH}
107+
./configure --host=${ARCH}-apple-darwin \
108+
--enable-curl \
109+
--enable-static --disable-shared \
110+
--prefix=${WOLFSSL_INSTALL} \
111+
CFLAGS="-arch ${ARCH} -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"
112+
113+
make
114+
```
115+
116+
2. Configure and build curl to use the wolfSSL library for your platform that was built in step 1. Note that you must use `--with-wolfssl` to point curl to the wolfSSL *library install* for your specific platform, not to the xcframework.
117+
118+
```sh
119+
cd /path/to/curl
120+
121+
# Note that it is necessary to manually link curl against the Apple CoreFoundation and Security frameworks,
122+
# as they are required by wolfSSL on Apple platforms. Using iOS as an example:
123+
./configure --host=${ARCH}-apple-darwin \
124+
--with-wolfssl=${WOLFSSL_INSTALL} \
125+
CFLAGS="-arch ${ARCH} -isysroot $(xcrun -sdk iphoneos --show-sdk-path)" \
126+
LDFLAGS="-framework CoreFoundation -framework Security"
127+
128+
make
129+
```
130+
92131

0 commit comments

Comments
 (0)