Skip to content

Commit

Permalink
Fix invertase#2698: Build fails when targeting Mac (Project Catalyst)
Browse files Browse the repository at this point in the history
The Catalyst SDK does not support `assets-library://` URLs, which have been deprecated for many years. This patch fixes the build failure when compiling with the Catalyst SDK; requests for such assets will fail and log (the first time).
  • Loading branch information
andymatuschak authored Jun 26, 2020
1 parent a6dc460 commit 90562e0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/app/ios/RNFBApp/RNFBUtilsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ + (PHAsset *)fetchAssetForPath:(NSString *)localFilePath {
if ([localFilePath hasPrefix:@"assets-library://"] || [localFilePath hasPrefix:@"ph://"]) {
if ([localFilePath hasPrefix:@"assets-library://"]) {
NSURL *localFile = [[NSURL alloc] initWithString:localFilePath];
#if TARGET_OS_MACCATALYST
static BOOL hasWarned = NO;
if (!hasWarned) {
NSLog(@"assets-library:// URLs are not supported in Catalyst-based targets; returning nil (future warnings will be suppressed)");
hasWarned = YES;
}
asset = nil;
#else
asset = [[PHAsset fetchAssetsWithALAssetURLs:@[localFile] options:nil] firstObject];
#endif
} else {
NSString *assetId = [localFilePath substringFromIndex:@"ph://".length];
asset = [[PHAsset fetchAssetsWithLocalIdentifiers:@[assetId] options:nil] firstObject];
Expand Down Expand Up @@ -91,4 +100,4 @@ - (NSDictionary *)constantsToExport {
return constants;
}

@end
@end

0 comments on commit 90562e0

Please sign in to comment.