react-native-lingua 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Lingua.podspec +12 -47
- package/README.md +1 -1
- package/android/build.gradle +1 -4
- package/android/src/main/jni/include/liblingua.h +1 -1
- package/ios/build.sh +73 -0
- package/package.json +13 -13
package/Lingua.podspec
CHANGED
|
@@ -15,54 +15,19 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}"
|
|
17
17
|
s.private_header_files = "ios/**/*.h"
|
|
18
|
-
s.vendored_frameworks = "ios/*.xcframework"
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if ! rustup target list --installed | grep -q "aarch64-apple-ios"; then
|
|
33
|
-
echo "[ERROR] iOS Rust targets not installed."
|
|
34
|
-
echo "Please run: rustup target add aarch64-apple-ios aarch64-apple-ios-sim"
|
|
35
|
-
exit 1
|
|
36
|
-
fi
|
|
37
|
-
|
|
38
|
-
# Clean previous builds
|
|
39
|
-
rm -rf rust/generated/liblingua_native.xcframework
|
|
40
|
-
rm -rf ios/liblingua_native.xcframework
|
|
41
|
-
|
|
42
|
-
# Build the xcframework
|
|
43
|
-
cd rust
|
|
44
|
-
make header
|
|
45
|
-
|
|
46
|
-
# Build for iOS targets
|
|
47
|
-
echo "[INFO] Building Rust library for iOS..."
|
|
48
|
-
cargo build --release --target aarch64-apple-ios
|
|
49
|
-
cargo build --release --target aarch64-apple-ios-sim
|
|
50
|
-
|
|
51
|
-
# Create xcframework
|
|
52
|
-
mkdir -p generated/include
|
|
53
|
-
xcodebuild -create-xcframework \
|
|
54
|
-
-library target/aarch64-apple-ios/release/liblingua_native.a \
|
|
55
|
-
-headers generated/include \
|
|
56
|
-
-library target/aarch64-apple-ios-sim/release/liblingua_native.a \
|
|
57
|
-
-headers generated/include \
|
|
58
|
-
-output generated/liblingua_native.xcframework
|
|
59
|
-
|
|
60
|
-
# Copy to ios directory
|
|
61
|
-
cp -rf generated/liblingua_native.xcframework ../ios/
|
|
62
|
-
cp -f generated/include/liblingua.h ../cpp/
|
|
63
|
-
|
|
64
|
-
echo "[SUCCESS] Rust library built successfully"
|
|
65
|
-
CMD
|
|
19
|
+
s.pod_target_xcconfig = {
|
|
20
|
+
'LIBRARY_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/ios/build"',
|
|
21
|
+
'OTHER_LDFLAGS' => '-llingua_native'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
s.script_phase = {
|
|
25
|
+
:name => 'Build Rust Library',
|
|
26
|
+
:script => 'bash "${PODS_TARGET_SRCROOT}/ios/build.sh"',
|
|
27
|
+
:execution_position => :before_compile,
|
|
28
|
+
:input_files => ['${PODS_TARGET_SRCROOT}/rust/src/**/*.rs', '${PODS_TARGET_SRCROOT}/rust/Cargo.toml'],
|
|
29
|
+
:output_files => ['${PODS_TARGET_SRCROOT}/ios/build/liblingua_native.a', '${PODS_TARGET_SRCROOT}/cpp/liblingua.h']
|
|
30
|
+
}
|
|
66
31
|
|
|
67
32
|
install_modules_dependencies(s)
|
|
68
33
|
end
|
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ npm install react-native-lingua
|
|
|
48
48
|
yarn add react-native-lingua
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
The native libraries will be built automatically during
|
|
51
|
+
The native libraries will be built automatically during the native build process (Xcode/Gradle).
|
|
52
52
|
|
|
53
53
|
### iOS Setup
|
|
54
54
|
|
package/android/build.gradle
CHANGED
|
@@ -98,10 +98,7 @@ task buildRust(type: Exec) {
|
|
|
98
98
|
workingDir file("${projectDir}/../rust")
|
|
99
99
|
commandLine 'make', 'android'
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
onlyIf {
|
|
103
|
-
!file("${projectDir}/jniLibs/arm64-v8a/liblingua_native.a").exists()
|
|
104
|
-
}
|
|
101
|
+
|
|
105
102
|
|
|
106
103
|
dependsOn buildRustHeader
|
|
107
104
|
}
|
package/ios/build.sh
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
# Setup path to rust/cargo
|
|
5
|
+
# Xcode doesn't load .zshrc/.bashrc, so we need to find cargo manually if not in PATH
|
|
6
|
+
export PATH="$HOME/.cargo/bin:$PATH"
|
|
7
|
+
|
|
8
|
+
if ! command -v cargo &> /dev/null; then
|
|
9
|
+
echo "error: Rust not found. Please install Rust: https://rustup.rs"
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
# Move to rust directory
|
|
14
|
+
TOOLS_DIR=$(cd "$(dirname "$0")/../rust" && pwd)
|
|
15
|
+
cd "$TOOLS_DIR"
|
|
16
|
+
|
|
17
|
+
echo "Building Rust library for ARCHS=$ARCHS PLATFORM_NAME=$PLATFORM_NAME"
|
|
18
|
+
|
|
19
|
+
LIBS=()
|
|
20
|
+
|
|
21
|
+
for ARCH in $ARCHS; do
|
|
22
|
+
TARGET=""
|
|
23
|
+
if [ "$PLATFORM_NAME" == "iphoneos" ]; then
|
|
24
|
+
if [ "$ARCH" == "arm64" ]; then
|
|
25
|
+
TARGET="aarch64-apple-ios"
|
|
26
|
+
fi
|
|
27
|
+
elif [ "$PLATFORM_NAME" == "iphonesimulator" ]; then
|
|
28
|
+
if [ "$ARCH" == "arm64" ]; then
|
|
29
|
+
TARGET="aarch64-apple-ios-sim"
|
|
30
|
+
elif [ "$ARCH" == "x86_64" ]; then
|
|
31
|
+
TARGET="x86_64-apple-ios"
|
|
32
|
+
fi
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
if [ -z "$TARGET" ]; then
|
|
36
|
+
echo "warning: Unknown arch $ARCH for platform $PLATFORM_NAME, skipping"
|
|
37
|
+
continue
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
echo "Building for $TARGET"
|
|
41
|
+
# Ensure target is added
|
|
42
|
+
rustup target add "$TARGET"
|
|
43
|
+
|
|
44
|
+
cargo build --release --target "$TARGET" --lib
|
|
45
|
+
LIBS+=("target/$TARGET/release/liblingua_native.a")
|
|
46
|
+
done
|
|
47
|
+
|
|
48
|
+
# Ensure header is generated and copied
|
|
49
|
+
HEADER_PATH="generated/include/liblingua.h"
|
|
50
|
+
# If header doesn't exist (maybe built fresh), force generation
|
|
51
|
+
if [ ! -f "$HEADER_PATH" ]; then
|
|
52
|
+
echo "Header generated/include/liblingua.h missing, forcing generation..."
|
|
53
|
+
mkdir -p generated/include
|
|
54
|
+
# Force build.rs to run by updating mtime of main source
|
|
55
|
+
touch src/lib.rs
|
|
56
|
+
cargo build --lib
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
echo "Copying header to cpp/"
|
|
60
|
+
cp -f "$HEADER_PATH" "../cpp/liblingua.h"
|
|
61
|
+
|
|
62
|
+
# Link with Lipo
|
|
63
|
+
mkdir -p "../ios/build"
|
|
64
|
+
OUTPUT_LIB="../ios/build/liblingua_native.a"
|
|
65
|
+
rm -f "$OUTPUT_LIB"
|
|
66
|
+
|
|
67
|
+
if [ ${#LIBS[@]} -eq 0 ]; then
|
|
68
|
+
echo "error: No libraries built for ARCHS=$ARCHS"
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
echo "Creating universal library at $OUTPUT_LIB from ${LIBS[@]}"
|
|
73
|
+
lipo -create "${LIBS[@]}" -output "$OUTPUT_LIB"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-lingua",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A lingua-rs wrapper for React Native",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"lib",
|
|
18
18
|
"android",
|
|
19
19
|
"ios/*.{h,mm}",
|
|
20
|
+
"ios/build.sh",
|
|
20
21
|
"cpp",
|
|
21
22
|
"rust/src",
|
|
22
23
|
"rust/Cargo.toml",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"!android/gradlew",
|
|
32
33
|
"!android/gradlew.bat",
|
|
33
34
|
"!android/local.properties",
|
|
35
|
+
"!android/jniLibs",
|
|
34
36
|
"!cpp/liblingua.h",
|
|
35
37
|
"!**/__tests__",
|
|
36
38
|
"!**/__fixtures__",
|
|
@@ -39,16 +41,6 @@
|
|
|
39
41
|
"README.md",
|
|
40
42
|
"LICENSE"
|
|
41
43
|
],
|
|
42
|
-
"scripts": {
|
|
43
|
-
"example": "pnpm --filter react-native-lingua-example",
|
|
44
|
-
"test": "jest",
|
|
45
|
-
"typecheck": "tsc",
|
|
46
|
-
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
47
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
48
|
-
"build:rust": "cd rust && make all",
|
|
49
|
-
"prepare": "bob build",
|
|
50
|
-
"release": "release-it --only-version"
|
|
51
|
-
},
|
|
52
44
|
"workspaces": [
|
|
53
45
|
"example"
|
|
54
46
|
],
|
|
@@ -97,7 +89,6 @@
|
|
|
97
89
|
"react": "*",
|
|
98
90
|
"react-native": "*"
|
|
99
91
|
},
|
|
100
|
-
"packageManager": "pnpm@10.14.0",
|
|
101
92
|
"jest": {
|
|
102
93
|
"preset": "react-native",
|
|
103
94
|
"modulePathIgnorePatterns": [
|
|
@@ -169,5 +160,14 @@
|
|
|
169
160
|
},
|
|
170
161
|
"dependencies": {
|
|
171
162
|
"@babel/runtime": "^7.28.4"
|
|
163
|
+
},
|
|
164
|
+
"scripts": {
|
|
165
|
+
"example": "pnpm --filter react-native-lingua-example",
|
|
166
|
+
"test": "jest",
|
|
167
|
+
"typecheck": "tsc",
|
|
168
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
169
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
170
|
+
"build:rust": "cd rust && make all",
|
|
171
|
+
"release": "release-it --only-version"
|
|
172
172
|
}
|
|
173
|
-
}
|
|
173
|
+
}
|