Post

Replies

Boosts

Views

Activity

Generated xcarchive has no built dylib
I am in peril. Can anyone save me. I am desperate! I am using Xcode Version 14.2 (14C18). I created a fresh new library project (plain C/C++) and added the well-known SQLite3.h and SQLite3.c. When I build debug configuration, Xcode correctly produces dylib. But when I do archive build, the generated xcarchive is almost empty - it does not have expected libsqlite3s.dylib! I even went back to Xcode 7.2.1 on macOS 10.10. Xcode 7.2.1 can correctly produce archived dylib and I can link the dylib with a test app. I am extremely frustrated!
1
0
743
May ’23
Weird: let statement leads to nil
I have not touched Swift code for more than a year. My skills become rusty. I am not sure what stupid errors I made in the following code: extension Bundle { func readResourceFile(_ filename: String) -> String? { if let fileUrl = self.resourceURL?.appendingPathComponent(filename, isDirectory: false) { return try? String(contentsOf: fileUrl) } return nil } } class MyVC { //... @IBAction func testButton_click(_ sender: Any) { Task.init { await self.test1() } } func test1() async { var loaded = false do { let result = try await self.webView.evaluateJavaScript("typeof(jQuery)") loaded = result as? String == "function" } catch { self.statusLabel.stringValue = "error: \(error)" } if (loaded) { await self.runUserScript(self.input.string) return } let scriptFiles = ["jQuery.js", "Scriptlets.js"] var count = 0 for scriptFile in scriptFiles { print("Loading \(scriptFile)") do { if let script = Bundle.main.readResourceFile(scriptFile) { try await self.webView.evaluateJavaScript(script) print("Loaded \(scriptFile)") count += 1 } } catch { self.statusLabel.stringValue = "error: \(error)" } } } The line if let script = Bundle.main.readResourceFile(scriptFile) { succeeds but script still is nil and causes app crash in next line self.webView.evaluateJavaScript(script). Bundle.main.readResourceFile(scriptFile) is working if I run this line elsewhere. EDIT: When I click on the I button in debugging on variable script I get: (String) script = <no location, value may have been optimized out> However, I can print(script) and the output is correct.
2
0
549
Apr ’23
User voice: Apple geniuses, please pay attention to small details!!!
This is really disgusting. I really hate to say this. I started Xcode programming many years ago when it's at version 4 (or even 3). It has been fun and pleasure to program in this IDE, with no problem at all. User rating of this app in App Store was 4.5+. But 2 or 3 years ago, maybe starting from Xcode 11, it started getting too many quirks/gotchas. App Store user rating drops to 3.5+. With version 14+, user rating drops to 2.9. The app's key/main features work. But many small bugs/nuisances put developers like me into peril during daily coding work. Now I almost want to quit Xcode programming, because it is making my life unpleasant.
1
0
416
May ’23
Does Swift support stored property with computed value?
This may sound strange, but I encounter real world need on this. private var queryItems_: [URLQueryItem]? private var queryItems: [URLQueryItem]? { get { if queryItems_ == nil { if !queries.isEmpty { queryItems_ = queries.map { (key: String, value: String?) in return URLQueryItem(name: key, value: value) } } } return queryItems_ } } /// Query strings public private(set) lazy var queries = [String: String?]() { didSet { queryItems_ = nil } } The queryItems will be (re)created on get if queries property was changed. What I wish is that I could use queryItems as a simple var property but let me do my logic in its getter. Is this supported already?
1
0
328
Aug ’23
How throw error in willSet
I have the following code: public var endpoint: String! { willSet { if newValue == nil { throw ErrorCode.NullValue("endpoint") } } } But compiler gives me error: Error is not handled because the enclosing function is not declared 'throws'
3
0
761
Aug ’23
How extract files in Assets.car?
I got a few answers from SO, but the tools are too old and they don't even run my macOS (12.6). Is there any official way to extract an Assets.car file? The reason I ask this question is that I want to re-use the icons for strings/storyboard files in Xcode packaged Assets.car (if it's legal).
0
0
979
Sep ’23