Skip to content

Commit 4f1adc8

Browse files
fix: macOS UIImage build issues (#2862)
# Summary Really simple change to get skia running on macOS, I noticed this while testing BareExpo in the expo/expo repo. Just add a `!TARGET_OS_OSX` check and use `NSImage` ## Test Plan Run fabric-macos-example on macOS <img width="1392" height="864" alt="image" src="https://github.com/user-attachments/assets/199d860b-7722-4afd-90a7-9741d8fe9034" /> ## Compatibility | OS | Implemented | | ------- | :---------: | | MacOS | ✅ | ## Checklist <!-- Check completed item, when applicable, via: [X] --> - [x] I have tested this on a device and a simulator - [ ] I added documentation in `README.md` - [ ] I updated the typed files (typescript) - [ ] I added a test for the API in the `__tests__` folder --------- Co-authored-by: Jakub Grzywacz <[email protected]>
1 parent 99cc75d commit 4f1adc8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

apple/Elements/RNSVGImage.mm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ - (void)_setStateAndResubscribeImageResponseObserver:(RNSVGImageShadowNode::Conc
130130
}
131131

132132
#pragma mark - RCTImageResponseDelegate
133-
133+
#if !TARGET_OS_OSX // [macOS]
134134
- (void)didReceiveImage:(UIImage *)image metadata:(id)metadata fromObserver:(void const *)observer
135+
#else // [macOS
136+
- (void)didReceiveImage:(NSImage *)image metadata:(id)metadata fromObserver:(void const *)observer
137+
#endif // macOS]
135138
{
136139
if (!_eventEmitter || !_state) {
137140
// Notifications are delivered asynchronously and might arrive after the view is already recycled.
@@ -233,7 +236,11 @@ - (void)setSrc:(RCTImageSource *)src
233236

234237
_reloadImageCancellationBlock = [[self.bridge moduleForName:@"ImageLoader"]
235238
loadImageWithURLRequest:src.request
239+
#if !TARGET_OS_OSX // [macOS]
236240
callback:^(__unused NSError *error, UIImage *image) {
241+
#else // [macOS
242+
callback:^(__unused NSError *error, NSImage *image) {
243+
#endif // macOS]
237244
dispatch_async(dispatch_get_main_queue(), ^{
238245
self->_image = CGImageRetain(image.CGImage);
239246
self->_imageSize = CGSizeMake(CGImageGetWidth(self->_image), CGImageGetHeight(self->_image));

0 commit comments

Comments
 (0)