1

我们有一个旧的 iOS 目标 C 应用程序。我们想添加“快速”功能。创建了一个单独的“Cocoa touch framework”项目以从“objective C”项目中引用它。当我尝试从目标 c 快速调用/初始化任何方法时出现此错误

ld /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Products/Debug-iphonesimulator/super.app/super normal x86_64 cd /Users/teeboy/iWorkbench/super export IPHONEOS_DEPLOYMENT_TARGET=10.0 export PATH=" /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin: /bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms /iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3。sdk -L/Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Products/Debug-iphonesimulator -F/Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Products/ Debug-iphonesimulator -F/Users/teeboy/iWorkbench/super -filelist /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Intermediates/super.build/Debug-iphonesimulator/super.build/Objects- normal/x86_64/super.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=10.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/teeboy/Library/Developer/Xcode/DerivedData/super- aybvkjtipygrszeyqsnbmtglaaqi/Build/Intermediates/super.build/Debug-iphonesimulator/super.build/Objects-normal/x86_64/super_lto。o -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -all_load -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/teeboy/Library/Developer/Xcode/DerivedData /super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Intermediates/super.build/Debug-iphonesimulator/super.build/super.app。xcent -lz -lPatientSearch -framework MapKit -framework ZipArchive -framework QuartzCore -lMobuleMenuCell -framework OCMockitoIOS -framework Security -lModuleNavigation -lToDoList -framework CoreData -lPatientChart -framework CoreText -framework Crashlytics -framework CoreLocation -lVisitNotes -lDataAccess -lDashboard -framework MobileCoreServices -框架 SystemConfiguration -lframework -lsuperCommon -framework UIKit -framework OCHamcrestIOS -framework Foundation -framework CoreGraphics -Xlinker -dependency_info -Xlinker /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Intermediates/super.build/Debug -iphonesimulator/super.build/Objects-normal/x86_64/super_dependency_info.dat -o /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Products/Debug-iphonesimulator/super.应用程序/超级

架构 x86_64 的未定义符号:“_OBJC_CLASS_$__TtC5utils3zip”,引用自:libDashboard.a(ASLandingPageVC.o) 中的 objc-class-ref ld:未找到架构 x86_64 的符号 clang:错误:链接器命令失败并出现退出代码1(使用 -v 查看调用)

swift 库的名称是“utils”。旧的目标 c 应用程序使用一些其他项目依赖项。抱歉,xcode 的新手。

4

1 回答 1

0

在不确切知道您如何在 Objective-C 应用程序中引用 Swift 框架的情况下,我只能猜测您引用了一个框架二进制文件,该二进制文件是为与您尝试构建应用程序的平台不同的平台构建的。

例如,如果您为设备构建框架,然后在应用程序的构建设置下的框架搜索路径中包含到包含生成的 .framework 目录的目录的路径,然后尝试为模拟器构建应用程序,则会发生这种情况. 如果您使用正确的框架二进制文件(在这种情况下为模拟器构建),它将起作用。

然而,一个更优雅的方法是在你的应用程序中嵌入 Swift 框架。假设框架和应用程序位于不同的项目中,您可能会执行以下操作:

  • 确保框架项目未在 Xcode 中打开。
  • 在 Xcode 中打开应用程序项目。
  • 将框架的 .xcodeproj 从 Finder 拖到 Xcode 中的应用项目中以创建引用。
  • 在 General -> Embedded Binaries 添加你的 Swift .framework。
  • 当您构建应用程序时,Xcode 将为正确的架构构建框架并使用并将其嵌入到您的应用程序中。

有关嵌入框架的更多信息,请参阅https://developer.apple.com/library/content/technotes/tn2435/_index.html。顺便说一句,当链接器失败时,您是否还看到ld有关缺少所需架构的文件的警告?

于 2017-05-05T03:27:12.727 回答