diff --git a/.maestro/flows/_assets-test.yaml b/.maestro/flows/_assets-test.yaml index 731bcdcf..b07726b2 100644 --- a/.maestro/flows/_assets-test.yaml +++ b/.maestro/flows/_assets-test.yaml @@ -2,29 +2,20 @@ appId: ${APP_ID} --- - runFlow: when: - notVisible: "Assets (Android)" + notVisible: "Bundled Assets" commands: - tapOn: "Playground" - scrollUntilVisible: element: - text: "Assets (Android)" + text: "Bundled Assets" direction: DOWN -- tapOn: "Assets (Android)" -- runFlow: - when: - visible: "Not Supported" - commands: - - assertVisible: "Not Supported" -- runFlow: - when: - visible: "Android Assets Demo" - commands: - - assertVisible: "Android Assets Demo" - - tapOn: "Unzip Assets" - - waitForAnimationToEnd: - timeout: 10000 - - assertVisible: "Extracted To" - - extendedWaitUntil: - visible: "Files:" - timeout: 10000 - - assertVisible: "Files:" +- tapOn: "Bundled Assets" +- assertVisible: "Bundled Assets Demo" +- tapOn: "Unzip Assets" +- waitForAnimationToEnd: + timeout: 10000 +- assertVisible: "Extracted To" +- extendedWaitUntil: + visible: "Files:" + timeout: 10000 +- assertVisible: "Files:" diff --git a/CHANGELOG.md b/CHANGELOG.md index dfa3f44c..495341a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [9.4.0] - 2026-07-25 + +### Added +- iOS: `unzipAssets` reads archives from the main app bundle (parity with Android `assets/`) (#368) +- iOS: preserve empty directories when zipping directory items in a files array (#368) + +### Changed +- iOS: non-UTF-8 `charset` arguments now reject with `ERR_UNSUPPORTED` instead of being silently ignored (#368) +- iOS: `getUncompressedSize` rejects on failure (previously resolved `-1`) for parity with Android + ## [9.3.0] - 2026-07-25 ### Fixed diff --git a/README.md b/README.md index 0c6d534a..e7d18a73 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Or with an explicit charset: unzip(sourcePath, targetPath, 'UTF-8', ['readme.md', 'docs']) ``` -> The `charset` parameter is only supported on Android (default: `UTF-8`). On iOS it is ignored. +> The `charset` parameter defaults to `UTF-8`. On Android, other charsets are supported. On iOS, non-UTF-8 values reject with `ERR_UNSUPPORTED`. ```js const sourcePath = `${DocumentDirectoryPath}/myFile.zip` @@ -162,7 +162,7 @@ type ZipEntry = { } ``` -> The `charset` parameter is only supported on Android (default: `UTF-8`). On iOS it is ignored. +> The `charset` parameter defaults to `UTF-8`. On Android, other charsets are supported. On iOS, non-UTF-8 values reject with `ERR_UNSUPPORTED`. ```js listContents(sourcePath) @@ -176,9 +176,12 @@ listContents(sourcePath) ### `unzipAssets(assetPath: string, target: string): Promise` -Unzip a file from the Android `assets` folder. **Android only.** +Unzip a bundled archive. -`assetPath` is the relative path inside the pre-bundled assets folder (e.g. `folder/myFile.zip`). Do not pass an absolute path. +- **Android:** relative path inside the APK `assets/` folder (also accepts `content://` URIs). +- **iOS:** relative path inside the main app bundle (e.g. a file copied with Xcode “Copy Bundle Resources”). + +Do not pass an absolute filesystem path. ```js unzipAssets('./myFile.zip', DocumentDirectoryPath) @@ -265,21 +268,22 @@ useEffect(() => { | `zip` (files array) | ✅ | ✅ | — | | `zipWithPassword` (folder) | ✅ | ✅ | Prefer `STANDARD` for server unzip | | `zipWithPassword` (files array) | ✅ | ✅ | iOS honors `STANDARD` vs AES | -| `unzip` | ✅ | ✅ | Optional `entries` for selective extract; charset ignored on iOS | +| `unzip` | ✅ | ✅ | Optional `entries`; non-UTF-8 charset → `ERR_UNSUPPORTED` on iOS | | `unzipWithPassword` | ✅ | ✅ | Optional `entries` for selective extract | -| `listContents` | ✅ | ✅ | Charset ignored on iOS | -| `unzipAssets` | ❌ | ✅ | Android only | +| `listContents` | ✅ | ✅ | Non-UTF-8 charset → `ERR_UNSUPPORTED` on iOS | +| `unzipAssets` | ✅ | ✅ | Android `assets/` (+ `content://`); iOS main bundle | | `cancel` | ✅ | ✅ | Best-effort mid-operation abort | | `isPasswordProtected` | ✅ | ✅ | — | -| `getUncompressedSize` | ✅ | ✅ | Charset ignored on iOS | +| `getUncompressedSize` | ✅ | ✅ | Non-UTF-8 charset → `ERR_UNSUPPORTED` on iOS | | Progress Events | ✅ | ✅ | File path empty on iOS for zip | ### Cross-Platform Notes - **Compression levels:** Android supports 0–9 for all operations. iOS supports 0–9 for folder and file-array zips. - **Encryption:** Android supports AES-128, AES-256, and Standard ZIP encryption for all operations. On iOS, pass `'STANDARD'` (default) for ZipCrypto archives that Node `unzipper` / Java `ZipInputStream` can read; `'AES-128'` / `'AES-256'` produce WinZip-AES archives that many server tools cannot open. -- **Charset:** Android supports custom charsets (default UTF-8). iOS always uses UTF-8. -- **unzipAssets:** Supports `assets/` folder and `content://` URIs on Android. Not supported on iOS. +- **Charset:** Android supports custom charsets (default UTF-8). iOS accepts only UTF-8; other values reject with `ERR_UNSUPPORTED`. +- **unzipAssets:** Android reads `assets/` (and `content://`). iOS reads from the main app bundle using the same relative path. +- **Empty directories:** Preserved when zipping directory contents via a files/folders array on both platforms. ### Server-side unzip interoperability diff --git a/RNZipArchive.podspec b/RNZipArchive.podspec index 9e12d730..88efbd78 100644 --- a/RNZipArchive.podspec +++ b/RNZipArchive.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| end s.dependency 'SSZipArchive', '~>2.5.5' s.pod_target_xcconfig = { - 'HEADER_SEARCH_PATHS' => '$(inherited) "${PODS_ROOT}/SSZipArchive" "${PODS_ROOT}/SSZipArchive/SSZipArchive/minizip"' + 'HEADER_SEARCH_PATHS' => '$(inherited) "$(PODS_ROOT)/SSZipArchive" "$(PODS_ROOT)/SSZipArchive/SSZipArchive/minizip"' } s.source_files = 'ios/*.{h,m,mm}' diff --git a/ios/RNZipArchive.mm b/ios/RNZipArchive.mm index c0046c85..c2cb77bd 100644 --- a/ios/RNZipArchive.mm +++ b/ios/RNZipArchive.mm @@ -9,8 +9,10 @@ #import "RNZipArchive.h" #if __has_include() #import -#else +#elif __has_include("mz_compat.h") #import "mz_compat.h" +#else +#import "unzip.h" #endif #import #import @@ -127,13 +129,35 @@ - (void)isPasswordProtected:(NSString *)file }]; } +- (BOOL)isUtf8Charset:(NSString *)charset { + if (charset == nil || charset.length == 0) { + return YES; + } + NSString *normalized = [[charset stringByReplacingOccurrencesOfString:@"-" withString:@""] + lowercaseString]; + return [normalized isEqualToString:@"utf8"]; +} + +- (BOOL)rejectIfUnsupportedCharset:(NSString *)charset + reject:(RCTPromiseRejectBlock)reject { + if ([self isUtf8Charset:charset]) { + return NO; + } + reject(kZipErrUnsupported, + [NSString stringWithFormat:@"charset '%@' is not supported on iOS (UTF-8 only)", charset], + nil); + return YES; +} + - (void)unzip:(NSString *)from destinationPath:(NSString *)destinationPath charset:(NSString *)charset entries:(NSArray *)entries resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject { - (void)charset; + if ([self rejectIfUnsupportedCharset:charset reject:reject]) { + return; + } [self beginOperation]; [self runAsync:^{ if (entries != nil && entries.count > 0) { @@ -174,7 +198,9 @@ - (void)listContents:(NSString *)source charset:(NSString *)charset resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject { - (void)charset; // iOS always reads entry names as UTF-8 / Latin-1 fallback + if ([self rejectIfUnsupportedCharset:charset reject:reject]) { + return; + } [self beginOperation]; [self runAsync:^{ zipFile zip = unzOpen(source.fileSystemRepresentation); @@ -662,10 +688,11 @@ - (void)zipFolder:(NSString *)from }]; } -// Expands `paths` into (full path, entry name) pairs. Files keep their base -// name; directory contents are added recursively with entry names relative to -// the listed directory (e.g. "a.txt", "sub/b.txt"), matching Android's -// zip(string[]) behavior (#339). Directory entries themselves are not written. +// Expands `paths` into (full path, entry name, kind) triples. +// kind is @"file" or @"dir". Files keep their base name; directory contents are +// added recursively with entry names relative to the listed directory +// (e.g. "a.txt", "sub/b.txt"), matching Android's zip(string[]) behavior (#339). +// Empty directories are preserved as directory entries for Android parity (#368). // Returns nil if any path does not exist. - (NSArray *> *)expandedZipEntries:(NSArray *)paths { NSFileManager *fileManager = [[NSFileManager alloc] init]; @@ -676,7 +703,7 @@ - (void)zipFolder:(NSString *)from return nil; } if (!isDirectory) { - [entries addObject:@[path, path.lastPathComponent]]; + [entries addObject:@[path, path.lastPathComponent, @"file"]]; continue; } NSDirectoryEnumerator *enumerator = [fileManager enumeratorAtPath:path]; @@ -686,9 +713,13 @@ - (void)zipFolder:(NSString *)from BOOL childIsDirectory = NO; [fileManager fileExistsAtPath:fullPath isDirectory:&childIsDirectory]; if (childIsDirectory) { + NSArray *children = [fileManager contentsOfDirectoryAtPath:fullPath error:nil]; + if (children.count == 0) { + [entries addObject:@[fullPath, relativePath, @"dir"]]; + } continue; } - [entries addObject:@[fullPath, relativePath]]; + [entries addObject:@[fullPath, relativePath, @"file"]]; } } return entries; @@ -743,7 +774,16 @@ - (BOOL)writeZipEntriesToPath:(NSString *)destinationPath success = NO; break; } - success &= [zipArchive writeFileAtPath:entry[0] withFileName:entry[1] compressionLevel:compressionLevel password:password AES:aes]; + NSString *kind = entry.count > 2 ? entry[2] : @"file"; + if ([kind isEqualToString:@"dir"]) { + success &= [zipArchive writeFolderAtPath:entry[0] withFolderName:entry[1] withPassword:password]; + } else { + success &= [zipArchive writeFileAtPath:entry[0] + withFileName:entry[1] + compressionLevel:compressionLevel + password:password + AES:aes]; + } if (self.progressHandler) { complete++; self.progressHandler(complete, total); @@ -873,17 +913,19 @@ - (void)getUncompressedSize:(NSString *)path charset:(NSString *)charset resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject { - (void)charset; + if ([self rejectIfUnsupportedCharset:charset reject:reject]) { + return; + } [self beginOperation]; [self runAsync:^{ - NSError *error = nil; - NSNumber *wantedFileSize = [SSZipArchive payloadSizeForArchiveAtPath:path error:&error]; + NSError *error = nil; + NSNumber *wantedFileSize = [SSZipArchive payloadSizeForArchiveAtPath:path error:&error]; - if (error == nil) { - resolve(wantedFileSize); - } else { - resolve(@-1); - } + if (error == nil) { + resolve(wantedFileSize); + } else { + reject(kZipErrCorruptArchive, error.localizedDescription ?: @"Failed to get uncompressed size", error); + } }]; } @@ -891,9 +933,47 @@ - (void)unzipAssets:(NSString *)source target:(NSString *)target resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject { - // iOS doesn't have assets like Android, return error - NSError *error = [NSError errorWithDomain:@"RNZipArchive" code:-1 userInfo:@{NSLocalizedDescriptionKey: @"unzipAssets is not supported on iOS"}]; - reject(kZipErrUnsupported, @"unzipAssets is not supported on iOS", error); + // Android reads from the APK assets/ folder. On iOS, map the same relative + // path onto the main app bundle so playground/docs can share one API (#368). + if (source.length == 0) { + reject(kZipErrInvalidArgs, @"asset path must not be empty", nil); + return; + } + + NSString *normalized = source; + while ([normalized hasPrefix:@"./"]) { + normalized = [normalized substringFromIndex:2]; + } + if ([normalized hasPrefix:@"/"]) { + normalized = [normalized substringFromIndex:1]; + } + + NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; + NSString *assetPath = [bundleRoot stringByAppendingPathComponent:normalized]; + if (![[NSFileManager defaultManager] fileExistsAtPath:assetPath]) { + // Also try pathForResource for files copied as bundle resources without folders. + NSString *resourceName = normalized.stringByDeletingPathExtension.lastPathComponent; + NSString *resourceExt = normalized.pathExtension; + NSString *resourceDir = normalized.stringByDeletingLastPathComponent; + if (resourceDir.length == 0) { + resourceDir = nil; + } + assetPath = [[NSBundle mainBundle] pathForResource:resourceName + ofType:resourceExt.length ? resourceExt : nil + inDirectory:resourceDir]; + } + + if (assetPath.length == 0 || ![[NSFileManager defaultManager] fileExistsAtPath:assetPath]) { + reject(kZipErrFileNotFound, + [NSString stringWithFormat:@"Asset file `%@` could not be opened from the app bundle", source], + nil); + return; + } + + [self beginOperation]; + [self runAsync:^{ + [self unzipFile:assetPath destinationPath:target password:nil resolve:resolve reject:reject]; + }]; } - (void)addListener:(NSString *)eventName { diff --git a/package.json b/package.json index d68ed07b..10f2ab3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-zip-archive", - "version": "9.3.0", + "version": "9.4.0", "description": "A TurboModule wrapper on ZipArchive for React Native's New Architecture", "main": "index.js", "scripts": { diff --git a/playground-expo/app/assets.tsx b/playground-expo/app/assets.tsx index ea555ebe..04103b96 100644 --- a/playground-expo/app/assets.tsx +++ b/playground-expo/app/assets.tsx @@ -1,6 +1,5 @@ import React, { useState } from 'react'; import { - View, Text, StyleSheet, ScrollView, @@ -44,26 +43,14 @@ export default function AssetsScreen() { } }; - if (Platform.OS !== 'android') { - return ( - - - - unzipAssets is only available on Android. iOS apps should use the main bundle or other asset mechanisms. - - - - - ); - } - return ( - Android Assets Demo + Bundled Assets Demo - Unzip a pre-bundled asset file (sample.zip) from the Android assets folder. - Make sure sample.zip exists in{' '} - android/app/src/main/assets/. + Unzip a pre-bundled sample.zip + {Platform.OS === 'android' + ? ' from android/app/src/main/assets/.' + : ' from the iOS app bundle (Copy Bundle Resources).'} diff --git a/playground-expo/app/index.tsx b/playground-expo/app/index.tsx index e2aa351e..c7bd72f0 100644 --- a/playground-expo/app/index.tsx +++ b/playground-expo/app/index.tsx @@ -17,7 +17,7 @@ const DEMOS = [ { href: '/password' as const, title: 'Password Protection', desc: 'AES & standard encryption demos' }, { href: '/progress' as const, title: 'Progress Events', desc: 'Real-time zip/unzip progress' }, { href: '/benchmark' as const, title: 'Benchmarks', desc: 'Compare compression levels & speed' }, - { href: '/assets' as const, title: 'Assets (Android)', desc: 'Unzip bundled assets on Android' }, + { href: '/assets' as const, title: 'Bundled Assets', desc: 'Unzip Android assets / iOS bundle resources' }, ]; export default function HomeScreen() { diff --git a/playground-expo/assets/sample.zip b/playground-expo/assets/sample.zip new file mode 100644 index 00000000..e6b08557 Binary files /dev/null and b/playground-expo/assets/sample.zip differ diff --git a/playground-expo/ios/RNZipArchivePlayground.xcodeproj/project.pbxproj b/playground-expo/ios/RNZipArchivePlayground.xcodeproj/project.pbxproj index 4c3440ff..494f9ff8 100644 --- a/playground-expo/ios/RNZipArchivePlayground.xcodeproj/project.pbxproj +++ b/playground-expo/ios/RNZipArchivePlayground.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; }; DBAA7EA6CD08B42E8510EF79 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = EFB54E4CD17F3FB2EC627D4B /* PrivacyInfo.xcprivacy */; }; F11748422D0307B40044C1D9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F11748412D0307B40044C1D9 /* AppDelegate.swift */; }; + A1B2C3D45E6F708192A3B4C5 /* sample.zip in Resources */ = {isa = PBXBuildFile; fileRef = A1B2C3D35E6F708192A3B4C5 /* sample.zip */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -30,6 +31,7 @@ F11748412D0307B40044C1D9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = RNZipArchivePlayground/AppDelegate.swift; sourceTree = ""; }; F11748442D0722820044C1D9 /* RNZipArchivePlayground-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "RNZipArchivePlayground-Bridging-Header.h"; path = "RNZipArchivePlayground/RNZipArchivePlayground-Bridging-Header.h"; sourceTree = ""; }; F3CD0FA6E823EC0EFCAB415A /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-RNZipArchivePlayground/ExpoModulesProvider.swift"; sourceTree = ""; }; + A1B2C3D35E6F708192A3B4C5 /* sample.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; name = sample.zip; path = RNZipArchivePlayground/sample.zip; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -62,6 +64,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */, AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */, EFB54E4CD17F3FB2EC627D4B /* PrivacyInfo.xcprivacy */, + A1B2C3D35E6F708192A3B4C5 /* sample.zip */, ); name = RNZipArchivePlayground; sourceTree = ""; @@ -198,6 +201,7 @@ 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */, DBAA7EA6CD08B42E8510EF79 /* PrivacyInfo.xcprivacy in Resources */, + A1B2C3D45E6F708192A3B4C5 /* sample.zip in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/playground-expo/ios/RNZipArchivePlayground/sample.zip b/playground-expo/ios/RNZipArchivePlayground/sample.zip new file mode 100644 index 00000000..e6b08557 Binary files /dev/null and b/playground-expo/ios/RNZipArchivePlayground/sample.zip differ diff --git a/playground-rn/ios/PlaygroundRN.xcodeproj/project.pbxproj b/playground-rn/ios/PlaygroundRN.xcodeproj/project.pbxproj index 3ecbe55a..22699e98 100644 --- a/playground-rn/ios/PlaygroundRN.xcodeproj/project.pbxproj +++ b/playground-rn/ios/PlaygroundRN.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 97523AD4E6E87C2182825509 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E5EBC47BA2EB7F034C1ACD13 /* main.m */; }; DB69DB97B85F813FDF0E001E /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = B21341DD1A1109A08737F2E2 /* AppDelegate.mm */; }; E0B8E392EC6F22AC59BCBB21 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; }; + F7C3A1B25E9D4A0F8C2B6D11 /* sample.zip in Resources */ = {isa = PBXBuildFile; fileRef = F7C3A1B15E9D4A0F8C2B6D11 /* sample.zip */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -28,6 +29,7 @@ D55102F37F12E8BE1D6159A2 /* libPods-PlaygroundRN.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PlaygroundRN.a"; sourceTree = BUILT_PRODUCTS_DIR; }; E5EBC47BA2EB7F034C1ACD13 /* main.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = main.m; path = PlaygroundRN/main.m; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; + F7C3A1B15E9D4A0F8C2B6D11 /* sample.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; name = sample.zip; path = PlaygroundRN/sample.zip; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -49,6 +51,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */, 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */, + F7C3A1B15E9D4A0F8C2B6D11 /* sample.zip */, ); name = PlaygroundRN; sourceTree = ""; @@ -166,6 +169,7 @@ 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, E0B8E392EC6F22AC59BCBB21 /* PrivacyInfo.xcprivacy in Resources */, + F7C3A1B25E9D4A0F8C2B6D11 /* sample.zip in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/playground-rn/ios/PlaygroundRN/sample.zip b/playground-rn/ios/PlaygroundRN/sample.zip new file mode 100644 index 00000000..e6b08557 Binary files /dev/null and b/playground-rn/ios/PlaygroundRN/sample.zip differ diff --git a/playground-rn/src/screens/AssetsScreen.tsx b/playground-rn/src/screens/AssetsScreen.tsx index fe85fc80..11c4a758 100644 --- a/playground-rn/src/screens/AssetsScreen.tsx +++ b/playground-rn/src/screens/AssetsScreen.tsx @@ -1,6 +1,5 @@ import React, { useState } from 'react'; import { - View, Text, StyleSheet, ScrollView, @@ -44,26 +43,14 @@ export default function AssetsScreen() { } }; - if (Platform.OS !== 'android') { - return ( - - - - unzipAssets is only available on Android. iOS apps should use the main bundle or other asset mechanisms. - - - - - ); - } - return ( - Android Assets Demo + Bundled Assets Demo - Unzip a pre-bundled asset file (sample.zip) from the Android assets folder. - Make sure sample.zip exists in{' '} - android/app/src/main/assets/. + Unzip a pre-bundled sample.zip + {Platform.OS === 'android' + ? ' from android/app/src/main/assets/.' + : ' from the iOS app bundle (Copy Bundle Resources).'} diff --git a/playground-rn/src/screens/HomeScreen.tsx b/playground-rn/src/screens/HomeScreen.tsx index df8cebe5..ebf65148 100644 --- a/playground-rn/src/screens/HomeScreen.tsx +++ b/playground-rn/src/screens/HomeScreen.tsx @@ -31,7 +31,7 @@ const DEMOS = [ { screen: 'Password' as const, title: 'Password Protection', desc: 'AES & standard encryption demos' }, { screen: 'Progress' as const, title: 'Progress Events', desc: 'Real-time zip/unzip progress' }, { screen: 'Benchmark' as const, title: 'Benchmarks', desc: 'Compare compression levels & speed' }, - { screen: 'Assets' as const, title: 'Assets (Android)', desc: 'Unzip bundled assets on Android' }, + { screen: 'Assets' as const, title: 'Bundled Assets', desc: 'Unzip Android assets / iOS bundle resources' }, ]; export default function HomeScreen() {