Dive into the world of programming languages used for app development.

All subtopics
Posts under Programming Languages topic

Post

Replies

Boosts

Views

Activity

Programming Languages Resources
This topic area is about the programming languages themselves, not about any specific API or tool. If you have an API question, go to the top level and look for a subtopic for that API. If you have a question about Apple developer tools, start in the Developer Tools & Services topic. For Swift questions: If your question is about the SwiftUI framework, start in UI Frameworks > SwiftUI. If your question is specific to the Swift Playground app, ask over in Developer Tools & Services > Swift Playground If you’re interested in the Swift open source effort — that includes the evolution of the language, the open source tools and libraries, and Swift on non-Apple platforms — check out Swift Forums If your question is about the Swift language, that’s on topic for Programming Languages > Swift, but you might have more luck asking it in Swift Forums > Using Swift. General: Forums topic: Programming Languages Swift: Forums subtopic: Programming Languages > Swift Forums tags: Swift Developer > Swift website Swift Programming Language website The Swift Programming Language documentation Swift Forums website, and specifically Swift Forums > Using Swift Swift Package Index website Concurrency Resources, which covers Swift concurrency How to think properly about binding memory Swift Forums thread Other: Forums subtopic: Programming Languages > Generic Forums tags: Objective-C Programming with Objective-C archived documentation Objective-C Runtime documentation Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com"
0
0
869
Oct ’25
How to set the custom DNS with the Network client
We are facing a DNS resolution issue with a specific ISP, where our domain name does not resolve correctly using the system DNS. However, the same domain works as expected when a custom DNS resolver is used. On Android, this is straightforward to handle by configuring a custom DNS implementation using OkHttp / Retrofit. I am trying to implement a functionally equivalent solution in native iOS (Swift / SwiftUI). Android Reference (Working Behavior) : val dns = DnsOverHttps.Builder() .client(OkHttpClient()) .url("https://cloudflare-dns.com/dns-query".toHttpUrl()) .bootstrapDnsHosts(InetAddress.getByName("1.1.1.1")) .build() OkHttpClient.Builder() .dns(dns) .build() Attempted iOS Approach I attempted the following approach : Resolve the domain to an IP address programmatically (using DNS over HTTPS) Connect directly to the resolved IP address Set the original domain in the Host HTTP header DNS Resolution via DoH : func resolveDomain(domain: String) async throws -> String {     guard let url = URL(         string: "https://cloudflare-dns.com/dns-query?name=\(domain)&type=A"     ) else {         throw URLError(.badURL)     }     var request = URLRequest(url: url)     request.setValue("application/dns-json", forHTTPHeaderField: "accept")     let (data, _) = try await URLSession.shared.data(for: request)     let response = try JSONDecoder().decode(DNSResponse.self, from: data)     guard let ip = response.Answer?.first?.data else {         throw URLError(.cannotFindHost)     }     return ip } API Call Using Resolved IP :  func callAPIUsingCustomDNS() async throws {     let ip = try await resolveDomain(domain: "example.com")     guard let url = URL(string: "https://(ip)") else {         throw URLError(.badURL)     }     let configuration = URLSessionConfiguration.ephemeral     let session = URLSession(         configuration: configuration,         delegate: CustomURLSessionDelegate(originalHost: "example.com"),         delegateQueue: .main     )     var request = URLRequest(url: url)     request.setValue("example.com", forHTTPHeaderField: "Host")     let (_, response) = try await session.data(for: request)     print("Success: (response)") } Problem Encountered When connecting via the IP address, the TLS handshake fails with the following error: Error Domain=NSURLErrorDomain Code=-1200 "A TLS error caused the secure connection to fail." This appears to happen because iOS sends the IP address as the Server Name Indication (SNI) during the TLS handshake, while the server’s certificate is issued for the domain name. Custom URLSessionDelegate Attempt :  class CustomURLSessionDelegate: NSObject, URLSessionDelegate {     let originalHost: String     init(originalHost: String) {         self.originalHost = originalHost     }     func urlSession(         _ session: URLSession,         didReceive challenge: URLAuthenticationChallenge,         completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void     ) {         guard challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,               let serverTrust = challenge.protectionSpace.serverTrust else {             completionHandler(.performDefaultHandling, nil)             return         }         let sslPolicy = SecPolicyCreateSSL(true, originalHost as CFString)         let basicPolicy = SecPolicyCreateBasicX509()         SecTrustSetPolicies(serverTrust, [sslPolicy, basicPolicy] as CFArray)         var error: CFError?         if SecTrustEvaluateWithError(serverTrust, &error) {             completionHandler(.useCredential, URLCredential(trust: serverTrust))         } else {             completionHandler(.cancelAuthenticationChallenge, nil)         }     } } However, TLS validation still fails because the SNI remains the IP address, not the domain. I would appreciate guidance on the supported and App Store–compliant way to handle ISP-specific DNS resolution issues on iOS. If custom DNS or SNI configuration is not supported, what alternative architectural approaches are recommended by Apple?
0
0
63
16h
Passkit generator vulnerabilities issue
We are getting vulnerabilities for passkit generator, used for apple wallet creation. Could you please suggest how to resolve this issue In our system we updated MIME with latest version but passkit is referring older version 1.4.1 npm audit report mime <1.4.1 Severity: high mime Regular Expression Denial of Service when MIME lookup performed on untrusted user input - https://github.com/advisories/GHSA-wrvr-8mpx-r7pp No fix available node_modules/mime passkit * Depends on vulnerable versions of mime node_modules/passkit 2 high severity vulnerabilities Some issues need review, and may require choosing a different dependency.
0
0
58
17h
iOS doesn’t switch back to home router + socket connect failure in AP mode
In iOS AP-mode onboarding for IOT devices, why does the iPhone sometimes stay stuck on the device Wi-Fi (no internet) and fail to route packets to the device’s local IP, even though SSID is correct? Sub-questions to include: • Is this an iOS Wi-Fi auto-join priority issue? • Can AP networks become “sticky” after multiple joins? • How does iOS choose the active routing interface when Wi-Fi has no gateway? • Why does the packet never reach the device even though NWPath shows WiFi = satisfied?
0
0
63
17h
Update or remove Ruby 2.6
macOS Tahoe ships with Ruby 2.6.10 which was End Of Life in April 2022 (https://www.ruby-lang.org/en/downloads/branches/). How can I either upgrade it to Ruby 3.4.7 or delete it, so that my mac meets minimum cybersecurity requirements? I use rbenv for more recent versions of Ruby at the moment so don't need any suggestions on how to do add them, I just need rid of the dangerously out of date system Ruby, thanks.
6
0
1k
6d
Compiler exception when using Binding and Swift 6
In my code I use a binding that use 2 methods to get and get a value. There is no problem with swift 5 but when I swift to swift 6 the compiler fails : Here a sample example of code to reproduce the problem : `import SwiftUI struct ContentView: View { @State private var isOn = false var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") Toggle("change it", isOn: Binding(get: getValue, set: setValue(_:))) } .padding() } private func getValue() -&gt; Bool { isOn } private func setValue(_ value: Bool) { isOn = value } }` Xcode compiler log error : 1. Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5) 2. Compiling with the current language version 3. While evaluating request IRGenRequest(IR Generation for file "/Users/xavierrouet/Developer/TestCompilBindingSwift6/TestCompilBindingSwift6/ContentView.swift") 4. While emitting IR SIL function "@$sSbScA_pSgIeAghyg_SbIeAghn_TR". for &lt;&lt;debugloc at "&lt;compiler-generated&gt;":0:0&gt;&gt;Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var LLVM_SYMBOLIZER_PATH` to point to it): 0 swift-frontend 0x000000010910ae24 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) + 56 1 swift-frontend 0x0000000109108c5c llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x000000010910b460 SignalHandler(int) + 360 3 libsystem_platform.dylib 0x0000000188e60624 _sigtramp + 56 4 libsystem_pthread.dylib 0x0000000188e2688c pthread_kill + 296 5 libsystem_c.dylib 0x0000000188d2fc60 abort + 124 6 swift-frontend 0x00000001032ff9a8 swift::DiagnosticHelper::~DiagnosticHelper() + 0 7 swift-frontend 0x000000010907a878 llvm::report_fatal_error(llvm::Twine const&amp;, bool) + 280 8 swift-frontend 0x00000001090aef6c report_at_maximum_capacity(unsigned long) + 0 9 swift-frontend 0x00000001090aec7c llvm::SmallVectorBase::grow_pod(void*, unsigned long, unsigned long) + 384 10 swift-frontend 0x000000010339c418 (anonymous namespace)::SyncCallEmission::setArgs(swift::irgen::Explosion&amp;, bool, swift::irgen::WitnessMetadata*) + 892 11 swift-frontend 0x00000001035f8104 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 4792 12 swift-frontend 0x00000001035c876c (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 2636 13 swift-frontend 0x00000001035c6614 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 15860 14 swift-frontend 0x00000001035c2368 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 2788 15 swift-frontend 0x00000001033e7c1c swift::irgen::IRGenerator::emitLazyDefinitions() + 5288 16 swift-frontend 0x0000000103573d6c swift::IRGenRequest::evaluate(swift::Evaluator&amp;, swift::IRGenDescriptor) const + 4528 17 swift-frontend 0x00000001035c15c4 swift::SimpleRequest&lt;swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)17&gt;::evaluateRequest(swift::IRGenRequest const&amp;, swift::Evaluator&amp;) + 180 18 swift-frontend 0x000000010357d1b0 swift::IRGenRequest::OutputType swift::Evaluator::getResultUncached&lt;swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatalswift::IRGenRequest(swift::Evaluator&amp;, swift::IRGenRequest)::'lambda'()&gt;(swift::IRGenRequest const&amp;, swift::IRGenRequest::OutputType swift::evaluateOrFatalswift::IRGenRequest(swift::Evaluator&amp;, swift::IRGenRequest)::'lambda'()) + 812 19 swift-frontend 0x0000000103576910 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&amp;, swift::TBDGenOptions const&amp;, std::__1::unique_ptr&lt;swift::SILModule, std::__1::default_deleteswift::SILModule&gt;, llvm::StringRef, swift::PrimarySpecificPaths const&amp;, llvm::StringRef, llvm::GlobalVariable**) + 176 20 swift-frontend 0x0000000102f61af0 generateIR(swift::IRGenOptions const&amp;, swift::TBDGenOptions const&amp;, std::__1::unique_ptr&lt;swift::SILModule, std::__1::default_deleteswift::SILModule&gt;, swift::PrimarySpecificPaths const&amp;, llvm::StringRef, llvm::PointerUnion&lt;swift::ModuleDecl*, swift::SourceFile*&gt;, llvm::GlobalVariable*&amp;, llvm::ArrayRef&lt;std::__1::basic_string&lt;char, std::__1::char_traits, std::__1::allocator&gt;&gt;) + 156 21 swift-frontend 0x0000000102f5d07c performCompileStepsPostSILGen(swift::CompilerInstance&amp;, std::__1::unique_ptr&lt;swift::SILModule, std::__1::default_deleteswift::SILModule&gt;, llvm::PointerUnion&lt;swift::ModuleDecl*, swift::SourceFile*&gt;, swift::PrimarySpecificPaths const&amp;, int&amp;, swift::FrontendObserver*) + 2108 22 swift-frontend 0x0000000102f5c0a8 swift::performCompileStepsPostSema(swift::CompilerInstance&amp;, int&amp;, swift::FrontendObserver*) + 1036 23 swift-frontend 0x0000000102f5f654 performCompile(swift::CompilerInstance&amp;, int&amp;, swift::FrontendObserver*) + 1764 24 swift-frontend 0x0000000102f5dfd8 swift::performFrontend(llvm::ArrayRef&lt;char const*&gt;, char const*, void*, swift::FrontendObserver*) + 3716 25 swift-frontend 0x0000000102ee20bc swift::mainEntry(int, char const**) + 5428 26 dyld 0x0000000188a86b98 start + 6076 Using Xcode 16.4 / Mac OS 16.4
4
0
926
1w
App mysteriously crashing in CFNetwork.LoaderQ queue
I’m stuck with repeated production crashes in my SwiftUI app and I can’t make sense of the traces on my own. The symbolicated reports show the same pattern: Crash on com.apple.CFNetwork.LoaderQ with EXC_BAD_ACCESS / PAC failure Always deep in CFNetwork, most often in URLConnectionLoader::loadWithWhatToDo(NSURLRequest*, _CFCachedURLResponse const*, long, URLConnectionLoader::WhatToDo) No frames from my code, no sign of AuthManager or tokens. What I’ve tried: Enabled Address Sanitizer, Malloc Scribble, Guard Malloc, Zombies. Set CFNETWORK_DIAGNOSTICS=3 and collected Console logs. Stress-tested the app (rapid typing, filter switching, background/foreground, poor network with Network Link Conditioner). Could not reproduce the crash locally. So far: Logs show unrelated performance faults (I/O on main thread, CLLocationManager delegate), but no obvious CFNetwork misuse. My suspicion is a URLSession lifetime or delegate/auth-challenge race, but I can’t confirm because I can’t trigger it. Since starting this investigation, I also refactored some of my singletons into @State/@ObservedObject dependencies. For example, my app root now wires up AuthManager, BackendService, and AccountManager (where API calls happen using async/await) as @State properties: @State var authManager: AuthManager @State var accountManager: AccountManager @State var backendService: BackendService init() { let authManager = AuthManager() self._authManager = .init(wrappedValue: authManager) let backendService = BackendService(authManager: authManager) self._backendService = .init(wrappedValue: backendService) self._accountManager = .init(wrappedValue: AccountManager(backendService: backendService)) } I don’t know if this refactor is related to the crash, but I am including it to be complete. Apologies that I don’t have a minimized sample project — this issue seems app-wide, and all I have are the crash logs. Request: Given the crash location (URLConnectionLoader::loadWithWhatToDo), can Apple provide guidance on known scenarios or misuses that can lead to this crash? Is there a way to get more actionable diagnostics from CFNetwork beyond CFNETWORK_DIAGNOSTICS to pinpoint whether it’s session lifetime, cached response corruption, or auth/redirect? Can you also confirm whether my dependency setup above could contribute to URLSession or backend lifetime issues? I can’t reliably reproduce the crash, and without Apple’s insight the stack trace is effectively opaque to me. Thanks for your time and help. Happy to send multiple symbolicated crash logs at request. Thanks for any help. PS. Including 2 of many similar crash logs. Can provide more if needed. Atlans-2025-07-29-154915_symbolicated (cfloader).txt Atlans-2025-08-08-124226_symbolicated (cfloader).txt
5
0
3.7k
1w
NotificationCenter Crash On iOS 18+ Swift6.2
After switching our iOS app project from Swift 5 to Swift 6 and publishing an update, we started seeing a large number of crashes in Firebase Crashlytics. The crashes are triggered by NotificationCenter methods (post, addObserver, removeObserver) and show the following error: BUG IN CLIENT OF LIBDISPATCH: Assertion failed: Block was expected to execute on queue [com.apple.main-thread (0x1f9dc1580)] All scopes to related calls are already explicitly marked with @MainActor. This issue never occurred with Swift 5, but appeared immediately after moving to Swift 6. Has anyone else encountered this problem? Is there a known solution or workaround? Thanks in advance!
2
1
1.4k
2w
Async function doesn’t see external changes to an inout Bool in Release build
Title Why doesn’t this async function see external changes to an inout Bool in Release builds (but works in Debug)? Body I have a small helper function that waits for a Bool flag to become true with a timeout: public func test(binding value: inout Bool, timeout maximum: Int) async throws { var count = 0 while value == false { count += 1 try await Task.sleep(nanoseconds: 0_100_000_000) if value == true { return } if count > (maximum * 10) { return } } } I call like this: var isVPNConnected = false adapter.start(tunnelConfiguration: tunnelConfiguration) { [weak self] adapterError in guard let self = self else { return } if let adapterError = adapterError { } else { isVPNConnected = true } completionHandler(adapterError) } try await waitUntilTrue(binding: &isVPNConnected, timeout: 10) What I expect: test should keep looping until flag becomes true (or the timeout is hit). When the second task sets flag = true, the first task should see that change and return. What actually happens: In Debug builds this behaves as expected: when the second task sets flag = true, the loop inside test eventually exits. In Release builds the function often never sees the change and gets stuck until the timeout (or forever, depending on the code). It looks like the while value == false condition is using some cached value and never observes the external write. So my questions are: Is the compiler allowed to assume that value (the inout Bool) does not change inside the loop, even though there are await suspension points and another task is mutating the same variable? Is this behavior officially “undefined” because I’m sharing a plain Bool across tasks without any synchronization (actors / locks / atomics), so the debug build just happens to work? What is the correct / idiomatic way in Swift concurrency to implement this kind of “wait until flag becomes true with timeout” pattern? Should I avoid inout here completely and use some other primitive (e.g. AsyncStream, CheckedContinuation, Actor, ManagedAtomic, etc.)? Is there any way to force the compiler to re-read the Bool from memory each iteration, or is that the wrong way to think about it? Environment (if it matters): Swift: [fill in your Swift version] Xcode: [fill in your Xcode version] Target: iOS / macOS [fill in as needed] Optimization: default Debug vs. Release settings I’d like to understand why Debug vs Release behaves differently here, and what the recommended design is for this kind of async waiting logic in Swift.
2
0
1.1k
3w
Adding days to a date using the result of a division operation
var testTwo: Double = 0 testDouble = 80 testTwo = 200 var testThree: Int = 0 testThree = Int(testTwo/testDouble) var testDate: Date = .now var dateComponent = DateComponents() dateComponent.day = testThree var newDate: Date = Calendar.current.date(byAdding: dateComponentwith a thread error , to: testDate)! This code works in a playground. However, when I try to use it in Xcode for my app it fails with the following error: Thread 1: Fatal error: Double value cannot be converted to Int because it is either infinite or NaN I printed the value being converted to Int and it was not NAN or infinite.
2
0
742
3w
Basic c++ main xcodeproj call to swift struct
I can't find any simple c++ xcodeproj call to swift struct using modern c++ swift mix. there is the fibonacci example that is swift app call to c++. Base on fibonacci example I create new simple project and fail to build it with error when I try to include #include <SwiftMixTester/SwiftMixTester-Swift.h> What is wrong? Is it the right place to ask this? Any work project link? Xcode 26.
1
0
869
Oct ’25
Basic c++xcodeproj call to swift code
I have c++ macOs app(Xcode +14) and I try to add call to swift code. I can't find any simple c++ xcodeproj call to swift code. I create new simple project and fail to build it with error when I try to include #include <SwiftMixTester/SwiftMixTester-Swift.h>: main.m:9:10: error: 'SwiftMixTester/SwiftMixTester-Swift.h' file not found (in target 'CppCallSwift' from project 'CppCallSwift') note: Did not find header 'SwiftMixTester-Swift.h' in framework 'SwiftMixTester' (loaded from '/Users/yanivsmacm4/Library/Developer/Xcode/DerivedData/CppCallSwift-exdxjvwdcczqntbkksebulvfdolq/Build/Products/Debug') . Please help.
5
0
409
Oct ’25
App sometimes crashes when inserting String into Set with assertion ELEMENT_TYPE_OF_SET_VIOLATES_HASHABLE_REQUIREMENTS
Xcode downloaded a crash report for my app that crashed when trying to insert a String into a Set<String>. Apparently there was an assertion failure ELEMENT_TYPE_OF_SET_VIOLATES_HASHABLE_REQUIREMENTS. I assume that this assertion failure happened because the hash of the new element didn't match the hash of an equal already inserted element, but regardless, I don't understand how inserting a simple string could trigger this assertion. Here is essentially the code that leads to the crash. path is any file system directory, and basePath is a directory higher in the hierarchy, or path itself. var scanErrorPaths = Set<String>() func main() { let path = "/path/to/directory" let basePath = "/path" let fileDescriptor = open(path, O_RDONLY) if fileDescriptor < 0 { if (try? URL(fileURLWithPath: path, isDirectory: false).checkResourceIsReachable()) == true { scanErrorPaths.insert(path.relativePath(from: basePath)!) return } } extension String { func relativePath(from basePath: String) -> String? { if basePath == "" { return self } guard let index = range(of: basePath, options: .anchored)?.upperBound else { return nil } return if index == endIndex || basePath == "/" { String(self[index...]) } else if let index = self[index...].range(of: "/", options: .anchored)?.upperBound { String(self[index...]) } else { nil } } } crash.crash
7
0
791
Oct ’25
Attrubute can only be applied to types not declarations
Error: "Attrubute can only be applied to types not declarations" on line 2 : @unchecked @unchecked enum ReminderRow : Hashable, Sendable { case date case notes case time case title var imageName : String? { switch self { case .date: return "calendar.circle" case .notes: return "square.and.pencil" case .time: return "clock" default : return nil } } var image : UIImage? { guard let imageName else { return nil } let configuration = UIImage.SymbolConfiguration(textStyle: .headline) return UIImage(systemName: imageName, withConfiguration: configuration) } var textStyle : UIFont.TextStyle { switch self { case .title : return .headline default : return .subheadline } } }
1
0
303
Oct ’25
"_swift_coroFrameAlloc", 报错
Undefined symbols for architecture arm64: "_swift_coroFrameAlloc", referenced from: NvMobileCore.Constraint.isActive.modify : Swift.Bool in NvMobileCore[5] NvMobileCore.Constraint.isActive.modify : Swift.Bool in NvMobileCore[5] NvMobileCore.NvMobileCoreManager.delegate.modify : NvMobileCore.NvPublicInterface? in NvMobileCore[53] NvMobileCore.NvMobileCoreManager.delegate.modify : NvMobileCore.NvPublicInterface? in NvMobileCore[53] NvMobileCore.NvMobileCoreManager.language.modify : Swift.String in NvMobileCore[53] NvMobileCore.NvMobileCoreManager.language.modify : Swift.String in NvMobileCore[53] ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
2
0
391
Oct ’25
Archive Failing for iPhoneOS SDK in Xcode 26
When i am trying to archive a framework for ML, using below command: xcodebuild -workspace "./src/MLProject.xcworkspace" -configuration "Release" -sdk "iphoneos" -archivePath "./gen/out/Archives/Release-iphoneos/MLProject" -scheme "MLProject" -derivedDataPath "./gen/out/" archive BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO The same command used to work fine on Xcode 16.4. Attached is the detailed error MLProject_Archive_failure.txt
1
1
110
Oct ’25
Beginner’s question on learning philosophy.
Hello Everyone! I started programming 6 months ago and started Swift / IOS last month. My learning so far has mainly been with Python. I learned a lot of the package ‘SQLAlchemy’, which has very ‘example based’ documentation. If I wanted to learn how to make a many to many relationship, there was a demonstration with code. But going into Swift and Apple packages, I notice most of the documentation is definitions of structures, modifiers, functions, etc. I wanted to make the equivalent of python ‘date times’ in my swift app. I found the section in the documentation “Foundation->Dates & Times”, but I couldn’t figure how to use that in my code. I assume my goal should not be to memorize every Swift and apple functionality by memory to be an app developer. So I would appreciate advice on how to approach this aspect of learning programming.
2
0
463
Oct ’25