Post

Replies

Boosts

Views

Activity

CFBundleIdentifier not match?
I submitted a test package and got the following email: ITMS-90345: Metadata/Info.plist Mismatch - The value for bundle_identifier in the metadata.xml file does not match the value for CFBundleIdentifier in test [net.neolib.test.pkg/Payload/test.app]. I really don't have any idea what's wrong. It's a simple (almost blank) app with nearly no modification (except linked with a dylib). What is the metadata.xml? I cannot find it in my test project.
2
0
839
Apr ’23
@available question (again)
I once posted a question in the forums, but it seems I cannot find the thread now (maybe the thread was before the new forums was born). I don't know why I am so confused about this directive (or whatever): It looks like a compiler directive because it has a specific syntax. But it also looks like it's a runtime check because it is used in if statement (not in #if). So my question is: Given the following code: if (@available(macOS 13.0, *) { NSLog("Running on macOS Ventura or later") } else { NSLog("Running on older version before Ventura") } Does this directive check real macOS version during runtime?
1
0
585
Apr ’23
How to write a wrapper around CFSomeRef
I am testing with FSEventStreamCreate which returns an FSEventStreamRef, but I cannot find an equivalent toll-free class in Cocoa. In order to free-up resources used by this Ref, I need to do following: FSEventStreamStop(stream); FSEventStreamInvalidate(stream); FSEventStreamRelease(stream); That is quite error-prone and tedious. So I want to write a wrapper class, but don't have any idea on when or where to release the Ref. Is it correct to do 'free' in dealloc?
1
0
1k
Apr ’23
libarclite_macosx not found when building a framework project
Not sure if it's specific to me only. I tried to build a framework project using Xcode 14.3.1 RC but got a strange error: File not found: /Users/USERNAME/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a The project was created several years ago and was upgraded all the way to Xcode 14.2. I remember last time I posted a question about getting an empty xcarchive when doing archive build. The remedy is quite simple - setting SKIP_INSTALL to no. I wonder if this problem also has a simple remedy.
1
0
2.4k
May ’23
Not able to reference classes/structs in Swift playground sources
I have to admit that this is strange for me. Though I have been using playgrounds for years, but I only write small pieces of code to test simple ideas, and I never used another source file. Today I want to add a new struct in Sources folder. To my surprise, I am not able to reference the struct in the main playground file. Sources/testlets.swift: struct Dummy { var name: String } MyPlayground: var box = Dummy(name: "abc") // error: /.../MyPlayground.playground:22:11 Cannot find 'Dummy' in scope
2
0
912
Aug ’23
How make SomeClass<T> Decodable?
I am trying to encode/decode JSON data, and I have the following code: struct SomeOrdinaryClass: Decodable { // ... } struct SomeBox<T>: Decodable { var data: T? } But Xcode gives me the following error: myfile.swift:16:8 Type 'SomeBox' does not conform to protocol 'Decodable' Is there anyway to overcome this?
1
0
375
Aug ’23
JSONEncoder with dictionary of objects?
I have a need to wrap several kinds of objects into a dictionary say [String: Any?], but how do I tell that the Any? object is all Encodable? let params: [String: Any?] = ["num": 123, "text": "abc", "obj": encodableobject] JSONEncoder().encode(params) // compiler error because Any? is not Encodable
1
0
718
Aug ’23
Does Swift has a string builder class?
In other languages, I usually have a StringBuilder class that provides the functionality to concatenate strings in an efficient way. // pseudo code let sb = StringBuilder() sb.append("text") sb.appendFormat("name=%@", name) I am aware of @resultBuilder, but does Swift provide a builtin construct?
2
0
2.3k
Aug ’23
String interpolation produces a debug description for an optional value; did you mean to make this explicit?
This makes my head dizzy! Help me out of this peril. How to avoid this with my own class objects? let obj: LanguageItem? = LanguageItem(language: "en") print("object: \(obj)") struct LanguageItem: Codable { var language: String var name: String? } extension LanguageItem: CustomStringConvertible { var description: String { "Lang:\(language) name:\(name ?? "(none)")" } } The print statement still prints "Optional(Lang:en name:(none))". How to get rid the Optional prefix?
2
0
542
Aug ’23
switch case and === operator
I have the following code: func numberOfRows(in tableView: NSTableView) -> Int { switch tableView { case self.stringsTable: return self.stringsList?.count ?? 0 case self.localeTable: return self.localeMap.count default: print("numberOfRows not handled for \(tableView)") return 0 } } I wonder if there is any (performance) difference between case and ==== operator like below: func numberOfRows(in tableView: NSTableView) -> Int { if tableView === self.stringsTable { } // ... }
3
0
462
Sep ’23