Cocoapod 库问题:DTCoreText

Cocoapod library issue: DTCoreText

我之前就这个问题提出了一个问题,但我已经清理了项目并从头开始重新启动。

我正在尝试使用 DTCoreText

  1. 我的播客文件:
platform :iOS
pod 'DTCoreText'

^quote 因为出于某种原因编辑器不让我把代码放在那里。

  1. Other Linker Flags: -OjbC -all_load

我得到一长串错误:

Undefined symbols for architecture x86_64:
  "_htmlCreatePushParserCtxt", referenced from:
      -[DTHTMLParser parse] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_htmlCtxtUseOptions", referenced from:
      -[DTHTMLParser parse] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_htmlFreeParserCtxt", referenced from:
      -[DTHTMLParser dealloc] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_htmlParseDocument", referenced from:
      -[DTHTMLParser parse] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_xmlDetectCharEncoding", referenced from:
      -[DTHTMLParser parse] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_xmlParseCharEncoding", referenced from:
      -[DTHTMLParser parse] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_xmlSAX2GetColumnNumber", referenced from:
      -[DTHTMLParser columnNumber] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_xmlSAX2GetLineNumber", referenced from:
      -[DTHTMLParser lineNumber] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_xmlSAX2GetPublicId", referenced from:
      -[DTHTMLParser publicID] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_xmlSAX2GetSystemId", referenced from:
      -[DTHTMLParser systemID] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_xmlSAX2InitHtmlDefaultSAXHandler", referenced from:
      -[DTHTMLParser initWithData:encoding:] in libPods-DTFoundation.a(DTHTMLParser.o)
  "_xmlStopParser", referenced from:
      -[DTHTMLParser abortParsing] in libPods-DTFoundation.a(DTHTMLParser.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这是我第一次尝试使用 Cocoapod,我可能在这里犯了一个菜鸟错误


如果我从项目运行的链接框架中删除 DTFoundation.a 和 DTCoreText.a,但我收到以下错误:

-[NSConcreteMutableAttributedString initWithHTMLData:documentAttributes:]: unrecognized selector sent to instance 

使用他们的示例代码:

#import "DTCoreText.h"

NSString *html = @"<p>Some Text</p>";
NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];

NSAttributedString *attrString = [[NSAttributedString alloc] initWithHTMLData:data
                                                           documentAttributes:NULL];
NSLog(@"%@", attrString);

当我更新播客文件 Jon Suggested 并删除旧的 configs/linker 标志时,我收到此错误:

[!] The `**** [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-****/Pods-****.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `**** [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-****/Pods-****.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

如何重置这些?或者有没有办法告诉它无论如何都要覆盖它?

"Works on my machine."™

您使用的是最新的 CocoaPods 吗? 0.37.1 是最新的,你应该使用它,除非你有特定的理由不这样做。

这个 Podfile 对我来说工作得很好(由 运行 pod init 在项目目录中生成):

platform :ios, '8.3'

target 'DTCoreTextTest' do
  pod 'DTCoreText'
end

target 'DTCoreTextTestTests' do

end

无需添加额外的 -ObjC-all_load 标志。