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

All subtopics

Post

Replies

Boosts

Views

Activity

What does ".island" suffix in symbol name mean?
During my analysis of the binary size changes after compiling Swift source code, I discovered symbols with the ".island" suffix. I couldn't find meaningful information about this suffix through my search, so I decided to reach out for assistance. While comparing the changes in binary size after modifying specific code, I noticed a significant increase (from 33MB to 520MB). Upon analyzing the symbols of the enlarged binary using the nm command, I found the following pattern: t _$s12{SomeSymbol}WOb t _$s12{SomeSymbol}WOb.island t _$s12{SomeSymbol}WOb.island2 t _$s12{SomeSymbol}WOb.island3 When I output the symbols of the binary using nm, I noticed many symbols with the same name but different ".island", ".island2", ".island3" suffixes. Disassembling the binary showed that functions with these suffixes simply delegate calls sequentially: x.island3 -> x.island2 -> x.island1 -> x. It appears that these symbols serve as delegates for function calls, but I would like to understand why such duplicated functions with these suffixes are generated. Could someone help me to provide some insights on this matter?
0
0
48
6h
Version 15.4 (15F31d) Xcode NSAppleScript of Safari broken
All attempts to script Safari in Xcode using NSAppleScript returns the following message. error: { NSAppleScriptErrorAppName = Safari; NSAppleScriptErrorBriefMessage = "Application isn\U2019t running."; NSAppleScriptErrorMessage = "Safari got an error: Application isn\U2019t running."; NSAppleScriptErrorNumber = "-600"; NSAppleScriptErrorRange = "NSRange: {32, 3}"; } Latest script attempt: func getHTML() -> String { let source = """ tell application "Safari" get URL of tab 1 of window 1 end tell """ //print(source) var a = "hello" var error: NSDictionary? if let scriptObject = NSAppleScript(source: source) { if let scriptResult = scriptObject.executeAndReturnError(&error).stringValue { a = scriptResult print(scriptResult) } else if (error != nil) { print("error: ",error!) } } return a }
0
0
37
7h
xcode16 beta not support iAd
May I ask how to adapt to devices using ADClient under iOS 14.3? xcode version: 16.0 beta (16A5171c) error message:Use of undeclared identifier 'ADClient' if (@available(iOS 14.3, *)) { NSError *error = nil; NSString *token = [AAAttribution attributionTokenWithError:&error]; } else { if ([[ADClient sharedClient] respondsToSelector:@selector(requestAttributionDetailsWithBlock:)]) { [[ADClient sharedClient] requestAttributionDetailsWithBlock:^(NSDictionary<NSString *, NSObject *> * _Nullable attributionDetails, NSError * _Nullable error) { }]; } }
1
0
52
1d
Create code at runtime on iOS: possible any more?
I'm the developer of 8th (https://8th-dev.com), which compiles the program at run-time, on the device. There used to be an iOS version which worked, but it seems things have changed since then. I'm trying to distribute an iOS version of an app written in 8th, and am encountering "SIGKILL - CODESIGNING" when trying to execute freshly compiled code. I am doing the 'sys_icache_invalidate' thing after writing into a mmap'ed bit of memory (rwx). I'm not writing into memory that was codesigned, so I don't know why the error is that. Anyway, the question is: is it possible any more to do what I used to be able to do?
4
1
87
19h
Bug Report: 'consume' Applied to Unsupported Value
'consume' applied to value that the compiler does not support. This is a compiler bug. Please file a bug with a small example of the bug. public func requestTopicsAndSubTopics() async throws -> (topics: [Topic], subTopics: [String: [SubTopic]]) { var subTopics = [String: [SubTopic]]() let topics = try await getTopics().sorted { $0.index < $1.index } try await withThrowingTaskGroup(of: ([SubTopic], String).self) { [weak self] group in guard let self else { return } for topic in topics { guard let topicId = topic.id else { throw Error.missingId } group.addTask { let subTopics = try await self.getSubtopics(topicId: topicId).sorted { $0.name < $1.name } return (consume subTopics, topicId) } } for try await (resultedSubTopics, topicId) in group { subTopics.updateValue(resultedSubTopics, forKey: topicId) } } return (consume topics, consume subTopics) }
1
0
86
1d
Link to a Precompiled Static C Library in a Swift Library Package
I want to build a Swift library package that uses modified build of OpenSSL and Curl. I have already statically compiled both and verified I can use them in an Objective-C framework on my target platform (iOS & iOS Simulator). I'm using XCFramework files that contain the static library binaries and headers: openssl.xcframework/ ios-arm64/ openssl.framework/ Headers/ [...] openssl ios-arm64_x86_64-simulator/ openssl.framework/ Headers/ [...] openssl Info.plist I'm not sure how I'm supposed to set up my Swift package to import these libraries. I can use .systemLibrary but that seems to use the embedded copies of libssl and libcurl on my system, and I can't figure out how to use the path: parameter to that. I also tried using a .binaryTarget pointing to the XCFramework files, but that didn't seem to work as there is no module generated and I'm not sure how to make one myself. At a basic high level, this is what I'm trying to accomplish: where libcrypto & libssl come from the provided openssl.xcframework file, and libcurl from curl.xcframework
6
0
155
6d
xcode16 beta not support iAd
May I ask how to adapt to devices using ADClient under iOS 14.3? xcode version: 16.0 beta (16A5171c) error message:Use of undeclared identifier 'ADClient' if (@available(iOS 14.3, *)) { NSError *error = nil; NSString *token = [AAAttribution attributionTokenWithError:&error]; } else { if ([[ADClient sharedClient] respondsToSelector:@selector(requestAttributionDetailsWithBlock:)]) { [[ADClient sharedClient] requestAttributionDetailsWithBlock:^(NSDictionary<NSString *, NSObject *> * _Nullable attributionDetails, NSError * _Nullable error) { }]; } }
1
0
82
1d
Multiple async lets crash the app
Usage of multiple async lets crashes the app in a nondeterministic fashion. We are experiencing this crash in production, but it is rare. 0 libswift_Concurrency.dylib 0x20a8b89b4 swift_task_create_commonImpl(unsigned long, swift::TaskOptionRecord*, swift::TargetMetadata<swift::InProcess> const*, void (swift::AsyncContext* swift_async_context) swiftasynccall*, void*, unsigned long) + 384 1 libswift_Concurrency.dylib 0x20a8b6970 swift_asyncLet_begin + 36 We managed to isolate the issue, and we submitted a technical incident (Case-ID: 8007727). However, we were completely ignored, and referred to the developer forums. To reproduce the bug you need to run the code on a physical device and under instruments (we used swift concurrency). This bug is present on iOS 17 and 18, Xcode 15.1, 15.4 and 16 beta, swift 5 and 6, including strict concurrency. Here's the code for Swift 6 / Xcode 16 / strict concurrency: (I wanted to attach the project but for some reason I am unable to) typealias VoidHandler = () -> Void enum Fetching { case inProgress, idle } protocol PersonProviding: Sendable { func getPerson() async throws -> Person } actor PersonProvider: PersonProviding { func getPerson() async throws -> Person { async let first = getFirstName() async let last = getLastName() async let age = getAge() async let role = getRole() return try await Person(firstName: first, lastName: last, age: age, familyMemberRole: role) } private func getFirstName() async throws -> String { try await Task.sleep(nanoseconds: 1_000_000_000) return ["John", "Kate", "Alex"].randomElement()! } private func getLastName() async throws -> String { try await Task.sleep(nanoseconds: 1_400_000_000) return ["Kowalski", "McMurphy", "Grimm"].randomElement()! } private func getAge() async throws -> Int { try await Task.sleep(nanoseconds: 2_100_000_000) return [56, 24, 11].randomElement()! } private func getRole() async throws -> Person.Role { try await Task.sleep(nanoseconds: 500_000_000) return Person.Role.allCases.randomElement()! } } @MainActor final class ViewModel { private let provider: PersonProviding = PersonProvider() private var fetchingTask: Task<Void, Never>? let onFetchingChanged: (Fetching) -> Void let onPersonFetched: (Person) -> Void init(onFetchingChanged: @escaping (Fetching) -> Void, onPersonFetched: @escaping (Person) -> Void) { self.onFetchingChanged = onFetchingChanged self.onPersonFetched = onPersonFetched } func fetchData() { fetchingTask?.cancel() fetchingTask = Task { do { onFetchingChanged(.inProgress) let person = try await provider.getPerson() guard !Task.isCancelled else { return } onPersonFetched(person) onFetchingChanged(.idle) } catch { print(error) } } } } struct Person { enum Role: String, CaseIterable { case mum, dad, brother, sister } let firstName: String let lastName: String let age: Int let familyMemberRole: Role init(firstName: String, lastName: String, age: Int, familyMemberRole: Person.Role) { self.firstName = firstName self.lastName = lastName self.age = age self.familyMemberRole = familyMemberRole } } import UIKit class ViewController: UIViewController { @IBOutlet private var first: UILabel! @IBOutlet private var last: UILabel! @IBOutlet private var age: UILabel! @IBOutlet private var role: UILabel! @IBOutlet private var spinner: UIActivityIndicatorView! private lazy var viewModel = ViewModel(onFetchingChanged: { [weak self] state in switch state { case .idle: self?.spinner.stopAnimating() case .inProgress: self?.spinner.startAnimating() } }, onPersonFetched: { [weak self] person in guard let self else { return } first.text = person.firstName last.text = person.lastName age.text = "\(person.age)" role.text = person.familyMemberRole.rawValue }) @IBAction private func onTap() { viewModel.fetchData() } }
1
0
78
2d
Decoding JSON with a reserved property name
I need to decode JSON into a class. The JSON has a field called "Type", and I cannot declare a property with that name in my class since Type is a reserved word. I tried declaring CodingKeys, but that doesn't work unless I declare EVERY property in the CodingKeys. This class has about a hundred properties and I have others like it, I do not want to do this. Is there a better solution?
2
0
80
2d
Failed to produce diagnostic for expression; please submit a bug report
I got the error and I don’t how can I fix it help please struct MovieDetail: View { var movie: Movie let screen = UIScreen.main.bounds @State private var showSeasonPicker = true @State private var selectedSeason = 0 var body: some View { ZStack { Color.black .ignoresSafeArea() ZStack { VStack { HStack { Spacer() Button() { // Closing Button }label: { Image(systemName: "xmark.circle") .font(.system(size: 28)) } } .padding(.horizontal, 22) ScrollView (.vertical, showsIndicators: false){ VStack { StandardHomeMovie(movie: movie) .frame(width: screen.width / 2.5) MovieInfoSubheadline(movie: movie) if movie.promotionHeadline != nil { Text(movie.promotionHeadline!) .bold() .font(.headline) } PlayButton(text: "Play", imagename: "play.fill", backgroundColor: .red) { // } CurrentEpisodeInformation(movie: movie) CastInfo(movie: movie) HStack(spacing: 60){ SmallVerticalButton(text: "My List", isOnImage: "checkmark", isOffImage: "plus", isOn: true) { // } SmallVerticalButton(text: "Rate", isOnImage: "hand.thumbsup.fill", isOffImage: "hand.thumbsup", isOn: true) { // } SmallVerticalButton(text: "Share", isOnImage: "square.and.arrow.up", isOffImage: "square.and.arrow.up", isOn: true) { // } Spacer() } .padding(.leading, 20) CustomTabSwitcher(tabs: [.episodes, .trailers, .more], movie: movie, showSeasonPicker: $showSeasonPicker, selectedSeason: $selectedSeason) } .padding(.horizontal, 10) } Spacer() } .foregroundStyle(.white) if showSeasonPicker { Group { Color.black.opacity(0.9) VStack(spacing: 40){ Spacer() ForEach(0..<(movie.numberOfSeasons ?? 0)) { season in Button(action: { self.selectedSeason = (season != 0) self.showSeasonPicker = false }, label: { Text("Season: \(season + 1)") .foregroundStyle(selectedSeason == season + 1 ? .white : .gray) .bold() .font(.title2) }) } Spacer() Button(action: { self.showSeasonPicker = false }, label: { Image(systemName: "xmark.circle.fill") .foregroundStyle(.white) .font(.system(size: 40)) .scaleEffect(x: 1.1) }) .padding(.bottom, 30) } } .ignoresSafeArea() } } } } } #Preview { MovieDetail(movie: exampleMovie2) } struct MovieInfoSubheadline: View { var movie: Movie var body: some View { HStack(spacing: 20){ Image(systemName: "hand.thumbsup.fill") .foregroundStyle(.white) Text(String(movie.year)) RatingView(rating: movie.rating) Text(movie.numberOfSeasonsDisplay) ZStack{ Text("HD") .foregroundStyle(.white) .font(.system(size: 12)) .bold() Rectangle() .stroke(.gray, lineWidth: 2) .frame(width: 30, height: 20) } } .foregroundStyle(.gray) .padding(.vertical, 6) } } struct RatingView: View { var rating: String var body: some View { ZStack { Rectangle() .foregroundStyle(.gray) Text(rating) .foregroundStyle(.white) .font(.system(size: 12)) .bold() } .frame(width: 50, height: 20) } } struct CastInfo: View { var movie: Movie var body: some View { VStack(spacing: 3) { HStack { Text("Cast: \(movie.cast)") Spacer() } HStack { Text("Creaters: \(movie.creaters)") Spacer() } } .font(.caption) .foregroundStyle(.gray) .padding(.vertical, 10) } } struct CurrentEpisodeInformation: View { var movie: Movie var body: some View { Group { HStack { Text(movie.episodeInfoDisplay) .bold() Spacer() } .padding(.vertical, 4) HStack { Text(movie.episodeDescriptionDisplay) .font(.subheadline) Spacer() } } } }
2
0
90
2d
iOS Developer Beta 18
I want to ask about NSDecimalNumber. is it any changes for use this function ? i test use number like this. example: a = "1000000.0" var a i make number formatter use NumberFormatter b = NSDecimalNumber(string: a with number formatter).decimalValue i try to print b. the value return 1. Anyone can help ?
4
0
125
1w
Issue with Swift and C++ Interoperability: Passing void pointer between Swift and C++
Hello everyone, I'm encountering an issue with Swift and C++ interoperability when passing a void pointer between Swift and C++ functions. When I pass pMessageBuffer (an UnsafeMutableRawPointer) from Swift to MyCppClass.NFCompletion (a static c++ function), which expects a reference to void pointer, Swift throws an error "Cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'Optional' ". Here is a sample code to help in better visualization of the usecase. Cpp Code class MyCppClass { public: static void SendData(void *pMessage, TUInt16 pMessageLength) { // Assume vSocket is my Swift object held in C++. vSocket.Send(pMessage, pMessageLength); } static void NFCompletion(void * & pBuffer, TInt64 pErrorCode, VPtr pCompletionFunction) { // Process the buffer. } }; Swift Code: public class MySwiftClass { var vConnection: NWConnection? public init() {} public func Send(_ pMessageBuffer: UnsafeMutableRawPointer, _ pMessageLength: TSUInt16) { let messageData = Data(bytesNoCopy: pMessageBuffer, count: Int(pMessageLength), deallocator: .none) self.vConnection?.send(content: messageData, completion: .contentProcessed { nw_error in var error_code: TSInt64 = 0 if let nw_error = nw_error { error_code = self.InternalGetNetworkErrorCode(nw_error) } // Here's where the issue arises: MyCppClass.NFCompletion(pMessageBuffer, TInt64(error_code), self.uCompletionHandler) }) } // Example function to handle network errors private func InternalGetNetworkErrorCode(_ error: Error) -> TSInt64 { // Implementation to convert nw_error to TSInt64 error code return 0 // Placeholder return value } } Could someone please help me understand why this conversion error occurs? How should I correctly handle passing a void pointer between Swift and C++ functions, ensuring compatibility and proper memory management? Note: TSInt64 is typealias for swift Int and TInt64 is alias of c++ int_64t. Thank you in advance for your assistance! Regards, Harshal
1
2
154
2w
Swift Syntax Comment Trivia - Expected prefixes
Hello! I am working on a project that does some automatic code generation using SwiftSyntax and SwiftSyntaxBuilder. As part of this project, I want to put in a comment at the top of the file warning users to not modify the file and make it obvious that the code was automatically generated. I was trying to use the .lineComment(String) static member of the Trivia (or TriviaPiece) types and I expected that the comment would automatically be prefixed with the expected // and space for use in code. (For example, Trivia.lineComment("No comment") would be written as // No Comment when sent through a BasicFormat Object or similar SyntaxRewriter). I was surprised to find that this is not the case and was wondering before I write an issue on GitHub whether this behavior is intentional or a bug. If it is intentional, I'm not entirely sure if I'm missing something regarding this to more easily generate these comments. At the moment my comment generation consists of constructing the comment in the leadingTrivia of the syntax node that appears after the comment. For example: VariableDeclSyntax(leadingTrivia: [.newlines(2), .lineComment("// These members are always generated irrespective of the contents of the generated files. They are intended to exclusively centralize code symbols that would otherwise be repeated frequently."), .newlines(1)], modifiers: [DeclModifierSyntax(name: .keyword(.private)), DeclModifierSyntax(name: .keyword(.static))], .let, name: PatternSyntax(IdentifierPatternSyntax(identifier: "decoder")), initializer: InitializerClauseSyntax(value: ExprSyntax(stringLiteral: "\(configuration.decoderExpression)"))) outputs // These members are always generated irrespective of the contents of the generated files. They are intended to exclusively centralize code symbols that would otherwise be repeated frequently. private static let decoder = JSONDecoder() in this project (with example data having been added).
1
0
172
1w
dyld[11387]: Library not loaded: @loader_path/../../../../opt/icu4c/lib/libicuio.73.dylib
When I Run Php Artisan Command in PhpStorm Laravel Project The below results show in the terminal. dyld[11387]: Library not loaded: @loader_path/../../../../opt/icu4c/lib/libicuio.73.dylib Referenced from: &lt;27B43AEF-470B-32CD-9521-AA834300394F&gt; /usr/local/Cellar/php/8.2.10/bin/php Reason: tried: '/usr/local/Cellar/php/8.2.10/bin/../../../../opt/icu4c/lib/libicuio.73.dylib' (no such file), '/usr/local/lib/libicuio.73.dylib' (no such file), '/usr/lib/libicuio.73.dylib' (no such file, not in dyld cache) zsh: abort php artisan
1
0
170
2w
Exclude C runtime library from linking?
Hi, I am writing my own little toy programming language and when I try to link the binary object file (.o file) it requires a _main symbol. I wonder if there is a way to exclude this, presumably, a C runtime requirement? Is it safe to provide a stub _main symbol, or provide a the _main as the entry point to my own little runtime? What is the correct way to invoke the linker with the appropriate flags?
2
0
129
1w