Skip to content

Commit 33e24b7

Browse files
committed
fix: macos symlink issue
because osx is using symlinks for versioning, distributing its framework via npm won't work - compression via tar breaks the link. therefore this script resolves the symlinks into actual folders, to match expected structure by macos.
1 parent a7bddb0 commit 33e24b7

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

scripts/build-native-lib.sh

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/sh
22

3+
set -e
34

45
MODULE_NAME="shared-storage"
56
RN_MODULE_DIR="packages/async-storage"
@@ -18,31 +19,58 @@ APPLE_RN_OUTPUT_DIR="$RN_MODULE_DIR/apple/Frameworks"
1819

1920

2021
build_android() {
21-
echo "👷 Assembling android shared-storage"
22+
log "👷 Assembling android shared-storage"
2223
./gradlew :$MODULE_NAME:$ANDROID_BUILD_TASK
2324

24-
echo "Publishing binaries to local repo"
25+
log "Publishing binaries to local repo"
2526
./gradlew :$MODULE_NAME:$ANDROID_PUBLISH_TASK
2627

27-
echo "Remove old local repo"
28+
log "Remove old local repo"
2829
rm -rf $ANDROID_RN_OUTPUT_DIR/$ANDROID_OUTPUT_NAME
2930

30-
echo "Moving local repo to RN target"
31+
log "Moving local repo to RN target"
3132
mv $ANDROID_OUTPUT_DIR/$ANDROID_OUTPUT_NAME $ANDROID_RN_OUTPUT_DIR/$ANDROID_OUTPUT_NAME
32-
echo "all done"
33+
34+
log "🚀 all done"
3335
}
3436

3537
build_apple() {
36-
echo "👷 Assembling apple shared-storage"
38+
log "👷 Assembling apple shared-storage"
3739
./gradlew :$MODULE_NAME:$APPLE_BUILD_TASK
3840

39-
echo "recreate Frameworks dir"
41+
log "recreate Frameworks dir"
4042
rm -rf $APPLE_RN_OUTPUT_DIR
4143
mkdir $APPLE_RN_OUTPUT_DIR
4244

43-
echo "move xcframework to RN module"
45+
log "move xcframework to RN module"
4446
mv $APPLE_OUTPUT_DIR/$APPLE_OUTPUT_NAME $APPLE_RN_OUTPUT_DIR/$APPLE_OUTPUT_NAME
45-
echo "all done"
47+
48+
49+
# because osx is using symlinks for versioning, distributing its framework via
50+
# npm won't work - compression via tar breaks the link.
51+
# therefore this script resolves the symlinks into actual folders, to match
52+
# expected structure by macos.
53+
MAC_OS_FRAMEWORK="$APPLE_RN_OUTPUT_DIR/SharedAsyncStorage.xcframework/macos-arm64_x86_64/SharedAsyncStorage.framework"
54+
55+
log "fixing macos symlinks"
56+
57+
# symlinks
58+
rm "$MAC_OS_FRAMEWORK/Headers" "$MAC_OS_FRAMEWORK/Modules" "$MAC_OS_FRAMEWORK/Resources" "$MAC_OS_FRAMEWORK/SharedAsyncStorage"
59+
60+
cp -r --copy-content "$MAC_OS_FRAMEWORK/Versions/A/Headers" -t "$MAC_OS_FRAMEWORK/"
61+
cp -r --copy-content "$MAC_OS_FRAMEWORK/Versions/A/Modules" -t "$MAC_OS_FRAMEWORK/"
62+
cp -r --copy-content "$MAC_OS_FRAMEWORK/Versions/A/Resources" -t "$MAC_OS_FRAMEWORK/"
63+
cp --copy-content "$MAC_OS_FRAMEWORK/Versions/A/SharedAsyncStorage" -t "$MAC_OS_FRAMEWORK/"
64+
65+
# clear versions, not needed
66+
rm -r "$MAC_OS_FRAMEWORK/Versions"
67+
68+
log "🚀 all done"
69+
}
70+
71+
log() {
72+
local message="$1"
73+
echo "[AsyncStorage] $message"
4674
}
4775

4876
TARGET=$1

shared-storage/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ plugins {
1010
alias(libs.plugins.skie)
1111
}
1212

13-
1413
/**
1514
* Windows as native target is not currently supported by Room db.
1615
* https://issuetracker.google.com/issues/363195546
@@ -41,12 +40,12 @@ kotlin {
4140
listOf(iosX64(), iosArm64(), iosSimulatorArm64(), macosArm64(), macosX64()).forEach {
4241
it.binaries.framework {
4342
baseName = xcfName
43+
isStatic = true
4444
xcf.add(this)
4545
binaryOption("bundleId", "org.asyncstorage.shared_storage")
4646
}
4747
}
4848

49-
5049
sourceSets {
5150
commonMain {
5251
dependencies {

0 commit comments

Comments
 (0)