From 90562e03b8f8b5ab4e168f59525293862c419414 Mon Sep 17 00:00:00 2001 From: Andy Matuschak Date: Thu, 25 Jun 2020 20:01:00 -0700 Subject: [PATCH] Fix #2698: Build fails when targeting Mac (Project Catalyst) 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). --- packages/app/ios/RNFBApp/RNFBUtilsModule.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/app/ios/RNFBApp/RNFBUtilsModule.m b/packages/app/ios/RNFBApp/RNFBUtilsModule.m index f43b9b67d0..6feb422d84 100644 --- a/packages/app/ios/RNFBApp/RNFBUtilsModule.m +++ b/packages/app/ios/RNFBApp/RNFBUtilsModule.m @@ -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]; @@ -91,4 +100,4 @@ - (NSDictionary *)constantsToExport { return constants; } -@end \ No newline at end of file +@end