iOS Build fails when using vImage_CGImageFormat(cgImage: CGImage), even with target=13.0

I'm getting a build error when attempting to use the function vImage_CGImageFormat(cgImage: CGImage), which the documentation indicates is only available >= ios 13.0. I also get errors if I try to use any other vImage function that is only available >- ios 13.0.

I set the "iOS Deployment Target" to "iOS 13.0", but the error persists. I also tried cleaning and rebuilding.

This is the exact error:

Undefined symbol: (extension in Accelerate):C.vImageCGImageFormat.init(cgImage: C.CGImageRef) -> C.vImageCGImageFormat?

This is demo code that's causing the build error:
Code Block language
import Foundation
import Accelerate.vImage
import CoreGraphics
class ImageProcessor : NSObject {
@objc func resizeImg(img: UIImage) -> UIImage? {
guard var format = vImage_CGImageFormat(cgImage: img.cgImage!) else {
print("Unable to create format.")
return nil
}
return img
}
}


Interestingly, the XCode doesn't detect the error until building.

My environment:
XCode 12.5
MacOS 10.15.17
Swift 5

If I create a new project with these same settings the build works fine, so there must be something else in my main project that is causing the iOS 13+ methods to be excluded. Is there another target setting that needs to be changed? Could it be related to other pods I have in the project? I'd appreciate any help. Thanks!
Sorry, but I cannot reproduce the same issue in any build settings with Xcode 12.3.
(I know you say "If I create a new project with these same settings the build works fine".)

First of all, your demo code causes another error on line 7:
Code Block
Cannot find type 'UIImage' in scope

I doubt if it is the actual code which causes the error: Undefined symbol.
When shown code too simplified, it does not help solving your issue.

And the latest version of Xcode currently is 12.3. 12.5 is not yet even in beta.


Could it be related to other pods I have in the project?

Very likely, but not sure.

Starting from your the build works fine project, add pods (or other things in your causing the build error project) one by one and see what happens.


Thanks for your quick reply @OOPer. My mistake- I left out the import of UIKit in the Swift code which caused your error in the demo. Also I'm X-Code 12.3, not sure where I saw 12.5, sorry about that.

I'm still not sure what's causing this issue but it appears to be related to react-native, as I'm seeing the error on a newly created RN project with the above Swift file added.

I created a ticket on the RN issue tracker, so hopefully it will be addressed there. However, I am curious as to how pods could cause this issue. If I set the iOS deployment target to 13.0 shouldn't that force the iOS-13.0 functionality in the Accelerate framework to be built?

Thanks for your help.

I am curious as to how pods could cause this issue.

I do not know what the pod of react-native is doing. (Sorry, I have never used it.)
But may pods includes numbers of hacks to achieve something which is not supported by Xcode.

If I set the iOS deployment target to 13.0 shouldn't that force the iOS-13.0 functionality in the Accelerate framework to be built? 

True, if no pods are used.
iOS Build fails when using vImage_CGImageFormat(cgImage: CGImage), even with target=13.0
 
 
Q