Search code examples
iosobjective-cdtcoretext

Cocoapod library issue: DTCoreText


I posed a question earlier about this problem but I've since cleaned the project and restarted from scratch.

Im trying to use DTCoreText

  1. My podfile:
platform :iOS
pod 'DTCoreText'

^quote since for some reason editor wouldn't let me just put code there.

  1. Other Linker Flags: -OjbC -all_load

  2. Linked Frameworks

  3. Project

I get a long list of errors:

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)

This is my first attempt at using Cocoapod, I'm probably making a noob mistake here


If I remove DTFoundation.a and DTCoreText.a from linked frameworks the project runs, but I get the following error:

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

Using their sample code:

#import "DTCoreText.h"

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

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

When I updated with the podfile Jon Suggested and removed old configs/linker flags I get this error:

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

How do I reset these? or is there a way to tell it to overwrite it regardless?


Solution

  • "Works on my machine."™

    Are you using the latest CocoaPods? 0.37.1 is the latest and you should use it unless you have a specific reason not to.

    This Podfile worked fine for me (generated by running pod init in the project directory):

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

    With no need to add the extra -ObjC or -all_load flags.