【问题标题】:Xcode can't find interface declaration after running "pod install"运行“pod install”后 Xcode 找不到接口声明
【发布时间】:2017-03-25 04:57:42
【问题描述】:

我继承了一个使用 cocoapods 的 iOS 项目。

repo 包含 Pods 目录,其中所有必要的 pod 都及时冻结。如果我克隆 repo 并构建应用程序,一切都很好。如果我运行pod update 然后构建,我会得到一个错误:

找不到 COOperation 的接口声明。

问题似乎与一个名为 CompositeOperations 的库有关,它是从特定的 git 帐户中提取的(不是直接从 cocoapods 中提取的——不确定这是否重要,但只是试图提供尽可能多的信息)。 Xcode 可以很好地找到该库,但由于某种原因,它没有加载接口文件中声明的类。

在 repo 中包含 Pods 目录对我来说似乎很愚蠢。我觉得开发人员应该克隆 repo,然后发出 git install 以取消所有依赖项。

对于我需要调整什么以使 Xcode 成功构建我的项目有什么建议吗?

MessageScreenDataFetchOperation.h 中的实际错误是:

/Users/user/src/myapp/myapp-iOS/Classes/Shared/Operations/MessageScreenDataFetchOperation.h:13:46: 找不到“COOperation”的接口声明,超类 'MessageScreenDataFetchOperation';你的意思是“NSOperation”吗?

这就是MessageScreenDataFetchOperation.h 的样子:

#import <CompositeOperations/COOperation.h>

@protocol GroupRef;

@interface MessageScreenDataFetchOperation : COOperation
- (id)initWithMessageId:(NSNumber *)messageId group:(id <GroupRef>)groupRef memberId:(NSNumber *)memberId;
@end

这是我的 Podfile:

platform :ios, '8.0'

source 'https://github.com/CocoaPods/Specs.git'

target :MyTarget do
  pod 'RestKit', '~> 0.24.0'
  pod 'CompositeOperations', :git => 'https://github.com/stanislaw/CompositeOperations.git'

  pod 'MBProgressHUD', '~> 0.8'
  pod 'EKKeyboardAvoiding', '~> 2.0'
  pod 'RBStoryboardLink', '0.1.0'
  pod 'SWRevealViewController', '~> 2.0.0'
  pod 'youtube-ios-player-helper', :git => 'https://github.com/stanislaw/youtube-ios-player-helper', :branch => '0.1.1-and-no-ads'
  pod 'SZTextView'

  pod 'MagicKit', :git => 'https://github.com/stanislaw/MagicKit'
  pod 'ECPhoneNumberFormatter', :git => 'https://github.com/enriquez/ECPhoneNumberFormatter.git'
  pod 'SSKeychain'
  pod 'Mantle'
  pod 'RSEnvironment', :git => 'https://github.com/rabovik/RSEnvironment'

  pod 'FBSDKCoreKit'
  pod 'FBSDKLoginKit'
  pod 'FBSDKShareKit'

  # Analytics
  pod 'FlurrySDK', '5.1.0'
  pod 'Fabric'
  pod 'Crashlytics'

  pod 'NewRelicAgent'

  # Logging
  pod 'EchoLogger', :git => 'https://github.com/stanislaw/EchoLogger'
  pod 'AFNetworkingLogger', :git => 'https://github.com/stanislaw/AFNetworkingLogger'
end

target :MyTargetUnitTests do
  pod 'OCMock', '~> 3.0'
  pod 'Kiwi'
  pod 'JPSimulatorHacks', :git => 'https://github.com/plu/JPSimulatorHacks'
end

【问题讨论】:

  • 您可能应该显示您的 pod 文件、相关声明以及您如何导入 lib...
  • 感谢@l'L'l,我已经粘贴了上面的所有内容。

标签: ios objective-c xcode cocoapods


【解决方案1】:

您是否尝试过在不使用 pod 的情况下添加 CompositeOperations?那个豆荚对 cocoapods 来说似乎已经过时了: https://cocoapods.org/?q=CompositeOperations

【讨论】:

    【解决方案2】:

    原来嵌入到 Xcode 项目中的版本是一个更旧的版本。 Podfile 不受版本号的限制,因此运行 'pod update' 会将库更新到最新版本,该版本有重大更改,使其与我的代码库不兼容。

    我在运行pod update 后通过比较Podfile.lock 并注意到版本之间的巨大差异来解决这个问题。

    我继续删除 Pods 目录和 .xcworkspace 文件,但修改了 Podile 以根据特定标签限制库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-28
      • 2011-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-26
      • 2011-03-26
      相关资源
      最近更新 更多