创建 iOS 框架时未定义符号 OBJC_CLASS_$ [英] Undefined symbol OBJC_CLASS_$ when creating iOS framework

查看:60
本文介绍了创建 iOS 框架时未定义符号 OBJC_CLASS_$的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个 iOS 框架,为此,我使用了一些依赖项,而单独构建框架项目时没有出现错误,当我在演示应用程序中使用 CocoaPods 进行安装时,出现以下错误 未定义符号:_OBJC_CLASS_$_DFPRequest.

I'm trying to build a iOS framework, to this, I'm using some dependencies and while building the framework project alone gives no error, when I install using CocoaPods in a demo app I get the following error Undefined symbol: _OBJC_CLASS_$_DFPRequest.

这就是我在框架中的内容:

So this is what I have in the framework:

Podfile

platform :ios, '10.0'

use_frameworks!

target 'mylib' do  
  pod 'PrebidMobile'
  pod 'Google-Mobile-Ads-SDK'
  pod 'mopub-ios-sdk'
  pod 'GoogleAds-IMA-iOS-SDK'
end

MyLib.podspec

Pod::Spec.new do |s|

    ...

    s.platform      = :ios, "10.0"
    s.swift_version = '5.0'
    
    s.xcconfig = {
        :LIBRARY_SEARCH_PATHS => '$(inherited)',
        :OTHER_CFLAGS => '$(inherited)',
        :OTHER_LDFLAGS => '$(inherited)',
        :HEADER_SEARCH_PATHS => '$(inherited)',
        :FRAMEWORK_SEARCH_PATHS => '$(inherited)'
    }

    s.framework = [
      'CoreTelephony',
      'SystemConfiguration',
      'UIKit',
      'Foundation'
    ]
  
    s.subspec 'core' do |core|
      core.source_files = 'Source/**/*.{h,m,swift}'
    end

    s.dependency 'PrebidMobile'
    s.dependency 'Google-Mobile-Ads-SDK'
    s.dependency 'mopub-ios-sdk'
    s.dependency 'GoogleAds-IMA-iOS-SDK'

  end

Banner.swift

import UIKit
import PrebidMobile
import GoogleMobileAds
import MoPub

enum BannerFormat: Int {
    case html
    case vast
}

class BannerController: UIViewController, GADBannerViewDelegate, MPAdViewDelegate {

   @IBOutlet var appBannerView: UIView!

    @IBOutlet var adServerLabel: UILabel!

    var bannerFormat: BannerFormat = .html
    var adServerName: String = ""

    private var adUnit: AdUnit!
    
    private let amRequest = DFPRequest()
    private var amBanner: DFPBannerView!
    
    private var mpBanner: MPAdView!

    override func viewDidLoad() {
        super.viewDidLoad()
        adServerLabel.text = adServerName
    }

    override func viewDidDisappear(_ animated: Bool) {
        adUnit?.stopAutoRefresh()
    }

    func viewControllerForPresentingModalView() -> UIViewController! {
        return self
    }

}

现在在 appdemo 中,我有

Now in the appdemo, I have

Podfile

platform :ios, '10.0'
use_frameworks!
target 'appdemo (iOS)' do
  pod 'MyLib', :git => 'https://...mylib.git'
end

所以,只需运行 pod install &&pod update 并构建 appdemo 我已经收到错误.

So, just by running pod install && pod update and building the appdemo I already got the error.

由于单独运行框架有效,我在这里做错了什么,安装框架不起作用?

Since running the framework alone works, what am I doing wrong here that installing the framework does not work?

LD/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mylib/mylib.framework/mylib正常(在项目Pods"的目标mylib"中)cd/Users/user/appdemo/Pods/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-target x86_64-apple-ios10.0-simulator -dynamiclib -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk-L/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mylib-F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mylib-F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/GoogleUtilities-F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/PrebidMobile-F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/PromisesObjC-F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mopub-ios-sdk-F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/nanopb-F/Users/user/appdemo/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current-F/Users/user/appdemo/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current/GoogleMobileAds.xcframework/ios-arm64_armv7-F/Users/user/appdemo/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current/GoogleMobileAds.xcframework/ios-arm64_i386_x86_64-simulator-F/Users/user/appdemo/Pods/GoogleAds-IMA-iOS-SDK -F/Users/user/appdemo/Pods/GoogleAppMeasurement/Frameworks -F/Users/user/appdemo/Pods/GoogleUserMessagingPlatform/Frameworks/Release-F/Users/user/appdemo/Pods/GoogleUserMessagingPlatform/Frameworks/Release/UserMessagingPlatform.xcframework/ios-arm64_armv7-F/Users/user/appdemo/Pods/GoogleUserMessagingPlatform/Frameworks/Release/UserMessagingPlatform.xcframework/ios-arm64_i386_x86_64-simulator-filelist/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mylib.build/Objects-normal/x86_64/mylib.LinkFileList-install_name @rpath/mylib.framework/mylib -Xlinker -rpath -Xlinker/usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks-Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Intermediates.noindex/Podsim.build/.build/Objects-normal/x86_64/mylib_lto.o-Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphone模拟器-L/usr/lib/swift -Xlinker -add_ast_path -Xlinker/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mylib.build/Objects-normal/x86_64/mylib.swiftmodule-framework AVFoundation -framework AdSupport -framework AudioToolbox -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreMedia -framework CoreTelephony -framework CoreVideo -framework Foundation -framework GoogleInteractiveMediaAds -framework MediaPlayer -framework MessageUI -framework MobileCoreServices-framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -framework UIKit -framework WebKit -weak_framework AdSupport -weak_framework JavaScriptCore -weak_framework SafariServices -weak_framework StoreKit -weak_framework WebKit -framework CoreTelephony -framework Foundation -framework MoPub -framework System PrebidUIKit -Xlinker -no_adhoc_codesign-compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mynormal.build//x86_64/mylib_dependency_info.dat-o/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mylib/mylib.framework/mylib

Ld /Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mylib/mylib.framework/mylib normal (in target 'mylib' from project 'Pods') cd /Users/user/appdemo/Pods /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios10.0-simulator -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk -L/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mylib -F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mylib -F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/GoogleUtilities -F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/PrebidMobile -F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/PromisesObjC -F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mopub-ios-sdk -F/Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/nanopb -F/Users/user/appdemo/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current -F/Users/user/appdemo/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current/GoogleMobileAds.xcframework/ios-arm64_armv7 -F/Users/user/appdemo/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current/GoogleMobileAds.xcframework/ios-arm64_i386_x86_64-simulator -F/Users/user/appdemo/Pods/GoogleAds-IMA-iOS-SDK -F/Users/user/appdemo/Pods/GoogleAppMeasurement/Frameworks -F/Users/user/appdemo/Pods/GoogleUserMessagingPlatform/Frameworks/Release -F/Users/user/appdemo/Pods/GoogleUserMessagingPlatform/Frameworks/Release/UserMessagingPlatform.xcframework/ios-arm64_armv7 -F/Users/user/appdemo/Pods/GoogleUserMessagingPlatform/Frameworks/Release/UserMessagingPlatform.xcframework/ios-arm64_i386_x86_64-simulator -filelist /Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mylib.build/Objects-normal/x86_64/mylib.LinkFileList -install_name @rpath/mylib.framework/mylib -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mylib.build/Objects-normal/x86_64/mylib_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mylib.build/Objects-normal/x86_64/mylib.swiftmodule -framework AVFoundation -framework AdSupport -framework AudioToolbox -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreMedia -framework CoreTelephony -framework CoreVideo -framework Foundation -framework GoogleInteractiveMediaAds -framework MediaPlayer -framework MessageUI -framework MobileCoreServices -framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -framework UIKit -framework WebKit -weak_framework AdSupport -weak_framework JavaScriptCore -weak_framework SafariServices -weak_framework StoreKit -weak_framework WebKit -framework CoreTelephony -framework Foundation -framework MoPub -framework PrebidMobile -framework SystemConfiguration -framework UIKit -Xlinker -no_adhoc_codesign -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mylib.build/Objects-normal/x86_64/mylib_dependency_info.dat -o /Users/user/Library/Developer/Xcode/DerivedData/appdemo-gmoqpiaozrywmeguhfldbwybeebb/Build/Products/Debug-iphonesimulator/mylib/mylib.framework/mylib

架构 x86_64 的未定义符号:
OBJC_CLASS$_DFPRequest",引用自:Banner.o ld 中的 objc-class-ref:找不到架构 x86_64 clang 的符号:错误:链接器命令失败,退出代码1(使用 -v 查看调用)

Undefined symbols for architecture x86_64:
"OBJC_CLASS$_DFPRequest", referenced from: objc-class-ref in Banner.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

推荐答案

因为单独运行框架是可行的

Since running the framework alone works

我不是 100% 确定我理解这一点;你不能跑"一个框架.如果您的意思是框架构建,那并不奇怪;缺少的符号来自不同的库,在您的框架最终链接到应用程序之前不必解决这个问题.

I'm not 100% sure I understand this; you can't "run" a framework alone. If you mean that the framework builds, that's not surprising; the missing symbol is from a different library, and that doesn't have to be resolved until your framework is eventually linked into an application.

我在这里做错了什么,安装框架不起作用?

what am I doing wrong here that installing the framework does not work?

很难确定,但我敢打赌这可能与您应用的 Podfile 有关:

Hard to say for certain, but I'd bet that it might have something to do with your app's Podfile:

pod 'MyLib', :git =>'https://...mylib.git'

pod 'MyLib', :git => 'https://...mylib.git'

MyLib 的 podspec 应该在那个 repo 的根目录中,所以检查 URL 指向你认为它的位置,MyLib.podspec 在该存储库的根目录,并且 podspec 是正确的.

The podspec for MyLib should be in the root directory of that repo, so check that the URL points to where you think it does, that MyLib.podspec is in the root of that repository, and that the podspec is correct.

运行 pod install,然后运行 ​​pod update(在故障排除时单独运行它们是一个好主意,这样您就可以确定哪个产生了任何错误或其他输出).打开应用程序的工作区并找到定义 DFPRequest 类的文件.如果找不到,则需要深入研究 Pod 设置以找出问题所在.如果您确实找到了该文件,那么您的 pod 设置可能没问题;相反,请检查您的项目配置并确保该文件确实包含在您尝试构建的目标中.

Run pod install and then pod update (running them separately is a good idea when troubleshooting so that you know for certain which one produced any errors or other output). Open up your app's workspace and find the file that defines the DFPRequest class. If you can't find it, you'll need to dig deeper into your pods setup to figure out what the problem is. If you do find the file, then your pods setup is probably OK; instead, check your project configuration and make sure that the file is actually included in the target you're trying to build.

这篇关于创建 iOS 框架时未定义符号 OBJC_CLASS_$的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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