【问题标题】:Cocoapod library issue: DTCoreTextCocoapod 库问题:DTCoreText
【发布时间】:2015-07-20 19:45:59
【问题描述】:

我早些时候就这个问题提出了一个问题,但我已经清理了项目并从头开始。

我正在尝试使用 DTCoreText

  1. 我的 podfile:
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);

当我使用 podfile Jon Suggested 更新并删除旧的配置/链接器标志时,我收到此错误:

[!] 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.

如何重置这些?还是有办法告诉它无论如何都要覆盖它?

【问题讨论】:

    标签: ios objective-c dtcoretext


    【解决方案1】:

    “在我的机器上工作。”™

    您使用的是最新的 CocoaPods 吗? 0.37.1 是最新版本,除非您有特定理由不使用,否则您应该使用它。

    这个 Podfile 对我来说很好用(通过在项目目录中运行 pod init 生成):

    platform :ios, '8.3'
    
    target 'DTCoreTextTest' do
      pod 'DTCoreText'
    end
    
    target 'DTCoreTextTestTests' do
    
    end
    

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

    【讨论】:

    • 我今天刚刚使用 gem 安装了 cocoaPods,所以我应该运行最新版本。奇怪的是,当我使用你的 podfile 运行时,我得到了一个错误,上面发布了
    • 您是否摆脱了添加的额外链接器标志?此外,您需要删除旧 Podfile 设置的配置才能使用新配置。
    • 是的,我删除了链接器标志,只是删除了旧配置,再试一次
    • 现在我只是将无法识别的选择器发送到实例错误,其他一切都运行(如果我包含所有 3 个库或仅包含基本 pod.a)
    • 再一次,类似的代码对我有用。 NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithHTMLData:nil documentAttributes:nil];
    猜你喜欢
    • 2017-02-15
    • 1970-01-01
    • 2018-06-24
    • 1970-01-01
    • 2016-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多