Supported version: 1.9.4
This repo provides a universal script for building a static liblz4 library for use in iOS and Mac OS X applications. The actual library version is taken from https://github.com/lz4/lz4 with tag 'v1.9.4'
-
Install Xcode: Ensure Xcode is installed, as
xcodebuildis required to createxcframeworks. -
Verify Xcode Developer Directory:
- The
xcode-select -pcommand must point to the Xcode app's developer directory (e.g.,/Applications/Xcode.app/Contents/Developer). - If it points to the CommandLineTools directory, reset it using one of the following commands:
or
sudo xcode-select --reset
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
- The
-
Install Required SDKs: To build for tvOS, watchOS, visionOS, and their simulators, make sure the corresponding SDKs are installed in the folder:
/Applications/Xcode.app/Contents/Developer/Platforms
- Install CMake: CMake (at least version 3.10) must be installed, e.g., via
brew install cmake.
# clone the repo
git clone -b 1.9.4 https://github.com/apotocki/lz4-iosx
# build libraries
cd lz4-iosx
scripts/build.sh
# the result artifacts will be located in 'frameworks' folder.
# Then you can add the xcframework to your Xcode project. The process is described, e.g., at https://www.simpleswiftguide.com/how-to-add-xcframework-to-xcode-project/
build.sh without arguments builds xcframeworks for iOS, macOS, Catalyst and also for watchOS, tvOS, visionOS if their SDKs are installed on the system. It also builds xcframeworks for their simulators with the architecture (arm64 or x86_64) depending on the current host. If you are interested in a specific set of platforms and architectures, you can specify them explicitly using the -p argument, for example:
scripts/build.sh -p=ios,iossim-x86_64
# builds xcframeworks only for iOS and iOS Simulator with x86_64 architecture
Here is a list of all possible values for '-p' option:
macosx,macosx-arm64,macosx-x86_64,macosx-both,ios,iossim,iossim-arm64,iossim-x86_64,iossim-both,catalyst,catalyst-arm64,catalyst-x86_64,catalyst-both,xros,xrossim,xrossim-arm64,xrossim-x86_64,xrossim-both,tvos,tvossim,tvossim-arm64,tvossim-x86_64,tvossim-both,watchos,watchossim,watchossim-arm64,watchossim-x86_64,watchossim-both
Suffix '-both' means that xcframeworks will be built for both arm64 and x86_64 architectures. The platform names for macosx and simulators without an architecture suffix (e.g. macosx, iossim, tvossim) mean that xcframeworks are only built for the current host architecture.
To rebuild the libraries without using the results of previous builds, use the --rebuild option
scripts/build.sh -p=ios,iossim-x86_64 --rebuild
Add the following lines to your project's Podfile:
use_frameworks!
pod 'lz4-iosx', '~> 1.9.4'
# or optionally more precisely e.g.:
# pod 'lz4-iosx', :git => 'https://github.com/apotocki/lz4-iosx', :tag => '1.9.4.3'
Then install the dependencies:
pod install --verbose
The LZ4 XCFramework built by this project is used in my iOS application on the App Store:
|
|
PotoHEX HEX File Viewer & Editor |
PotoHEX is designed for viewing and editing files at the byte or character level, calculating hashes, encoding/decoding data, and compressing/decompressing selected byte ranges.
If you find this project useful, you can support my open-source work by trying the App.
Feedback is welcome!