Swift链接器错误:肯定可用的API表示形式的未定义符号 [英] Swift linker error: Undefined symbol for surely available API presentationDimensions

查看:92
本文介绍了Swift链接器错误:肯定可用的API表示形式的未定义符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用 presentationDimensions的相机应用(...)API :

if #available(iOS 13.0, *) {
  let leftVideo = self.formatDescription.presentationDimensions()
  let rightVideo = other.formatDescription.presentationDimensions()
  // ...
}

现在,当我尝试构建项目时,出现以下错误:

Now when I try to build the project, I get the following errors:

未定义符号:(在CoreMedia中的扩展名):__ C.CMFormatDescriptionRef.presentationDimensions(usePixelAspectRatio:Swift.Bool,useCleanAperture:Swift.Bool)->__C.CGSize

这是最后一个Xcode日志(错误):

Here's the last Xcode log (error):

Ld /Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/VisionCameraExample.app/VisionCameraExample normal (in target 'VisionCameraExample' from project 'VisionCameraExample')
    cd /Users/mrousavy/Projects/react-native-vision-camera/example/ios
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios12.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/CocoaAsyncSocket -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/DoubleConversion -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/FBReactNativeSpec -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/Flipper -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/Flipper-DoubleConversion -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/Flipper-Folly -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/Flipper-Glog -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/Flipper-PeerTalk -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/Flipper-RSocket -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/FlipperKit -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/Folly -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/RCTTypeSafety -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-Core -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-CoreModules -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-RCTAnimation -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-RCTBlob -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-RCTImage -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-RCTLinking -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-RCTNetwork -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-RCTSettings -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-RCTText -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-RCTVibration -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-cxxreact -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-jsi -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-jsiexecutor -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/React-jsinspector -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/ReactCommon -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/Yoga -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/YogaKit -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/glog -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/libevent -L/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/react-native-vision-camera -F/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos -F/Users/mrousavy/Projects/react-native-vision-camera/example/ios/Pods/OpenSSL-Universal/Frameworks -F/Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/OpenSSL -filelist /Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Intermediates.noindex/VisionCameraExample.build/Debug-iphoneos/VisionCameraExample.build/Objects-normal/arm64/VisionCameraExample.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Intermediates.noindex/VisionCameraExample.build/Debug-iphoneos/VisionCameraExample.build/Objects-normal/arm64/VisionCameraExample_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Intermediates.noindex/VisionCameraExample.build/Debug-iphoneos/VisionCameraExample.build/Objects-normal/arm64/VisionCameraExample.swiftmodule -ObjC -lCocoaAsyncSocket -lDoubleConversion -lFBReactNativeSpec -lFlipper -lFlipper-DoubleConversion -lFlipper-Folly -lFlipper-Glog -lFlipper-PeerTalk -lFlipper-RSocket -lFlipperKit -lFolly -lRCTTypeSafety -lReact-Core -lReact-CoreModules -lReact-RCTAnimation -lReact-RCTBlob -lReact-RCTImage -lReact-RCTLinking -lReact-RCTNetwork -lReact-RCTSettings -lReact-RCTText -lReact-RCTVibration -lReact-cxxreact -lReact-jsi -lReact-jsiexecutor -lReact-jsinspector -lReactCommon -lYoga -lYogaKit -lglog -llibevent -lreact-native-vision-camera -lstdc++ -framework AudioToolbox -framework CFNetwork -framework JavaScriptCore -framework MobileCoreServices -framework OpenSSL -framework Security -framework UIKit -ObjC -lc++ -lPods-VisionCameraExample -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Intermediates.noindex/VisionCameraExample.build/Debug-iphoneos/VisionCameraExample.build/Objects-normal/arm64/VisionCameraExample_dependency_info.dat -o /Users/mrousavy/Library/Developer/Xcode/DerivedData/VisionCameraExample-aeiaddcztqvxgygupinrzjkkdodr/Build/Products/Debug-iphoneos/VisionCameraExample.app/VisionCameraExample

Undefined symbols for architecture arm64:
  "(extension in CoreMedia):__C.CMFormatDescriptionRef.presentationDimensions(usePixelAspectRatio: Swift.Bool, useCleanAperture: Swift.Bool) -> __C.CGSize", referenced from:
      (extension in react_native_vision_camera):__C.AVCaptureDeviceFormat.isBetterThan(__C.AVCaptureDeviceFormat) -> Swift.Bool in libreact-native-vision-camera.a(AVCaptureDevice.Format+isBetterThan.o)
      (extension in react_native_vision_camera):__C.AVCaptureDeviceFormat.matchesFilter(__C.NSDictionary) -> Swift.Bool in libreact-native-vision-camera.a(AVCaptureDevice.Format+matchesFilter.o)
      (extension in react_native_vision_camera):__C.AVCaptureDeviceFormat.toDictionary() -> [Swift.String : Any] in libreact-native-vision-camera.a(AVCaptureDevice.Format+toDictionary.o)
     (maybe you meant: default argument 1 of (extension in CoreMedia):__C.CMFormatDescriptionRef.presentationDimensions(usePixelAspectRatio: Swift.Bool, useCleanAperture: Swift.Bool) -> __C.CGSize, default argument 0 of (extension in CoreMedia):__C.CMFormatDescriptionRef.presentationDimensions(usePixelAspectRatio: Swift.Bool, useCleanAperture: Swift.Bool) -> __C.CGSize )
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我的.pbxproj(剥离了不相关的部分,例如Release config等):

My .pbxproj (stripped irrelevant parts such as Release config etc):

// ...

/* Begin XCBuildConfiguration section */
        13B07F941A680F5B00A75B9A /* Debug */ = {
            isa = XCBuildConfiguration;
            baseConfigurationReference = 47F7ED3B7971BE374F7B8635 /* Pods-VisionCameraExample.debug.xcconfig */;
            buildSettings = {
                ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
                CLANG_ENABLE_MODULES = YES;
                CURRENT_PROJECT_VERSION = 1;
                DEVELOPMENT_TEAM = CJW62Q77E7;
                ENABLE_BITCODE = NO;
                INFOPLIST_FILE = VisionCameraExample/Info.plist;
                LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
                OTHER_LDFLAGS = (
                    "$(inherited)",
                    "-ObjC",
                    "-lc++",
                );
                PRODUCT_BUNDLE_IDENTIFIER = com.example.reactnativevisioncamera;
                PRODUCT_NAME = VisionCameraExample;
                SWIFT_OBJC_BRIDGING_HEADER = "VisionCameraExample-Bridging-Header.h";
                SWIFT_OPTIMIZATION_LEVEL = "-Onone";
                SWIFT_VERSION = 5.0;
                VERSIONING_SYSTEM = "apple-generic";
            };
            name = Debug;
        };

// ...

        83CBBA201A601CBA00E9B192 /* Debug */ = {
            isa = XCBuildConfiguration;
            buildSettings = {
                ALWAYS_SEARCH_USER_PATHS = NO;
                CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
                CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
                CLANG_CXX_LIBRARY = "libc++";
                CLANG_ENABLE_MODULES = YES;
                CLANG_ENABLE_OBJC_ARC = YES;
                CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
                CLANG_WARN_BOOL_CONVERSION = YES;
                CLANG_WARN_COMMA = YES;
                CLANG_WARN_CONSTANT_CONVERSION = YES;
                CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
                CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
                CLANG_WARN_EMPTY_BODY = YES;
                CLANG_WARN_ENUM_CONVERSION = YES;
                CLANG_WARN_INFINITE_RECURSION = YES;
                CLANG_WARN_INT_CONVERSION = YES;
                CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
                CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
                CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
                CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
                CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
                CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
                CLANG_WARN_STRICT_PROTOTYPES = YES;
                CLANG_WARN_SUSPICIOUS_MOVE = YES;
                CLANG_WARN_UNREACHABLE_CODE = YES;
                CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
                "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
                COPY_PHASE_STRIP = NO;
                ENABLE_STRICT_OBJC_MSGSEND = YES;
                ENABLE_TESTABILITY = YES;
                GCC_C_LANGUAGE_STANDARD = gnu99;
                GCC_DYNAMIC_NO_PIC = NO;
                GCC_NO_COMMON_BLOCKS = YES;
                GCC_OPTIMIZATION_LEVEL = 0;
                GCC_PREPROCESSOR_DEFINITIONS = (
                    "DEBUG=1",
                    "$(inherited)",
                );
                GCC_SYMBOLS_PRIVATE_EXTERN = NO;
                GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
                GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
                GCC_WARN_UNDECLARED_SELECTOR = YES;
                GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
                GCC_WARN_UNUSED_FUNCTION = YES;
                GCC_WARN_UNUSED_VARIABLE = YES;
                IPHONEOS_DEPLOYMENT_TARGET = 12.0;
                LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
                LIBRARY_SEARCH_PATHS = (
                    "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
                    "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
                    "\"$(inherited)\"",
                );
                MTL_ENABLE_DEBUG_INFO = YES;
                ONLY_ACTIVE_ARCH = YES;
                SDKROOT = iphoneos;
            };
            name = Debug;
        };

// ...

请注意,当我删除对presentationDimensions的调用时,一切正常.

Note that when I remove those calls to presentationDimensions everything works fine.

有人可以在这里帮助我吗?该API自iOS 13.0起就可用,即使我的iOS部署目标是11.0,我仍然应该能够构建它,不是吗?

Can anyone help me out here? The API has been available since iOS 13.0, and even if my iOS deployment target is 11.0 I should still be able to build it, no?

推荐答案

最终找到了答案.我将 SWIFT_VERSION 固定为5.0,但是iOS 13附带了Swift 5.2,因此将Swift固定为5.2(并删除了指向5.0的 LIBRARY_SEARCH_PATH )解决了该问题.

Finally found the answer. I had SWIFT_VERSION pinned to 5.0, but iOS 13 came with Swift 5.2 so pinning Swift to 5.2 (and removing the LIBRARY_SEARCH_PATH pointing to 5.0) solved it.

这就是说,

                LIBRARY_SEARCH_PATHS = (
                    "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
                    "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
                    "\"$(inherited)\"",
                );
                SWIFT_VERSION = 5.0;

应如下所示:

                LIBRARY_SEARCH_PATHS = (
                    "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
                    "\"$(inherited)\"",
                );
                SWIFT_VERSION = 5.2;

耶稣基督.

这篇关于Swift链接器错误:肯定可用的API表示形式的未定义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆