iOS18.2 / iPhone16 pro / xcode16.2
'traitCollectionDidChange'
This function has been deprecated in iOS17.
However, when I debugged it, I confirmed that it is not called on iOS17, but it is called on iOS18.2.
What is the reason?
Dive into the world of programming languages used for app development.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello, I have an issue with importing some .mp3 files into a swift playground project (in Xcode, not in the Playground app). They worked fine in the Xcode project, but for some reason playgrounds isn't able to find them. I imported them the exact same way as I did in the Xcode project.
My application crash on iOS 16 randomly, stack trace like this:
libswiftCore.dylib __swift_release_dealloc + 32
libswiftNetwork.dylib outlined consume of (@escaping @callee_guaranteed (@in_guaranteed Network.NWConnection.State) -> ())? + 52
libswiftNetwork.dylib outlined consume of (@escaping @callee_guaranteed (@in_guaranteed Network.NWConnection.State) -> ())? + 52
libswiftCore.dylib __swift_release_dealloc + 56
libsystem_blocks.dylib __call_dispose_helpers_excp + 48
libsystem_blocks.dylib __Block_release + 252
libsystem_blocks.dylib bool HelperBase::disposeCapture<(HelperBase::BlockCaptureKind)4>(unsigned int, unsigned char*) + 68
libsystem_blocks.dylib HelperBase::destroyBlock(Block_layout*, bool, unsigned char*) + 180
libsystem_blocks.dylib __call_dispose_helpers_excp + 72
libsystem_blocks.dylib __Block_release + 252
libdispatch.dylib ___destroy_helper_block_8_32c35typeinfo name for dispatch_block_private_data_s + 96
libsystem_blocks.dylib __call_dispose_helpers_excp + 48
libsystem_blocks.dylib __Block_release + 252
libdispatch.dylib __dispatch_client_callout + 20
libdispatch.dylib __dispatch_root_queue_drain + 684
libdispatch.dylib __dispatch_worker_thread2 + 164
libsystem_pthread.dylib __pthread_wqthread + 228
From buly(a tool to report crash) we notice that this crash only happens on iOS 16
Topic:
Programming Languages
SubTopic:
Swift
Can i use c++ library with c library in swift app project
Hello. I want to use a C++ library in my Swift app project.
First, our company has an internal solution library.
When built, it generates a Static Library in '.a' format, and we use it by connecting the library's Header to the App_Bridging_Header.
There's no problem with this part.
However, the new feature now includes C++. It also generates a Static Library in '.a' format.
So, I tried to use the same method and created an App_Bridging_Header. But an error occurs, and I can't proceed.
The first error occurs in the library file:
'iostream' file not found
The second error occurs in the App_Bridging_Header:
failed to emit precompiled header '/Users/kimjitae/Library/Developer/Xcode/DerivedData/ddddd-glmnoqrwdrgarrhjulxjmalpyikr/Build/Intermediates.noindex/PrecompiledHeaders/ddddd-Bridging-Header-swift_3O89L0OXZ0CPD-clang_188AW1HK8F0Q3.pch' for bridging header '/Users/kimjitae/Desktop/enf4/ddddd/ddddd/ddddd-Bridging-Header.h'
Our library is developed in C++ using Xcode, and there's no problem when we run and build just the library project.
The build succeeds, and the '.a' file is generated correctly. However, when we try to connect it with the app, the above problems occur.
Could there be a problem because we also need to use the existing C library alongside this?
The build is successful in an app project created with Objective-C.
iOS18.2 / iPhone 16pro / Xcode 16.2
'traitCollectionDidChange'
This function has been deprecated since ios17.
However, in ios18, when I changed the app to the background state or changed it to the foreground state again, it was confirmed that the function worked.
It hasn't been confirmed in ios17, but why is it only confirmed in ios18?
I’ve been struggling with this issue for a long time. When I try to archive my app to submit it to the App Store, I encounter two errors:
Linker command failed with exit code 1 (use -v to see invocation)
Linker command failed with exit code 1 (use -v to see invocation)
Topic:
Programming Languages
SubTopic:
Swift
I'm encountering an issue where certain images are not displaying on some iOS devices, while the same code works perfectly on others. There’s no error or crash — just some images fail to load or display. I've confirmed the image URLs and formats are correct.
Has anyone faced a similar issue or could suggest what might be causing this inconsistent behavior?
Thanks in advance!
Topic:
Programming Languages
SubTopic:
Swift
I am using CHCSVParser in objective-c to use the CSVString extension of the Array instance method.
When I installed a new app on iOS18.1.1, the correct value (@"Application,"abc,def"") was returned for both the first and second turns, but
when I installed a new app on iOS18.2, the correct value was returned for the first turn, but @"" was returned for the second turn.
Even when I debug with step into, I can enter the CSVString for the first turn, but I cannot enter it for the second turn and after. It's as if the instance method is not being generated.
There are in-app purchases between the first and second turns, but the view controllers that are called are also the same.
Is there any change between iOS18.1.1 and iOS18.2?
[Code]
NSArray *application = [NSArray arrayWithObjects:KEY_APPLICATION, @"abc,def", nil];
NSString *applistring = [application CSVString];
NSString *appliStr = [application CSVString];
[Debug window 18.1.1 First]
application __NSArrayI * @"2 elements" 0x0000000302118c00
[0] __NSCFConstantString * @"Application" 0x00000001005deab8
[1] __NSCFConstantString * @"abc,def" 0x00000001005deb78
applistring __NSCFString * @"Application,"abc,def"" 0x0000000302f7d050
appliStr __NSCFString * @"Application,"abc,def"" 0x0000000302f706f0
[18.1.1 Second]
application __NSArrayI * @"2 elements" 0x00000003021b5200
[0] __NSCFConstantString * @"Application" 0x00000001005deab8
[1] __NSCFConstantString * @"abc,def" 0x00000001005deb78
applistring __NSCFString * @"Application,"abc,def"" 0x0000000302ff6dc0
appliStr __NSCFString * @"Application,"abc,def"" 0x0000000302fa4d20
[18.2 First]
sapplication __NSArrayI * @"2 elements" 0x00000003019d7e80
[0] __NSCFConstantString * @"Application" 0x00000001041c6ab8
[1] __NSCFConstantString * @"abc,def" 0x00000001041c6b78
applistring __NSCFString * @"Application,"abc,def"" 0x000000030179e430
appliStr __NSCFString * @"Application,"abc,def"" 0x000000030179e5e0
[18.2 Second]
application __NSArrayI * @"2 elements" 0x00000003019679a0
[0] __NSCFConstantString * @"Application" 0x00000001041c6ab8
[1] __NSCFConstantString * @"abc,def" 0x00000001041c6b78
applistring __NSCFConstantString * @"" 0x00000001efa04768
appliStr __NSCFConstantString * @"" 0x00000001efa04768
I am currently studying the Accelerate library by referring to Apple documentation.
Here is the link to the referenced document:
https://developer.apple.com/documentation/accelerate/veclib/vforce
When I executed the sample code provided at the bottom of the document, I found a case where the results were different.
let n = 10_000
let x = (0..<n).map { _ in
Float.random(in: 1 ... 10_000)
}
let y = x.map {
return sqrt($0)
}
and
let y = [Float](unsafeUninitializedCapacity: n) { buffer, initializedCount in
vForce.sqrt(x,
result: &buffer)
initializedCount = n
}
The code below is provided to observe the issue described above.
import Accelerate
Task {
let n = 1//10_000
let x = (0..<n).map { _ in
Float(6737.015)//Float.random(in: 1 ... 10_000)
}
let y = x.map {
return sqrt($0)
}
try? await Task.sleep(nanoseconds: 1_000_000_000)
let z = [Float](unsafeUninitializedCapacity: n) { buffer, initializedCount in
vForce.sqrt(x, result: &buffer)
initializedCount = n
}
}
For a value of 6737.015 when calculating the square root:
Using the sqrt(_:) function gives the result 82.07932,
While using the vForce.sqrt(_:result:) function gives the result 82.07933.
Using a calculator, the value comes out as 82.07932139, which shows that the result from vForce is incorrect.
Could you explain the reason behind this difference?
swift!!宇宙才是你的极限
谁能让它停下!!!
Topic:
Programming Languages
SubTopic:
Swift
Context: SwiftUI TextField with a String for simple math using NSExpression.
I first prepare the input string to an extent but a malformed input using valid characters still fails, as expected. Let's say preparedExpression is "5--"
let expr = NSExpression(format: preparedExpression)
gives
FAULT: NSInvalidArgumentException: Unable to parse the format string "5-- == 1"; (user info absent)
How can I use NSExpression such that either the preparedExpression is pre-tested before asking for actual execution or the error is handled in a polite way that I can use to alert the user to try again.
Is there a Swift alternative to NSExpression that I've missed?
i have macos 15 and xcode 16 swift 6 and want to make apps
to run on macintosh.
i know the syntax of this programming language, but i need
informations like which libraries i have to import for func's
which name i do not know, and parameters i have not found
on websites or the tutorial on swift.
i need procedures like
open window at x,y,width,height
draw rectangle at x,y,width,height,color
draw text at x,y,width,height,color,size
read keyboard-letter,up/dn,shift
read mouse x,y,buttons
Topic:
Programming Languages
SubTopic:
Swift
I have a class object created dynamically using Runtime, and I want to release some manually allocated memory resources when this object is deallocated. To achieve this, I added a custom implementation of the dealloc method using the following code:
SEL aSel = NSSelectorFromString(@"dealloc");
class_addMethod(kvoClass, aSel, (IMP)custom_dealloc, method_getTypeEncoding(class_getInstanceMethod(kvoClass, aSel)));
However, I encountered some issues. If I don't call the superclass's dealloc method in the cus_dealloc function, the superclass's dealloc implementation will not be executed. On the other hand, if I explicitly call the superclass's dealloc method, the program crashes.
Here is the implementation of the cus_dealloc function:
void custom_dealloc(id self, SEL _cmd) {
// Release other memory

Class superClass = class_getSuperclass(object_getClass(self));
void (*originIMP)(struct objc_super *, SEL, ...) = (void *)objc_msgSendSuper;
struct objc_super *objcSuper = &(struct objc_super){self, superClass};
originIMP(objcSuper, _cmd);
}
demo
Hello, I am a software engineer student and I have recently been getting problems on my Mac regarding the C/C++ libraries. I have used my macbook for uni work for months, but around 3 or 4 months ago my macbook could not compile my work since it couldnt find the basic libraries I was using. For example, iostream. I have been using VSCode, and what it exactly says is "cannot open source file "iostream". Please run the 'Select IntelliSense Configuration...' command to locate your system headers." I have tried researching, changing the include path, even using chatgpt, and nothing. Is anyone having this same problem, or is able to help me? If any other information is needed, please let me know!
Topic:
Programming Languages
SubTopic:
General
I don't understand what's happening when I save values via a loop.
I initialize an array with default values, then run a loop to assign calculated values to it. In the middle of the loop, I print values, then print values again after the loop is over. The array values sometimes change, even though nothing has been written between print calls (when they change, the values are equal the last value in the array, index 49).
I made a test file which writes four types of values to an array: (1) A new class instance, (2) Calculation, (3) Variable, (4) Hard-code. Saving the same value gives different results between the different write methods:
import Foundation
let numElements : Int = 50
class CustomType{
var x : Double
var y : Double
init(x: Double = 1.23, y: Double = 2.34) {
self.x = x
self.y = y
}
}
// Try this four different ways
var array1 = [CustomType](repeating:CustomType(), count:numElements)
var array2 = [CustomType](repeating:CustomType(), count:numElements)
var array3 = [CustomType](repeating:CustomType(), count:numElements)
var array4 = [CustomType](repeating:CustomType(), count:numElements)
// Checking that defaults were written
print("Pre: Point 1: (\(array1[44].x),\(array1[44].y))")
print("Pre: Point 2: (\(array2[44].x),\(array2[44].y))")
print("Pre: Point 3: (\(array3[44].x),\(array3[44].y))")
print("Pre: Point 4: (\(array4[44].x),\(array4[44].y))")
// --- Fix 1: Problem goes away if I uncomment this:
// array1[44]=CustomType()
// array2[44]=CustomType()
// array3[44]=CustomType()
// array4[44]=CustomType()
// --- Fix 2: Or if you swap these two lines for the following line:
// let index = 44
// do {
for index in 0..<numElements{
let rads = Double(index) * 2 * Double.pi/Double(numElements)
let sinrads = sin(rads), cosrads = cos(rads)
// Four different ways to save to arrays
array1[index] = CustomType(x:sin(rads),y:cos(rads))
array2[index].x = sin(rads)
array2[index].y = cos(rads)
array3[index].x = sinrads
array3[index].y = cosrads
array4[index].x = -0.684547105928689
array4[index].y = 0.7289686274214113
if(index==44){
print("\n== Printing results mid-loop at index 44 ==")
print("During: index: \(index), Calculated Rads: \(rads)")
print("During: Calculated Vals: (\(sin(rads)),\(cos(rads)))")
print("During: Stored 'let' Vals: (\(sinrads),\(cosrads))")
print("During: Point 1: (\(array1[44].x),\(array1[44].y))")
print("During: Point 2: (\(array2[44].x),\(array2[44].y))")
print("During: Point 3: (\(array3[44].x),\(array3[44].y))")
print("During: Point 4: (\(array4[44].x),\(array4[44].y))")
}
}
print("\n== Printing the same results after the loop ==")
print("Post: Point 1: (\(array1[44].x),\(array1[44].y))")
print("Post: Point 2: (\(array2[44].x),\(array2[44].y))")
print("Post: Point 3: (\(array3[44].x),\(array3[44].y))")
print("Post: Point 4: (\(array4[44].x),\(array4[44].y))")
print("\n== Reverse-calculating results from a correct array (array 1) to get the for loop index ==")
print("reverse index calculation 01: \( (atan2(array1[ 1].x,array1[ 1].y) + Double.pi * 0) * Double(numElements)/(2*Double.pi) )")
print("reverse index calculation 44: \( (atan2(array1[44].x,array1[44].y) + Double.pi * 2) * Double(numElements)/(2*Double.pi) )")
print("reverse index calculation 45: \( (atan2(array1[45].x,array1[45].y) + Double.pi * 2) * Double(numElements)/(2*Double.pi) )")
print("\n== Reverse-calculating results from an incorrect array (array 2) to get the for loop index ==")
print("reverse index calculation 1: \( (atan2(array2[ 1].x,array2[ 1].y) + Double.pi * 2) * Double(numElements)/(2*Double.pi) )")
print("reverse index calculation 44: \( (atan2(array2[44].x,array2[44].y) + Double.pi * 2) * Double(numElements)/(2*Double.pi) )")
print("reverse index calculation 45: \( (atan2(array2[45].x,array2[45].y) + Double.pi * 2) * Double(numElements)/(2*Double.pi) )")
Which gives the following output:
Pre: Point 1: (1.23,2.34)
Pre: Point 2: (1.23,2.34)
Pre: Point 3: (1.23,2.34)
Pre: Point 4: (1.23,2.34)
== Printing results mid-loop at index 44 ==
During: index: 44, Calculated Rads: 5.529203070318036
During: Calculated Vals: (-0.684547105928689,0.7289686274214113)
During: Stored 'let' Vals: (-0.684547105928689,0.7289686274214113)
During: Point 1: (-0.684547105928689,0.7289686274214113)
During: Point 2: (-0.684547105928689,0.7289686274214113)
During: Point 3: (-0.684547105928689,0.7289686274214113)
During: Point 4: (-0.684547105928689,0.7289686274214113)
== Printing the same results after the loop ==
Post: Point 1: (-0.684547105928689,0.7289686274214113)
Post: Point 2: (-0.12533323356430465,0.9921147013144778)
Post: Point 3: (-0.12533323356430465,0.9921147013144778)
Post: Point 4: (-0.684547105928689,0.7289686274214113)
== Reverse-calculating results from a correct array (array 1) to get the for loop index ==
reverse index calculation 01: 1.0000000000000002
reverse index calculation 44: 43.99999999999999
reverse index calculation 45: 45.0
== Reverse-calculating results from an incorrect array (array 2) to get the for loop index ==
reverse index calculation 1: 49.0
reverse index calculation 44: 49.0
reverse index calculation 45: 49.0
Program ended with exit code: 0
Re-initializing the objects prior to the loop fixes the problem (see "Fix 1" in the comments), but the elements of the array are all initialized during creation and I don't understand why doing it a second time is helpful. The values should all be the same, am I missing something simple?
Topic:
Programming Languages
SubTopic:
Swift
Hi, I have issue on build my react native project and got this error "Undefined symbol: _swift_willThrowTypedImpl" how can I fix it?
I’m working on a project in Xcode 16.2 and encountered an issue where getAPI() with a default implementation in a protocol extension doesn’t show up in autocomplete. Here’s a simplified version of the code:
import Foundation
public protocol Repository {
func getAPI(from url: String?)
}
extension Repository {
public func getAPI(from url: String? = "https://...") {
getAPI(from: url)
}
}
final class _Repository: Repository {
func getAPI(from url: String?) {
// Task...
}
}
let repo: Repository = _Repository()
repo.getAPI( // Autocomplete doesn't suggest getAPI()
I’ve tried the following without success:
• Clean build folder
• Restart Xcode
• Reindexing
Is there something wrong with the code, or is this a known issue with Xcode 16.2? I’d appreciate any insights or suggestions.
I have a simple shell script as follows:
#!/bin/bash
OUTPUT="network.$(date +'%d-%m-%y').info.txt"
SUPPORT_ID="email"
echo "---------------------------------------------------" > $OUTPUT
echo "Run date and time: $(date)" >> $OUTPUT
echo "---------------------------------------------------" >> $OUTPUT
ifconfig >> $OUTPUT
echo "---------------------------------------------------" >> $OUTPUT
echo "Network info written to file: $OUTPUT."
echo "Please email this file to: $SUPPORT_ID."
It just dumps the network config into a file. At some point I will have the file emailed out, but right now I'm just trying to figure out why the output looks like the following?
bash ./test.sh
.etwork info written to file: network.26-01-25.info.txt
.lease email this file to: email
Why in the world does the initial character of the last couple of "echo" commands get clipped and turned into periods? The echos for the output of the commands piped into the output file are fine. Strange...
Any ideas?
Topic:
Programming Languages
SubTopic:
General
Just read about the new @concurrent option coming to Swift 6.2 and lover it, but...
It just me, but I which these options would pick a case and stick with it...
@Sendable
@unchecked
@MainActor
@concurrent
@Observable
@ObservationIgnored
I have a simple shell script as follows:
#!/bin/bash
OUTPUT="network.$(date +'%d-%m-%y').info.txt"
SUPPORT_ID="emailaddress"
echo "---------------------------------------------------" > $OUTPUT
echo "Run date and time: $(date)" >> $OUTPUT
echo "---------------------------------------------------" >> $OUTPUT
ifconfig >> $OUTPUT
echo "---------------------------------------------------" >> $OUTPUT
echo "Network info written to file: $OUTPUT."
echo "Please email this file to: $SUPPORT_ID."
It just dumps the network config into a file. At some point I will have the file emailed out, but right now I'm just trying to figure out why the output looks like the following?
bash ./test.sh
.etwork info written to file: network.26-01-25.info.txt
.lease email this file to: emailaddress
Why in the world does the initial character of the last couple of "echo" commands get clipped and turned into periods? The echos for the output of the commands piped into the output file are fine. Strange...
Any ideas?
Topic:
Programming Languages
SubTopic:
General