Updates – Cocoaneticshttps://www.cocoanetics.com
Our DNA is written in Objective-CMon, 28 Aug 2017 14:39:38 +0000en-UShourly1https://wordpress.org/?v=4.8.239982308DTCoreText 1.6.21https://www.cocoanetics.com/2017/08/dtcoretext-1-6-21/
https://www.cocoanetics.com/2017/08/dtcoretext-1-6-21/#respondMon, 28 Aug 2017 14:39:38 +0000https://www.cocoanetics.com/?p=10506The previous release of DTCoreText was in February, 7 months ago, so it was about time to release an update for the about 50 commits that were made by community contributors since then.

BSA Banner

Changes

ADDED: Support for <p> text-indent

ADDED: Support width attribute in percent for text attachments

ADDED: Ability to abort HTML parsing

ADDED: Archiving

ADDED: Improved support for macOS

FIXED: Incorrect file name in import should be DTCSSStylesheet.h

FIXED: HTML generation with multi-line links

FIXED: Do not add Apple-converted-space to attributed string when processing custom HTML attributes

FIXED: Avoid unnecessary drawing of DTAttributedTextContentView if it is being deallocated

FIXED: Changing properties on DTCoreTextLayoutFrame would not update layout, resulting in incorrect sizing information being returned

I also went through the GitHub Issues and closed all the ones that have neither had any discussion in a long while. Most of them were questions which were long answered or are requests which nobody is willing to implement.

There are two requests/questions which I would like to answer here:

How about supporting synthetic italics for Chinese?

How about supporting HTML tables?

iOS TextKit does not have any fonts for showing Chinese glyphs in italic. The effect can be achieved by adding a slanting transform to the font. In fact this is already done during font matching. Why this is not working for Chinese script is a mystery to me. I’m interested if somebody can provide a fix via pull request.

About HTML tables… the problem here is that in order to support that we’d have to do two major things: First we need to parse the HTML tags related to tables (table, td, tr, etc.) into some temporary storage and then we need to build a text attachment from that. The second step would be to generate an image or a custom subview that is able to properly layout and render the table contents.

In all the years I have never met anybody using DTCoreText who would be willing to pay me for implementing that.

How about DTCoreText 2.0?

And actually… there are other changes to DTCoreText which would need to happen before adding any such new features could reasonably be added. I’d rather start working on a successor to DTCoreText 1.x.

To name a few examples of different design choices for a new start:

Nowadays, I would write it in Swift

We could still use libxml for parsing HTML but I would make it UIKit-compatible exclusively.

UILabel and UITextView support attributed strings for many years now, there is simply no good reason to keep using the attributed label from DTCoreText 1.x.

Text attachment would solely be modelled with NSTextAttachment, including support for asynchronousimages.

Via UITextView we would also get automatic support for Rich Text editing. Instead of using DTRichTextEditor, editing would then be built into iOS and macOS.

Unfortunately Apple still doesn’t give us support for creating text lists, although iOS seems to internally support NSTextList and NSTextBlock. But we can probably hack around that in a way that is App Store-compatible.

Using TextKit’s layout facilities it would also finally be possible to have text flow around floating images

I’ve gathered a lot of experience dealing with attributed strings without using DTCoreText, solely relying on built-in functionality. And from that I can tell you that it is possible and worth the effort.

I’d love to have a company sponsor a new start. If you’re interested to help fund it, please get in touch.

]]>https://www.cocoanetics.com/2017/08/dtcoretext-1-6-21/feed/010506DTCoreText 1.6.20https://www.cocoanetics.com/2017/02/dtcoretext-1-6-20/
https://www.cocoanetics.com/2017/02/dtcoretext-1-6-20/#respondThu, 23 Feb 2017 18:51:10 +0000https://www.cocoanetics.com/?p=10433Since the previous maintenance release was 4 months ago, I decided to make a new release with the contributions made since then. DTCoreText is not being actively developed further by me because by this time the HTML-parsing capabilities built into iOS 9 and 10 are sufficient for most peoples needs. But since I keep getting good pull requests (with unit tests a welcome extra) I keep releasing these every couple of months.

ADDED: Look for `DTCoreTextFontOverrides.plist` in the main bundle if its not found in the local bundle

ADDED: Expanded character decoding support in stringByReplacingHTMLEntities

Thank you to Kasper Weibel, David X. Lau and several contributors who have not set a proper name on Github, making it impossible for me to thank them by name.

At the time of this writing I have 80 open issues, but for the reason stated above I am going to close all of them for lack of activity. I’ve seen this practise in action on the Fastlane project. I will personally only ever work on an issue if somebody hires me to do so. Other issues will only be addressed if somebody provides a pull request.

For that reason, issues that basically say “I am a beginner and I cannot get the project to compile” are rather useless. Sorry, but I don’t have time to give free support or mentoring.

I’d rather be working on starting a new project that adds some missing functionality that Apple still hasn’t added to HTML parsing in iOS, specifically support for editing bulleted and numbered lists. In particular I am interested in adding proper handling for lists to UITextView which I am using in this Babyforum.at app which we recently built for a client. I did it once before in DTRichTextEditor, we should be able to do that in a UITextView subclass as well.

But enough ranting, for those people who still insist on using DTCoreText, the update is tagged on GitHub and available via Cocoapods. I don’t know about Carthage, sorry. But I think somebody mentioned that this works as well.

]]>https://www.cocoanetics.com/2017/02/dtcoretext-1-6-20/feed/010433POEditorAPI 1.1.0https://www.cocoanetics.com/2016/12/poeditorapi-1-1-0/
https://www.cocoanetics.com/2016/12/poeditorapi-1-1-0/#respondSat, 10 Dec 2016 18:40:55 +0000https://www.cocoanetics.com/?p=10331In the month since the initial release of the POEditor.com API and command line utility, I did some refinements which become necessary to support ongoing development projects. Generally speaking you should use the poet tool without parameters to refresh your strings files.

BSA Banner

The utility requires that all translations have their context set, or else we don’t know which file they go into. Now, if you go the outmoded route of importing a strings file into POEditor.com then the context isn’t correctly set. You can fix this by manually updating it to “Localizable.strings”. The modern way that has long replaced this is to export a XLIFF file in the development language directly from Xcode. This makes sure that all contexts are set, usually either to a strings file or sometimes a storyboard file.

Changes

FIXED: POEditor class/methods was not visible to importing app

FIXED: Don’t write empty files or empty plurals

CHANGED: Removed workaround that would use en-US as en language.

ADDED: Information in README on how to uses it with Cocoapods (now that it works)

ADDED: The poet command line utility now has a parameter to do a one-off export in a given format

The command line utility uses the JSON export format because this also contains plurals. For the BabyCheck app I needed to be able to export the XLIFF file for each language because I am building the localised checklists that come bundled with the app from that. This is why I added a parameter to poet which lets you specify the output file format.

The second change was that you couldn’t use it via CocoaPods because the framework classes did not have the correct public accessibility tags. This release fixes this. I also added some info to the README file to show how to do that and how to do a smoke test.

The ability to automate the process of updating localisations has proven to save me a great amount of time so far. I hope that it can do so for you as well. I would love to hear from you what challenges you have in your localisations and maybe see how poet and/or this API wrapper could be enhanced to address these.

]]>https://www.cocoanetics.com/2016/12/poeditorapi-1-1-0/feed/010331DTCoreText 1.6.19https://www.cocoanetics.com/2016/10/dtcoretext-1-6-19/
https://www.cocoanetics.com/2016/10/dtcoretext-1-6-19/#respondTue, 11 Oct 2016 17:21:08 +0000https://www.cocoanetics.com/?p=10322Hot on the heels of the previous release for DTCoreText this update hot-fixes several issues which were introduced in the previous release.

BSA Banner

Changes

FIXED: Incompatibility with iOS 7, using containsString

FIXED: Memory Leak in DTLazyImageView, using NSURLSession

FIXED: [Demo] When loading remote images the relayout needs to be done on next runloop

I decided to push this release without delay so that everybody needing DTCoreText can get fixes for bugs I introduced in 1.6.18 mostly fixing Xcode 8 warnings. Tips are welcome to PayPal oliver@cocoanetics.com.

]]>https://www.cocoanetics.com/2016/10/dtcoretext-1-6-19/feed/010322DTCoreText 1.6.18https://www.cocoanetics.com/2016/09/dtcoretext-1-6-18/
https://www.cocoanetics.com/2016/09/dtcoretext-1-6-18/#commentsFri, 30 Sep 2016 14:29:41 +0000https://www.cocoanetics.com/?p=10318Since the prior release of DTCoreText, 9 months ago, a few issues became apparent with Xcode 8. Some people contributed cool stuff like support for use in app extensions as well as tvOS support.

BSA Banner

Changes

ADDED: tvOS Support

ADDED: Property to better support display remote images with DTAttributedTextCell

ADDED: Extension sub spec (which removes some things that cannot be used in Extensions)

ADDED: Parse margin-top as paragraphSpacingBefore

ADDED: Support for list style with roman numerals

ADDED: 10% performance increase parsing CSS styles that only have a single part

Thank you for your contributions, Philipp Schmid, David X. Lau, James Hurst, Brandon Tram, Alex WU, Kai Maschke, Ryan Maxwell, Ian Ynda-Hummel, Florian Friedrich. (I can only thank people who have a proper name set up on GitHub)

One particular annoyance resulted from a bug in CocoaPods where the prepare_command of the podspec is not being executed. I am using this to generate a C file from the default CSS file and if it is not run, the linting of the spec fails. So as an immediate workaround I added a copy of this file to the repo.

The most work I needed to do on DTLazyImageView which required replacing the prior NSURLConnection logic with NSURLSessionDataTask while preserving the progressive download capability.

]]>https://www.cocoanetics.com/2016/09/dtcoretext-1-6-18/feed/110318DTFoundation 1.7.11https://www.cocoanetics.com/2016/09/dtfoundation-1-7-11/
https://www.cocoanetics.com/2016/09/dtfoundation-1-7-11/#respondMon, 26 Sep 2016 14:07:42 +0000https://www.cocoanetics.com/?p=10311With the prior update to DTFoundation having been 5 months ago, there were two main areas where some tweaks were necessary: support for tvOS and fixing a build error on Xcode 8.

BSA Banner

Changes

FIXED: Xcode 8 build error in Runtime

ADDED: tvOS Subspec

Thanks to Ryan Maxwell for the adjustments necessary to for tvOS support. Thanks to Fawaz Tahir for the Xcode 8 compatibility fix.

]]>https://www.cocoanetics.com/2016/09/dtfoundation-1-7-11/feed/010311BarCodeKit 1.3.1https://www.cocoanetics.com/2016/06/barcodekit-1-3-1/
https://www.cocoanetics.com/2016/06/barcodekit-1-3-1/#respondFri, 03 Jun 2016 16:33:32 +0000https://www.cocoanetics.com/?p=10236BarCodeKit can generate lots of different kinds of 1D barcodes. The previous update coincided with the release the Barcodes with iOS book. This release rolls up a few tweaks and adds a new rendering option.

BSA Banner

Changes

ADDED: option to specify explicit barcode size

FIXED: incorrectly named methods and comments not matching the class name

Thanks to Martin Kötzing and “ebaker355” for their contributions!

The new rendering options let you specify a higher resolution width or height as opposed to the one that get’s calculated from the multiple and minimum size. This is useful for when you want to render a barcode into a higher resolution image.

]]>https://www.cocoanetics.com/2016/06/barcodekit-1-3-1/feed/010236DTMarkdownParser 0.2.2https://www.cocoanetics.com/2016/05/dtmarkdownparser-0-2-2/
https://www.cocoanetics.com/2016/05/dtmarkdownparser-0-2-2/#respondThu, 26 May 2016 08:56:39 +0000https://www.cocoanetics.com/?p=10233DTMarkdownParser is a sequential parser for markdown, with a similar sequential paradigm as NSXMLParser. I started this project in 2013 as a training case for TDD and going for 100% code coverage by unit tests.

Apparently this nifty little project of mine has some fans, so we are publishing a new release today to include all the improvements that were made in that 2.5 years…

BSA Banner

Changes

Jan Weiß fixed a HTML error in the SimpleHTMLGenerator Demo. He also converted the unit tests to XCTest.

Mikkel Selsøe Sorensen added the option to ignore URLs.

I fixed some warnings and carried out project updates recommended by Xcode 7.3

The first issue was severe because the behavior of the mentioned category method was complete wrong. Thanks Mohamed Hafez for reporting this!

I slightly modified DTPieProgressIndicator to use tintColor for the label and image because this makes it work well as subview of a UIVisualEffectsView with vibrancy. iOS always makes all UI elements vibrant that are using the tintColor.

The build problems also resulted in issues with DTCoreText and DTRichTextEditor. This should be fixed now as well, at least when they were caused by Xcode complaining about non-modular headers preventing parts from building.

]]>https://www.cocoanetics.com/2016/04/dtfoundation-1-7-10/feed/010193DTBonjour 1.1.2https://www.cocoanetics.com/2015/12/dtbonjour-1-1-2/
https://www.cocoanetics.com/2015/12/dtbonjour-1-1-2/#respondTue, 29 Dec 2015 10:08:33 +0000https://www.cocoanetics.com/?p=10030DTBonjour simplifies the communication between client and server over Bonjour by allowing you to send any object which conforms to NSCoding. This update adds a new delegate method to inform about client disconnects. The rest is house-keeping.

BSA Banner

Changes

Added delegate method to DTBonjourServerDelegate to notifiy about client disconnect

]]>https://www.cocoanetics.com/2015/12/dtbonjour-1-1-2/feed/010030Kvitto 1.0.1https://www.cocoanetics.com/2015/12/kvitto-1-0-1/
https://www.cocoanetics.com/2015/12/kvitto-1-0-1/#commentsTue, 29 Dec 2015 09:55:19 +0000https://www.cocoanetics.com/?p=10027Kvitto is my first Swift component. I built it to decode universal app store receipts for the purpose of purchase validation and determining subscription durations.

Somehow the podspec for Kvitto had gotten lost. So I needed to reconstruct it from the JSON version which I found in the Cocoapods specs repo. Also there was some cleanup work and experiments trying to get unit testing and code coverage for Swift working. So this is purely a housekeeping release.

BSA Banner

Changes

No changes in functionality, purely housekeeping

Reconstructing the podspec reminded me that the universal app receipt – the sort that Kvitto can parse – is also used on Mac. Some days I think we should add support for OS X and tvOS for Kvitto as well.

]]>https://www.cocoanetics.com/2015/12/kvitto-1-0-1/feed/110027DTKeychain 1.0.2https://www.cocoanetics.com/2015/12/dtkeychain-1-0-2/
https://www.cocoanetics.com/2015/12/dtkeychain-1-0-2/#respondTue, 29 Dec 2015 09:27:29 +0000https://www.cocoanetics.com/?p=10024This update to DTKeychain adds the ability to use it as a dynamic framework. This nifty little component is what we use for all things required to store account information.

BSA Banner

Changes

ADDED: Support for use as dynamic framework

We needed to use it as framework in a Mac/iOS dual project and so I added support for that in addition to the previously existing Cocoapods support.

]]>https://www.cocoanetics.com/2015/12/dtkeychain-1-0-2/feed/010024DTCoreText 1.6.17https://www.cocoanetics.com/2015/12/dtcoretext-1-6-17/
https://www.cocoanetics.com/2015/12/dtcoretext-1-6-17/#respondTue, 29 Dec 2015 09:06:31 +0000https://www.cocoanetics.com/?p=10020This update to DTCoreText aggregates and release half a year worth of fixes. The previous update was in July 2015.

BSA Banner

Changes

Thanks to Hirad Motamed, Amro Mousa and Dominik Pich. They came together on GitHub to work out the fixes in concert.

The update is tagged on GitHub and also published on Cocoapods.

]]>https://www.cocoanetics.com/2015/11/dtrichtexteditor-1-6-12-dtloupe-1-5-8/feed/09990DTFoundation 1.7.8https://www.cocoanetics.com/2015/10/dtfoundation-1-7-8/
https://www.cocoanetics.com/2015/10/dtfoundation-1-7-8/#commentsWed, 07 Oct 2015 18:34:04 +0000http://www.cocoanetics.com/?p=9885This update for DTFoundation fixes some building problems for tvOS and extensions. Also most of the work happened on DTASN1 in preparation for Kvitto, my new open source framework for reading App Store receipt files.

BSA Banner

Changes

ADDED: Support for tvOS

ADDED: Define to disable code that does not work when building for extensions

ADDED: [DTASN1] now part of DTFoundation Core

FIXED: [DTASN1] Numbers with more than 4 bytes would not be represented as NSNumber

]]>https://www.cocoanetics.com/2015/07/dtfoundation-1-7-7/feed/09839DTRichTextEditor 1.6.11https://www.cocoanetics.com/2015/07/dtrichtexteditor-1-6-11/
https://www.cocoanetics.com/2015/07/dtrichtexteditor-1-6-11/#respondMon, 27 Jul 2015 14:31:36 +0000http://www.cocoanetics.com/?p=9825I had moved DTRichTextEditor to be Open Source because I wanted bright individuals to be able to contribute to this complex component. I had hatched the plan to ask people who are using the component commercially to set a bounty for fixed issues. This is the second release where a bounty was successfully captured.

BSA Banner

Changes

FIXED: Problems with dictation placeholder leading to crash or double text insertion

CHANGED: Updated DTLoupe to 1.5.7 – to support bundle in iOS framework

The bounty for this release was captured by Brian Lundgren. He did so by adjusting the way the dictation placeholder is handled. Congratulations!

I also set up a continuous integration build on Travis-CI, but found an issue in implicit dependency building, which I filed a Radar for. This is the reason why so many builds failed. I also tried the Xcode 6.4 image Travis-CI is providing for testing, but this does nothing to address the issue. Rather it has a different issue: the travis.yml script line calling appledoc does not appear to be working there, it just silently fails the build. So I reverted back to the standard settings.

I later found that DTRichTextEditor.framework for iOS was missing DTCoreText as explicit dependency. Once all dependencies are explicitly defined, Xcode does not seem to try to find the dependencies by itself.

]]>https://www.cocoanetics.com/2015/07/dtrichtexteditor-1-6-11/feed/09825DTRichTextEditor 1.6.10https://www.cocoanetics.com/2015/07/dtrichtexteditor-1-6-10/
https://www.cocoanetics.com/2015/07/dtrichtexteditor-1-6-10/#respondTue, 07 Jul 2015 11:39:54 +0000https://www.cocoanetics.com/?p=9769This is the first update since the project has been open-sourced. Together with the updates in all sub-modules it now supports Cocoapods frameworks and modules.

BSA Banner

Changes

FIXED: Crash in DTLoupe

FIXED: Crash on iOS <= 5.1.1

ADDED: iOS Framework

ADDED: Support for CocoaPods frameworks and Modules

The most valuable contribution came from Amro Mousa who fixed an iOS 8 issue where rendering a snapshot of a layer with invalid dimensions would cause a crash.

This bug had been unfixed for a long time while the framework was still private. After the switch to Open Source and putting out a bounty on the swatting of this bug, it got fixed within a few days.

So I am cautionsly optimistic that the approach of publicly offering bounties seems to work. If only because issues get more exposure because of this.

]]>https://www.cocoanetics.com/2015/07/dtrichtexteditor-1-6-10/feed/09769DTCoreText 1.6.16https://www.cocoanetics.com/2015/07/dtcoretext-1-6-16/
https://www.cocoanetics.com/2015/07/dtcoretext-1-6-16/#commentsSat, 04 Jul 2015 09:58:02 +0000https://www.cocoanetics.com/?p=9761This is a big update for DTCoreText, maybe even deserving of a minor version bump. It aggregates fixes and enhancements contributed over more than 4 months. This kind of proves that DTCoreText is alive and getting better all the time.

BSA Banner

Changes

FIXED: Compatibility with CocoaPods 0.36 and frameworks

FIXED: Missing super calls in -awakeFromNib

FIXED: Dependency problems with DTWeakSupport.h

FIXED: Problem with “Cursive” tag and a Custom Font Cursive

FIXED: CGFloat values were used as bool values within if statements

FIXED: Additional CGFloat build issue on xCode 7

FIXED: Wrong foreground color attribute used for appending NL

FIXED: Xcode warning for unused expression result

FIXED: CGFloat build issue on xCode 7

ADDED: Honour the value of NSBaselineOffsetAttributeName

ADDED: DTCoreText.framework for iOS

ADDED: Improve AutoLayout in DTAttributedTextContentView

ADDED: DTDocumentPreserveTrailingSpaces boolean option

The main driver for this release was the fact that people where experiencing problems using DTCoreText in Swift apps. The main reason for these issues resulted from some unclear cross dependencies dependencies and imports that would throw the module building. Support for modules/frameworks arrived in CocoaPods 0.36 and I hadn’t gotten around to fixing this until now.

When debugging the module support I also clarified the imports in many source files. Instead of blankly always importing the CoreText.h umbrella header I switched to importing exactly the needed files. I added a dynamic iOS framework for this purpose which would show me where module building problems would reside.