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
755
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
571
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
432
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
345
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
791
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
1k
Sep ’23
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!
Replies
1
Boosts
0
Views
755
Activity
May ’23
Where is the Preview function in Xcode Version 14.2 (14C18)?
Xcode 14.2 is really crap. I cannot find the Preview function as what I have in previous version. I cannot find this menu item:
Replies
0
Boosts
0
Views
636
Activity
Apr ’23
Ventura has no default python installation?
I have not upgraded to Ventura yet. Yesterday one of my user (of one of my apps) mentioned that he has no Python environment on Ventura. Is it true?
Replies
0
Boosts
0
Views
367
Activity
Apr ’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.
Replies
2
Boosts
0
Views
571
Activity
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.
Replies
1
Boosts
0
Views
432
Activity
May ’23
Where is the link to Swift language book (epub)?
I remember last time I could download epub book (5.7) of the Swift language from https://www.swift.org. But now I cannot find the link. Where is the link now?
Replies
1
Boosts
0
Views
442
Activity
Jun ’23
Is there any way to add new localizations using a command line tool?
I am reading "Managing Strings Files Yourself". Now the question arises in my mind. Is it possible to add new localizations using ibtool (or alike)? The reason I have this question is that I have a plan to build an app to automate strings localization so that I will be freed from tedious and repetitive work on translation.
Replies
0
Boosts
0
Views
426
Activity
Jul ’23
Swift equivalent of C getenv function?
A simple question, but I am not able to find the answer myself. Note - I tried ProcessInfo.environment but it does not include system env vars.
Replies
1
Boosts
0
Views
449
Activity
Aug ’23
Argument type 'LanguageItem?' does not conform to expected type 'CVarArg'
I have the following code: let obj: LanguageItem? = LanguageItem(language: "zh-CN") // Argument type 'LanguageItem?' does not conform to expected type 'CVarArg' print(String(format:"obj: %@", obj)) struct LanguageItem: Codable { var language: String var name: String? } How can I make my class work with String(format:)?
Replies
2
Boosts
0
Views
502
Activity
Aug ’23
Not able to inherit from NSObject in unit test
The following code compiles fine in a normal Swift app, but not in the accompanying unit test bundle. I don't have any idea why. import Foundation struct Dummy: NSObject { // Error: Inheritance from non-protocol type 'NSObject' var name: String? }
Replies
1
Boosts
0
Views
636
Activity
Aug ’23
Linker errors in Swift app with a framework bundle
I have a simple test project which has a framework bundle (as a target). See attached screenshots. When I import MyFramework and use classes from the framework, the app compiles fine but got linker errors. It seems Xcode does not automatically link the bundle into the app.
Replies
2
Boosts
0
Views
574
Activity
Aug ’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?
Replies
1
Boosts
0
Views
345
Activity
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'
Replies
3
Boosts
0
Views
791
Activity
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).
Replies
0
Boosts
0
Views
1k
Activity
Sep ’23
How expand first root node when NSOutlineView is done with loading
I want to expand the first only root node when NSOutlineView is finished loading all data. How to get notified in code (possibly by some delegate function)?
Replies
1
Boosts
0
Views
407
Activity
Sep ’23