bamlab/react-native-image-resizer

IOS Build error: Undefined symbol: _kUTTypeJPEG, Undefined symbol: _kUTTypePNG

tautvilas opened this issue · 7 comments

I am getting this build error when building the app with 30.0.0-beta.2 of image-resizer, react-native 0.70 and use_frameworks! setting in Podfile.

Hi @tautvilas !

Do you have the same error if you try to run the example project of this repo ?

I will check, but I see that example project is using RN version 0.68 and no use_frameworks! (which is required for react-native-firebase). It will take some time for me to upgrade example and check.

The solution might be related to this https://stackoverflow.com/questions/13976220/ios-undefined-symbols-for-architecture-i386-kuttypeimage

I have created example project with fresh react-native 0.70.1 install. Other settings:

hermes disabled
flipper disabled
new auth disabled
user_frameworks! set in Podfile

https://github.com/tautvilas/react-native-image-resizer-bug

I have managed to make it work, but had to make multiple adjustments. In Podfile had to add:

$static_framework = ['react-native-image-resizer']
pre_install do |installer|
    installer.pod_targets.each do |pod|
        if $static_framework.include?(pod.name)
          def pod.build_as_static_framework?;
            true
          end
        end
    end
 end

In the react-native code I had to import lib like this:
import * as ImageResizer from '@bam.tech/react-native-image-resizer';

And I had to pass every param to the function or it would crash on ios site with messages like this:
2022-09-20 16:47:31.717352+0300 Spp[89832:3878497] [native] Argument 9 (<null>) of ImageResizer.createResizedImage could not be processed. Aborting method call.

Example of call that works:
await ImageResizer.createResizedImage(uri, 1920, 1920, 'JPEG', 80, 0, null, false, {mode: 'contain', onlyScaleDown: false});

Issue is solved if MobileCoreServices are added to podspec. Please check out how I solved the problem with this commit Discontract@6b28d6c

@tautvilas

Thank you for this information. I'm going to take time this week.
Do you have a reproducible repo example with/without your fix?

And don't forget that contributions are welcome :)

I have added PR with the fix: #338

This is a repo where bug can be reproduced: https://github.com/tautvilas/react-native-image-resizer-bug as I mentioned before : #327 (comment)

Stackoverflow explanation of fix: https://stackoverflow.com/questions/10144961/symbol-not-found-kuttypeimage