In my View Controller screen in Xcode I've added some horizontal and vertical lines from the usual Library of buttons, windows, etc. In my app I have a clear window with just the title bar and an input/output text area shown. I want to have a visible border around the window. The added lines work but they're very light. I don't see how to edit that in Xcode or how to have my app modify them - or another way to get a visible border around my clear window. The rest of my simple app is working great. This is the last detail and I'm really stuck.
Post
Replies
Boosts
Views
Activity
Xcode 12.2, M1 Mac mini and M1 laptop. My MacOS apps compile and run first time. If I recompile to test again, the build fails with the ....detritus not allowed ... error. If I delete the app file first and recompile and run it works fine. Or if I do an xattr -cr on the app file in Terminal it compiles and runs fine. I don't know why Xcode looks at the existing file before overwriting it with a new one, and I don't know how to automate one of my two workarounds so I don't have to keep doing them manually. I've tried adding the xattr -cr command in the Run script in the Build Phase, but it kills the build so I'm doing something wrong there. Any clues would be appreciated, and I hope my steps of deleting or cleaning the app file before recompiling helps someone.
Two methods of reading a small text file work in Playground but fail in a MacOS App. Some permissions thing or ? Any clues would be appreciated.
this simple one errors with: Operation not permitted
import Cocoa
var path = "/Users/jeff/Documents/DateDisplayData.txt"
//read text file line by line
func readFile(_ path: String) -> Int {
errno = 0
if freopen(path, "r", stdin) == nil {
perror(path)
return 1
}
while let line = readLine() {
//do something with lines..
	 print(line)
}
return 0
}
readFile(path)
In case the simple example wasn't enough, this longer one errors with: File expected at “…<path>...” is missing
import Cocoa
// get URL to the the documents directory in the sandbox
let home = FileManager.default.homeDirectoryForCurrentUser
// add a filename
let fileUrl = home
.appendingPathComponent("Documents")
.appendingPathComponent("DateDisplayData")
.appendingPathExtension("txt")
// make sure the file exists
guard FileManager.default.fileExists(atPath: fileUrl.path) else {
preconditionFailure("file expected at \(fileUrl.absoluteString) is missing")
}
// open the file for reading
// note: user should be prompted the first time to allow reading from this location
guard let filePointer:UnsafeMutablePointer<FILE> = fopen(fileUrl.path,"r") else {
preconditionFailure("Could not open file at \(fileUrl.absoluteString)")
}
// a pointer to a null-terminated, UTF-8 encoded sequence of bytes
var lineByteArrayPointer: UnsafeMutablePointer<CChar>? = nil
// the smallest multiple of 16 that will fit the byte array for this line
var lineCap: Int = 0
// initial iteration
var bytesRead = getline(&lineByteArrayPointer, &lineCap, filePointer)
defer {
// remember to close the file when done
fclose(filePointer)
}
while (bytesRead > 0) {
// note: this translates the sequence of bytes to a string using UTF-8 interpretation
let lineAsString = String.init(cString:lineByteArrayPointer!)
// do whatever you need to do with this single line of text
print(lineAsString, terminator: "")
// updates number of bytes read, for the next iteration
bytesRead = getline(&lineByteArrayPointer, &lineCap, filePointer)
}
With spaces allowed in Mac folder names, it's necessary to use an escape sequence while programming (at least what I'm doing in C right now) and Xcode is complaining about the standard usage of the backslash character, as in:
input = fopen("/Users/joe\ schmoe/namedata.txt", "r");
if one of the folders were named "joe schmoe" with the space in there. Everything works, but the yellow warning tag and highlighting is bothersome.
How do I turn off that incorrect warning?
opt-shift-k gives me the expected Apple logo character in Notes and TextEdit, but in Mail I just get a square box. Same in a Flashcard Hero app I have. It used to work everywhere, but now, at least in Sonoma 14.3.1, it doesn't work some places.
(seems to work here)
I also have a keyboard text replacement set on my computer where I can type "apple logo" without the space in between and it puts in the character. That's not working in the same places opt-shift-k isn't working, so I guess the problem is in the Mail app and the Flashcard app.
Is anyone else finding this problem? Any ideas? I don't find any threads here on it, or on the web. Perhaps it's a new thing.