bamlab / react-native-image-resizer

🗻 Resize local images with React Native
MIT License
1.61k stars 347 forks source link

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

Closed tautvilas closed 2 years ago

tautvilas commented 2 years ago

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.

taboulot commented 2 years ago

Hi @tautvilas !

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

tautvilas commented 2 years ago

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

tautvilas commented 2 years ago

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

tautvilas commented 2 years ago

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});

tautvilas commented 2 years ago

Issue is solved if MobileCoreServices are added to podspec. Please check out how I solved the problem with this commit https://github.com/Discontract/react-native-image-resizer/commit/6b28d6cb5a557b6f67e60d6dac931bbe7a9d5b39

taboulot commented 2 years ago

@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 :)

tautvilas commented 2 years ago

I have added PR with the fix: https://github.com/bamlab/react-native-image-resizer/pull/338

This is a repo where bug can be reproduced: https://github.com/tautvilas/react-native-image-resizer-bug as I mentioned before : https://github.com/bamlab/react-native-image-resizer/issues/327#issuecomment-1249091985

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