Post

Replies

Boosts

Views

Activity

How to code sign unit tests in a Swift Package for Mac Catalyst?
It appears that on an Apple Silicon Macs, we cannot do unit tests for Swift Packages using Mac Catalyst. Steps to produce: 0. Get an Apple Silicon Mac. Go to an empty folder, create a new Swift Package using swift package init. Open the created Package.swift, select the running destination to be My Mac (Mac Catalyst). Run the tests. I was getting the following error: code signature in [generated test path] not valid for use in process using Library Validation: Trying to load an unsigned library. I did not get this issue on my Intel Mac. On Apple Silicon Macs, set the destination to an iOS simulator or a “pure” Mac destination also works. How to bypass this issue, or is this a bug from Xcode? I am running the latest Xcode 12.3.
2
0
1.6k
Jan ’21
Proper way to customize layout fragments' frames?
I found that compared with TextKit 1, NSTextLayoutManager does not provide any opportunity to customize line rectangles. In particular, I cannot do much about the frame of a NSTextLayoutFragment. I am curious about the proper approach to: limit the width and horizontal offset of a paragraph; add spacing below and above a paragraph; enclose a paragraph along an arbitrary path. For the first question, I noticed that in the sample app, when layout comments, BubbleLayoutFragment does not change the positions of any characters. While it did override renderingSurfaceBounds, it merely expands the bounds, without moving its text contents. And there seems to be no way to do so. For the second question, I noticed that paragraphSpacing and paragraphSpacingBefore set on the paragraph style seems to have no effect. According to the video, all layout fragments are stacked like a list. Therefore, this is an intended feature, right? Right now, my solutions to the first two questions are: If I want to control the horizontal position of a paragraph, I could simply set headIndent and trailIndent on the paragraph style. If I want to add spacing above or below a paragraph, I can add empty lines and set minimalLineHeight for the newline character. Are those the recommended ways to achieve such effect? Personally, I am not very interested in the third feature, enclosing a paragraph along an arbitrary path. However, I am indeed curious about how to add paragraph-level attachment, such as an block image/custom view between paragraphs. I think what I could do is: add an empty new line and set its height to leave enough space for the custom view; configure a CALayer or even a view and put it where the new line should be; If I want to layout characters within a strange shape, I could compute the shape's height based on the width, using TextKit 1, and then insert the new line as in step 1. Is this the intended way to approach such situation?
2
0
1.5k
Jun ’21