【问题标题】:Adding OpenTok framework to my project将 OpenTok 框架添加到我的项目中
【发布时间】:2026-01-20 01:40:01
【问题描述】:

所以我正在尝试将 OpenTok 框架添加到我的代码中。我正在从https://tokbox.com/developer/sdks/ios/ 下载 IOS SDK,然后将 opentok.framwork 文件拖到我的框架列表中。当我构建我的代码时,它会因为这个错误而失败:

Ld /Users/hussein/Library/Developer/Xcode/DerivedData/SocieteGeneral-hiagtpmptjkrqjbabjxpjmnshezi/Build/Intermediates/SocieteGeneral.build/Debug-iphoneos/SocieteGeneral.build/Objects-normal/arm64/SocieteGeneral normal arm64
cd /Users/hussein/Projects/ios-client
export IPHONEOS_DEPLOYMENT_TARGET=5.1.1
export PATH="/Applications/Xcode 2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode 2.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode\ 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /Applications/Xcode\ 2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -L/Users/hussein/Library/Developer/Xcode/DerivedData/SocieteGeneral-hiagtpmptjkrqjbabjxpjmnshezi/Build/Products/Debug-iphoneos -L/opt/vagrant/embedded/lib -F/Users/hussein/Library/Developer/Xcode/DerivedData/SocieteGeneral-hiagtpmptjkrqjbabjxpjmnshezi/Build/Products/Debug-iphoneos -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -F/Users/hussein/Projects/ios-client -filelist /Users/hussein/Library/Developer/Xcode/DerivedData/SocieteGeneral-hiagtpmptjkrqjbabjxpjmnshezi/Build/Intermediates/SocieteGeneral.build/Debug-iphoneos/SocieteGeneral.build/Objects-normal/arm64/SocieteGeneral.LinkFileList -miphoneos-version-min=5.1.1 -dead_strip -force_load -ObjC -mthumb -fobjc-arc -lsqlite3.0 -fobjc-arc -fobjc-link-runtime -framework GLKit -framework VideoToolbox -framework OpenTok -liconv -lstdc++.6.0.9 -lsqlite3 -framework LocalAuthentication /Users/hussein/Library/Developer/Xcode/DerivedData/SocieteGeneral-hiagtpmptjkrqjbabjxpjmnshezi/Build/Products/Debug-iphoneos/libCorePlot-CocoaTouch.a -framework MobileCoreServices -framework CoreText -weak_framework AdSupport -framework CoreAudio -weak_framework Social -framework QuartzCore -framework CoreGraphics -weak_framework Accounts -framework AddressBook -framework AddressBookUI -framework AudioToolbox -framework CFNetwork -framework CoreVideo -framework ImageIO -framework Foundation -framework MessageUI -framework OpenGLES -framework Twitter -framework AVFoundation -framework CoreMedia -framework CoreData -framework CoreFoundation -framework MapKit -framework CoreLocation -framework CoreTelephony -framework Security -framework SystemConfiguration -framework UIKit -Xlinker -dependency_info -Xlinker /Users/hussein/Library/Developer/Xcode/DerivedData/SocieteGeneral-hiagtpmptjkrqjbabjxpjmnshezi/Build/Intermediates/SocieteGeneral.build/Debug-iphoneos/SocieteGeneral.build/Objects-normal/arm64/SocieteGeneral_dependency_info.dat -o /Users/hussein/Library/Developer/Xcode/DerivedData/SocieteGeneral-hiagtpmptjkrqjbabjxpjmnshezi/Build/Intermediates/SocieteGeneral.build/Debug-iphoneos/SocieteGeneral.build/Objects-normal/arm64/SocieteGeneral

ld: file not found: -ObjC
clang: error: linker command failed with exit code 1 (use -v to see invocation)

【问题讨论】:

  • 你能用 cocoaPods 吗?
  • 我尝试用 cocoaPods 安装它,但仍然遇到同样的错误!

标签: ios objective-c xcode frameworks opentok


【解决方案1】:

好的,问题有点复杂: 当您在项目中拖动库时,您会弄乱链接器的标志(您可以在 Build Phase -> Other Linker Flags 中看到它们),现在当 cocoaPods 成功添加 OpenTok 时(我试过了,我没有错误)它仍然有标志(有错误)。 现在是复杂的部分:很难知道哪些标志会导致问题。

(即使您删除 -Objc 标志,问题也可能来自其他标志,因为: 你得到一些继承, 你的项目可能需要这个标志, 修改它们可能会产生其他错误 等等等等) ,并且无法在 xCode 中“重置”您的标志。

所以最好的解决方案是:创建一个新项目,添加 cocoapods OpenTok

platform :ios, '8.0'
use_frameworks!

target 'app' do
pod 'OpenTok', '~> 2.6'
end

target 'appTests' do
pod 'OpenTok', '~> 2.6'
end

target 'appUITests' do
pod 'OpenTok', '~> 2.6'
end

还有我的桥接导入:

#import "OpenTok/OpenTok.h"

用默认设置和cocoapod查看新项目是否还有错误,如果没有则将你之前的项目文件拖到新项目中

【讨论】:

  • 感谢您的回答,但我认为您的建议不可行。我试图添加它的项目也是一个具有多个目标的巨大项目。我不能简单地将我的文件拖到新项目中!
  • 你在添加 OpenTok 框架之前保存了项目吗?
【解决方案2】:

尝试在构建设置中添加其他LinkerFlags

试试这个!并检查部署目标是否为 iOS 8.0 或更高版本。

【讨论】:

    【解决方案3】:

    由于启用位码,您可能会收到此错误。 尝试将启用位码设置为“否”

    转到目标 -> 构建设置 -> 搜索“启用位码” -> 设置为“否”

    这解决了我的问题。

    【讨论】: