The Text inside README.md or any other Markdown files added to the project's bundle, simply are not formatted when previewed in XCode.
Almost all of the opensource projects have instructions in Markdown at the top level of the project & even Apple use MD in their sample projects.
Magically, the .md files in Apple sample projects are formatted as expected as you can see below, but this isn't the case in any other project.
I've also checked the file's settings in the XCode inspector and it didn't differ from the ones existing in the Apple code samples.
This is how we are used to view Markdowns in XCode.
And this is is the README.md in HappyBeam which is formatted.
HTML
RSS for tagHypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser.
Posts under HTML tag
45 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I allow users to choose a font to use throughout the app, then display text using that font in 3 different ways:
As the default body font of an HTML document displayed in a WKWebView.
Used to create an NSAttributedString then displayed in an NSTextField.
Used as the body font of a very small HTML document (2-3 lines), converted to NSAttributedString, then displayed in an NSTextField.
My code has been working fine for years, but starting with the release of Sonoma (macOS 14), any text that is converted from HTML to NSAttributedString displays as all "question marks in boxes" for each character. This happens when certain fonts are used. In particular I've seen it with Calibri, Candara, and SF Pro. Calibri and Candara are Microsoft fonts and I think are distributed with MS Office. SF Pro is an Apple font.
There could be others; I haven't done an exhaustive check. What I can tell you is that this has been working fine literally until a couple weeks ago when customers began installing macOS 14. If they go into my app and select a different font (such as Arial or Times New Roman) everything works fine. It is only certain fonts that don't work, and those fonts work when used as the body font of an HTML document in WKWebView and when used as the font for a new NSAttributedString. They just don't work if you make a little HTML document with the font selected as the body font, then convert to NSAttributedString.
Here's the code that worked up until macOS 14:
NSString *htmlString = @"<!DOCTYPE html>"
"<html>"
"<head>"
"<style>"
"body { font-family: 'Candara', serif; font-size: 14px; }"
"</style>"
"</head>"
"<body>"
"This won't display right."
"</body>"
"</html>";
NSData *htmlData = [htmlString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)};
NSError *error;
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:htmlData
options:options
documentAttributes:nil
error:&error];
Note the fallback of "serif" — that doesn't matter. you get all undefined characters and the fallback font is not used. It's as if the renderer really believes the font is usable, but it isn't.
Wondering if anyone has had any luck with getting the geo-location while viewing a web page in mobile Safari on Watch OS? I've updated my phone and watch to the latest versions.
The code I'm using is standard Javascript for geolocation such as
navigator.geolocation.getCurrentPosition(showPosition, showPositionError);
Works fine when I run it in Safari on my laptop, but when I try to run the same thing on apple watch in embedded web browser, get an "Access Denied" error, which would imply that I have some permission set wrong either on the watch or the paired iPhone. I've messed with many of those settings and nothing seems to be working.
Wondering if it's stated somewhere that it simply won't work so I don't continue chasing my tail on something that was designed not to work.
Hello, I'm trying to learn swift and making the Landmarks tutorial I found a problem with the map view. The error read as follow: "'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:)' was deprecated in iOS 17.0: Use Map initializers that take a MapContentBuilder instead."
My code is:
import MapKit
struct MapView: View {
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 34.011_286, longitude: -116.166_868),
span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2)
)
// The error happens here!
var body: some View {
Map(coordinateRegion: $region)
}
}
#Preview {
MapView()
}
Any suggestions about hot to solve this will be appreciate it.
Thanks,
BR
Skalex
Good morning!
I am developing an iOS app that gets its data from an API and displays it in a list. The list item view has NavigationLink embedded in it that sends users to a detail view. In this detail view, I have some Text views but the issue I am running into is a WKWebView that I have implemented to display some HTML that's is retrieved from the API call.
The WKWebView displays the HTML just how I want it to. The issue I have is in the HyperLinks that are displayed in the WKWebView. When a user taps on a link, it opens inside of the web view. Instead of opening in the web view, I would like this link to open in the user's default web browser. I have searched and found ways of doing this in older versions of Swift using classes but my web view is initialized inside of a struct that conforms to the UIViewRepresentable protocol.
I don't know how to get links to open in the browser instead of the WebView so any help would be appreciated. Here is the code for my WebView that is being used on the details page.
struct NewsItemWebView: UIViewRepresentable {
// HTML from API Call
var text: String
// Method to create the View
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
// Method to update the View by changing properties of the WebView
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.isOpaque = false
uiView.backgroundColor = UIColor.white
uiView.loadHTMLString(text, baseURL: nil)
}
}
Here is how I am implementing the WebView on DetailView
NewsItemWebView(text: item.PageContent)
.frame(height: 450)
Any help on how I can make links open in a browser would be great. Thanks in advance.