Skip to content

Commit 19bf7de

Browse files
committed
version 78.1.3
1 parent e64ccf5 commit 19bf7de

File tree

3 files changed

+142
-65
lines changed

3 files changed

+142
-65
lines changed

README.md

Lines changed: 139 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,172 @@
1-
## ICU for iOS, watchOS, tvOS, visionOS, macOS, Catalyst, Simulators - Intel(x86_64) / Apple Silicon(arm64)
1+
## ICU for iOS, watchOS, tvOS, visionOS, macOS, Mac Catalyst, and Simulators - Intel(x86_64) / Apple Silicon(arm64)
22

3-
Supported versions: 78.1
3+
This repository provides a universal build script for creating **static ICU libraries** for iOS, watchOS, tvOS, visionOS, macOS, and Mac Catalyst.
44

5-
This repo provides a universal script for building static ICU libraries for use in iOS, watchOS, tvOS, visionOS, and macOS applications. The actual ICU library version is taken from https://github.com/unicode-org/icu . The branches of the repository generally correspond to the branches of the ICU repository. E.g. "78" branch corresponds to "maint/maint-78" branch.
5+
The ICU source code is taken from the official Unicode ICU repository:
6+
https://github.com/unicode-org/icu
67

7-
# Prerequisites
8-
1) Xcode must be installed as xcodebuild is used to create xcframeworks
9-
2) ```xcode-select -p``` must point to the Xcode app developer directory (by default e.g. /Applications/Xcode.app/Contents/Developer). If it points to the CommandLineTools directory you should run:
10-
```sudo xcode-select --reset``` or ```sudo xcode-select -s /Applications/Xcode.app/Contents/Developer```
11-
12-
# Build Manually
13-
```
14-
# clone the repo
15-
git clone -b 78 https://github.com/apotocki/icu4c-iosx
16-
17-
# build libraries
18-
cd icu4c-iosx
19-
scripts/build.sh
8+
Repository branches generally correspond to ICU maintenance branches. For example, the `78` branch corresponds to the `maint/maint-78` branch in the ICU repository.
209

21-
# have fun, the result artifacts will be located in 'product' folder.
22-
```
23-
# Selecting Platforms and Architectures
24-
build.sh without arguments will build xcframeworks for iOS, macOS, and also for watchOS, tvOS, visionOS if their SDKs are installed on the system. It will also build xcframeworks for their simulators with the architecture (arm64 or x86_64) depending on the current host.
25-
If you are interested in a specific set of platforms and architectures, you can specify them explicitly using the -p argument, for example:
10+
### Supported ICU Version: 78.1
11+
12+
---
13+
14+
## Prerequisites
15+
16+
1. **Xcode** must be installed, as `xcodebuild` is used to create XCFrameworks.
17+
2. `xcode-select -p` must point to the Xcode developer directory (for example, `/Applications/Xcode.app/Contents/Developer`).
18+
19+
If it points to the CommandLineTools directory, run one of the following commands:
20+
```bash
21+
sudo xcode-select --reset
22+
# or
23+
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
24+
```
25+
26+
---
27+
28+
## Build Manually
29+
30+
```bash
31+
# Clone the repository
32+
git clone -b 78.1.3 https://github.com/apotocki/icu4c-iosx
33+
34+
# Build libraries
35+
cd icu4c-iosx
36+
scripts/build.sh
2637
```
38+
39+
The resulting artifacts will be located in the `product` directory.
40+
41+
---
42+
43+
## Selecting Platforms and Architectures
44+
45+
Running `build.sh` without arguments builds XCFrameworks for **iOS** and **macOS**, and also for **watchOS**, **tvOS**, and **visionOS** if their SDKs are installed. Simulator XCFrameworks are built for the current host architecture (`arm64` or `x86_64`).
46+
47+
To build a specific set of platforms or architectures, use the `-p` option:
48+
49+
```bash
2750
scripts/build.sh -p=ios,iossim-x86_64
28-
# builts xcframeworks only for iOS and iOS Simulator with x86_64 architecture
29-
```
30-
Here is a list of all possible values for '-p' option:
31-
```
32-
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-both,tvossim-arm64,tvossim-x86_64,watchos,watchossim,watchossim-both,watchossim-arm64,watchossim-x86_64
51+
# Builds XCFrameworks only for iOS and the iOS Simulator (x86_64)
3352
```
34-
Suffix '-both' means that xcframeworks will be built for both arm64 and x86_64 architectures.
35-
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.
3653

37-
# ICU Data Archive
38-
The build.sh script builds the following xcframeworks: icudata, icui18n, icuio, and icuuc.
39-
By default, 'icudata' is built with the --with-data-packaging=static option (see https://unicode-org.github.io/icu/userguide/icu_data/). So all the metadata (locales, tables, etc) is placed into icudata library making it quite large (~32MB). Since xcframework may contain libraries for multiple platforms and architectures this metadata is duplicated multiple times wasting space. Therefore, ICU allows to move the metadata to a separate platform-independent file that must be loaded during the library initialization. To activate this option you can specify -d=archive :
54+
### Available `-p` Values
55+
56+
```text
57+
macosx,macosx-arm64,macosx-x86_64,macosx-both,
58+
ios,iossim,iossim-arm64,iossim-x86_64,iossim-both,
59+
catalyst,catalyst-arm64,catalyst-x86_64,catalyst-both,
60+
xros,xrossim,xrossim-arm64,xrossim-x86_64,xrossim-both,
61+
tvos,tvossim,tvossim-arm64,tvossim-x86_64,tvossim-both,
62+
watchos,watchossim,watchossim-arm64,watchossim-x86_64,watchossim-both
4063
```
64+
65+
- The `-both` suffix builds XCFrameworks for both `arm64` and `x86_64`.
66+
- Platform names without an architecture suffix (for example, `macosx`, `iossim`) build only for the current host architecture.
67+
68+
---
69+
70+
## ICU Data Archive
71+
72+
The `build.sh` script builds the following XCFrameworks:
73+
74+
- `icudata`
75+
- `icui18n`
76+
- `icuio`
77+
- `icuuc`
78+
79+
By default, `icudata` is built with `--with-data-packaging=static` (see the ICU data documentation). All ICU metadata (locales, tables, rules, etc.) is embedded directly into the `icudata` library, making it relatively large (~32 MB).
80+
81+
Because an XCFramework may include multiple platforms and architectures, this metadata is duplicated several times, increasing the overall size. ICU allows this data to be moved into a separate, platform-independent archive that is loaded at runtime.
82+
83+
To enable this option, use `-d=archive`:
84+
85+
```bash
4186
scripts/build.sh -p=ios,iossim-x86_64 -d=archive
42-
# builts xcframeworks for iOS and iOS Simulator with x86_64 architecture
43-
# datafile path is product/share/icu/78.1/icudt78l.dat
87+
# Builds XCFrameworks for iOS and the iOS Simulator (x86_64)
88+
# Data file path: product/share/icu/78.1/icudt78l.dat
4489
```
45-
In that case, during the ICU initialization procedure you have to specify ICU data directory before u_init() call:
4690

47-
```
91+
During ICU initialization, you must specify the ICU data directory **before** calling `u_init()`:
92+
93+
```c
4894
#include <unicode/putil.h>
95+
#include <unicode/uclean.h>
96+
97+
// Specify the directory containing the ICU data file
98+
u_setDataDirectory("PATH_TO_DIRECTORY_CONTAINING_icudt78l.dat");
99+
100+
UErrorCode errCode = U_ZERO_ERROR;
101+
u_init(&errCode);
102+
if (U_FAILURE(errCode)) {
103+
// Handle initialization error
104+
...
105+
}
49106

50-
... // somewhere in ICU initialization procedure before u_init call
51-
u_setDataDirectory("PATH TO THE DIRECTORY WHERE icudt78l.dat is located");
107+
// Use ICU API...
108+
109+
u_cleanup(); // Optional: release ICU resources
52110

53-
u_init(code)
54-
...
55111
```
56112
113+
---
114+
57115
## ICU Data Filtering
58-
ICU metadata is a rather large set of different locales, tables, rules and so on. It's very likely that you won't need all of them in your application. Fortunately, we can filter the data we need when building the icudata library by specifying the filter with the -f option:
59-
```
116+
117+
ICU metadata includes a large collection of locales, tables, and rules. In most applications, only a subset of this data is required.
118+
119+
You can reduce the size of `icudata` by applying a data filter using the `-f` option:
120+
121+
```bash
60122
scripts/build.sh -p=ios,iossim-x86_64 -f=path_to_filter.json
61-
# builts xcframeworks for iOS and iOS Simulator with x86_64 architecture
123+
# Builds XCFrameworks for iOS and the iOS Simulator (x86_64)
62124
```
63-
The format of the filter is described at https://unicode-org.github.io/icu/userguide/icu_data/buildtool.html
64125
65-
## Rebuild option
66-
To rebuild the library without using the results of previous builds, use the --rebuild option
67-
```
68-
scripts/build.sh -p=ios,iossim-x86_64 --rebuild
126+
The filter format is described in the official ICU documentation:
127+
https://unicode-org.github.io/icu/userguide/icu_data/buildtool.html
69128
70-
```
129+
---
130+
131+
## Rebuild Option
71132
72-
# Build Using Cocoapods.
73-
Add the following lines into your project's Podfile:
133+
To rebuild the libraries without using artifacts from previous builds, use the `--rebuild` option:
134+
135+
```bash
136+
scripts/build.sh -p=ios,iossim-x86_64 --rebuild
74137
```
75-
use_frameworks!
76-
pod 'icu4c-iosx', '~> 78.1'
77-
78-
# or optionally more precisely
79-
# pod 'icu4c-iosx', :git => 'https://github.com/apotocki/icu4c-iosx', :tag => '78.1.2'
138+
139+
---
140+
141+
## Build Using CocoaPods
142+
143+
Add the following to your `Podfile`:
144+
145+
```ruby
146+
use_frameworks!
147+
pod 'icu4c-iosx', '~> 78.1'
148+
149+
# Or explicitly reference the repository
150+
# pod 'icu4c-iosx', :git => 'https://github.com/apotocki/icu4c-iosx', :tag => '78.1.3'
80151
```
81-
install new dependency:
82-
```
152+
153+
Install the dependency:
154+
```bash
83155
pod install --verbose
84156
```
85157
86-
## As advertising...
87-
The ICU libraries that have been built by this project are being used in my iOS application on the App Store:
158+
---
159+
160+
## Used in Production
161+
162+
The ICU libraries built by this project are used in my iOS application available on the App Store:
88163
89164
[<table align="center" border=0 cellspacing=0 cellpadding=0><tr><td><img src="https://is4-ssl.mzstatic.com/image/thumb/Purple112/v4/78/d6/f8/78d6f802-78f6-267a-8018-751111f52c10/AppIcon-0-1x_U007emarketing-0-10-0-85-220.png/460x0w.webp" width="70"/></td><td><a href="https://apps.apple.com/us/app/potohex/id1620963302">PotoHEX</a><br>HEX File Viewer & Editor</td><tr></table>]()
90165
91-
This application is designed to view and edit files at the byte or character level; calculate different hashes, encode/decode, and compress/decompress desired byte regions.
92-
93-
You can support my open-source development by trying the [App](https://apps.apple.com/us/app/potohex/id1620963302).
166+
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.
167+
168+
If you find this project useful, you can support my open-source work by trying the [App](https://apps.apple.com/us/app/potohex/id1620963302).
169+
170+
---
94171
95172
Feedback is welcome!

icu4c-iosx.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "icu4c-iosx"
3-
s.version = "78.1.2"
3+
s.version = "78.1.3"
44
s.summary = "ICU XCFramework for macOS, iOS, watchOS, tvOS, and visionOS, including builds for Mac Catalyst, iOS Simulator, watchOS Simulator, tvOS Simulator, and visionOS Simulator."
55
s.homepage = "https://github.com/apotocki/icu4c-iosx"
66
s.license = "BSD"

scripts/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ BUILD_PLATFORMS=" ${BUILD_PLATFORMS//,/ } "
110110
for i in $BUILD_PLATFORMS; do :;
111111
if [[ ! ",$BUILD_PLATFORMS_ALL," == *",$i,"* ]]; then
112112
echo "Unknown platform '$i'"
113-
exi1 1
113+
exit 1
114114
fi
115115
done
116116

117117
if [[ $WITH_DATA_FILTER ]]; then
118118
[[ ! "$WITH_DATA_FILTER" == "/"* ]] && [[ -f $BUILD_DIR/$WITH_DATA_FILTER ]] && WITH_DATA_FILTER=$BUILD_DIR/$WITH_DATA_FILTER
119119
if [[ ! -f $WITH_DATA_FILTER ]]; then
120120
echo "File '$WITH_DATA_FILTER' is not found."
121-
exi1 1
121+
exit 1
122122
fi
123123
fi
124124

0 commit comments

Comments
 (0)