I want to set a compiler flag to always emit warnings if I don't use any keyword on my existential types. I didn't find the flags in the official documentatin — the only thing I could find is the flag -enable-explicit-existential-types in apple/swift repo (PR #40282). But it doesn't seem to work
Also, I think I found a bug in Swift 5.8.1 compiler. If I set OTHER_SWIFT_FLAGS = "-enable-explicit-existential-types" , SWIFT_STRICT_CONCURRENCY = complete and use AppDelegate via main.swift, I get the following error:
error: Filename "main.swift" used twice: '/Users/admin/Documents/XcodeProjects/TestProjects/TestExistentialAny/TestExistentialAny/main.swift' and '-e' (in target 'TestExistentialAny' from project 'TestExistentialAny')
note: Filenames are used to distinguish private declarations with the same name (in target 'TestExistentialAny' from project 'TestExistentialAny')
I use Xcode 14.3.1 (14E300c)
Any help with this?
Post
Replies
Boosts
Views
Activity
I'm experimenting with the (relatively) new Logger API after watching WWDC20 session "Explore logging in Swift", and I don't see a default reduction of the values that was discussed in the talk.
When I run this code,
let i = A(a: "aaaa", b: 111)
logger.error("Password: \(i)") // privacy: .auto
logger.error("Password: \(i, privacy: .public)")
logger.error("Password: \(i, privacy: .private)")
logger.error("Password: \(i, privacy: .private(mask: .none))")
logger.error("Password: \(i, privacy: .private(mask: .hash))")
I get this output in both Xcode console and Console.app:
2023-08-20 22:55:57.373918+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111
2023-08-20 22:55:57.373988+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111
2023-08-20 22:55:57.374014+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111
2023-08-20 22:55:57.374032+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111
2023-08-20 22:55:57.374055+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111
My assumption is that when running the code from Xcode with debug build configuration the system generously opens up any private values so I can inspect them conveniently. But when I ran my code with the release config, I got the same output. However, I want to test what data will be stored on my users' devices when I write different privacy options
Any ideas why this happens?
Hi there!
Sorry in advance, this is going to be a long post of Apple developer pains which I want to share with you, and, hopefully, find the answer and help Apple become better.
I'm at the very beginning of my new and exciting personal project which (I hope) may one day feed me and be my daily source of inspiration. I'm not a newbie in Apple development nor am I a senior-level developer — just a fellow developa'.
Here's the problem I bring to you — why Apple promotes Unified Logging System and recommends using it as the primary way to implement logging in 3rd-party apps? No doubt, OSLog is a great, secure, efficient, and centralized way to gather diagnostics information, and I, starting my new project, am itching to choose exactly this 1st-party logging infrastructure. This decision in theory has a number of benefits:
I don't have to depend on 3rd-party logging frameworks which may eventually be discontinued;
I have extensive documentation, great WWDC sessions explaining how to use the framework, and stackoverflow answers from the whole Apple dev community in case I experience any troubles;
I have this cool Console.app and upcoming Xcode 15 tools with great visualization and filtering of my logs;
It's quite a robust and stable infrastructure which I may restfully rely on.
But... the thing is there's this big elephant in the room — this API is non-customizable, inconvenient, and hard to use in terms of the app architecture. I can't write my own protocol wrapper around it to abstract my domain logic from implementation details or just simplify the usage at the call site. I can't configure my own format for log messages (this is debatable, since Console.app doesn't provide "***** strings" as Xcode 14 and earlier, but still). And what's most important — I can't conveniently retrieve the logs!
I can't implement the functionality where my user just taps the button, and the logs are sent on the background queue to my support email (eskimo's answer). They would have to go through this monstrous procedure of holding volume buttons on the iPhone, connecting their device to the Mac, gathering sysdiagnose, entering some weird Terminal commands (jeez, these nerdy developers...), etc. If it ever succeeds, of course, and something doesn't go wrong, leaving my user angry and dissatisfied with my app.
Regarding the protocol wrapper, I can't do something like this:
protocol Logging {
var logger: Logger { get }
func info(_ message: OSLogMessage)
}
extension Logging {
var logger: Logger {
return Logger(
subsystem: "com.my.bundle.id",
category: String(describing: Self.self)
)
}
func info(_ message: OSLogMessage) {
logger.info(message)
}
}
class MyClass: Logging {
func someImportantMethod() {
// ...
self.info("Some useful debug info: \(someVar, privacy: .public)")
}
}
I've been investigating this topic for 2 days, and it's the farthest I want to go in beating my head over how to do two simple things:
How to isolate logging framework implementation decision from my main code and write convenience wrappers?
How to easily transfer the log files from the user to the developer?
And I'm not the only one struggling. Here's just one example among hundreds of other questions that are being asked on dev forums: https://www.hackingwithswift.com/forums/ios/unified-logging-system-retrieve-logs-on-device/838. I've read almost all Apple docs which describe the modern Unified Logging System, I've read through eskimo's thread on Apple Developer Forum about the API, but I still haven't found the answer.
Maybe, I've misperceived this framework and it's not the tool I'm searching for? Maybe, it focuses on different aspects of logging, e.g. signposting, rather than logging the current state of the app? What am I missing?