I've got a watch app, still with storyboard, WKInterfaceController and WatchConnectivity.
After updating it for swift 6 concurrency I thought I'd keep it for a little while without swift 6 concurrency dynamic runtime check.
So I added -disable-dynamic-actor-isolation in OTHER_SWIFT_FLAGS, but it doesn't seem to have an effect for the Apple Watch target. Without manually marking callbacks where needed with @Sendable in dynamic checks seem to be in place.
swiftc invocation is as (includes -disable-dynamic-actor-isolation):
swiftc -module-name GeoCameraWatchApp -Onone -enforce-exclusivity\=checked ... GeoCameraWatchApp.SwiftFileList -DDEBUG -enable-bridging-pch -disable-dynamic-actor-isolation -D DEBUG -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS11.2.sdk -target arm64_32-apple-watchos7.0 -g -module-cache-path /Users/stand/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/stand/Library/Developer/Xcode/DerivedData/speedo-almhjmryctkitceaufvkvhkkfvdw/Index.noindex/DataStore -enable-experimental-feature OpaqueTypeErasure -Xcc -D_LIBCPP_HARDENING_MODE\=_LIBCPP_HARDENING_MODE_DEBUG -swift-version 6
...
-disable-dynamic-actor-isolation flag seems to be working for the iOS targets, I believe.
The flag is described here
Am I missing something? Should the flag work for both iOS and Apple Watch targets?
Dive into the world of programming languages used for app development.
Post
Replies
Boosts
Views
Activity
Hello Apple Team,
I'm trying to import the Audodesk FBX SDK to my Objective-C iOS Project.
The SDK is written in C++, but has support for iOS and the iOS simulator architectures.
I've added the path to the include folder in the Header Search Path
I've also added the paths to libfbxsdk.a in the Library Search Paths
Finally, I've added the libfbxsdk.a file to the Link Binary with Libraries.
However, when I build the project, I get the following error:
building for 'iOS', but linking in object file (/Users/Lond/Documents/v2/Autodesk/iOS/2020.3.7/lib/ios/debug/libfbxsdk.a[28](fbxalloc.cxx.o)) built for 'macOS'
In the terminal, if I type the command:
lipo -info libfbxsdk.a
I get the message
Non-fat file: libfbxsdk.a is architecture: arm64
confirming that I'm using the library for the correct architecture.
Do I need to add any other confifuration option? (Like the other linker flag or something else)
I'm quite new to C++, and integrating a C++ SDK into iOS is not easy.
I'm using Mac Os Sonoma 14.6.1
Tested on Xcode 15.4 and 16.2
Target Device: iPhone 13 Pro (iOS 17.6.1)
iOS FBX SDK version: 2020.3.7
Link to the SDK if needed:
https://aps.autodesk.com/developer/overview/fbx-sdk
Any help would be greatly appreciated
Thank you
Hi!
We are seeing a bit surprising behavior of dispatch_main on macOS where it seems to spawn a different thread instead of preserving the one it gets called from.
Managed to reproduce it in a completely empty command-line tool project in Xcode
int main(int argc, const char * argv[]) {
@autoreleasepool {
dispatch_main();
return 0;
}
}
I put a breakpoint on the line with dispatch_main and see that I am on Thread 1 and inside main function. That makes sense.
I resume execution and pause again. Looking at Thread output in Xcode, I can only see Thread 2.
Thread 1 is gone and the executable keeps on running.
So dispatch_main did what was expected (prevented the process from termination) but throws out the thread it was called from and creates a new one? Is that behavior expected or am I missing something?
Just a brain teaser at this point. But we could not make sense out of it. :)
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?
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?
I have a class that I want to custom encode into JSON:
class Declination: Decodable, Encodable {
var asString: String
var asDouble: Double
init(_ asString: String) {
self.asString = asString
self.asDouble = raToDouble(asString)
}
required init(from decoder: Decoder) throws {
let value = try decoder.singleValueContainer()
self.asString = try value.decode(String.self)
self.asDouble = declinationToDouble(asString)
}
}
As you can see, I calculate the double form of the declination when I decode a JSON file containing the data. What I want to do now is ENCODE the class back out as a single string.
Currently the standard JSON encode in Swift produces the following:
"declination":{"asDouble":18.26388888888889,"asString":"+18:15:50.00"}
what I want to produce is:
declination:"+18:15:50.00"
How can I easily do that? I've read up about custom encoders and such, and I get confused about the containers and what keys are being used. I think there might be a simple answer where I could just code:
extension Coordinate: Encodable {
func encode(to encoder: Encoder) throws {
return encoder.encode(self.asString)
}
}
But experienced Swift developers will immediately see that won't work. Should I do JSONSerialization instead? Can I just write a toString() extension and have JSON pick that up?
Any help would be appreciated.
Thanks,
Robert
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.
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.
Using the DebugDescription macro to display an optional value produces a “String interpolation produces a debug description for an optional value” build warning.
For example:
@DebugDescription
struct MyType: CustomDebugStringConvertible {
let optionalValue: String?
public var debugDescription: String {
"Value: \(optionalValue)"
}
}
The DebugDescription macro does not allow (it is an error)
"Value: \(String(describing: optionalValue))"
or
"Value: \(optionalValue ?? "nil")"
because “Only references to stored properties are allowed.”
Is there a way to reconcile these?
I have a build log full of these warnings, obscuring real issues.
Hey there-
I'm having a quite interesting bug on Swift Playgrounds.
I am trying to run my app with this following code snippet which does not compile on Swift Playgrounds, yet compiles on XCode (note: this is a Swift Playground app)
if #available(iOS 18.0, *) {
//simple function to get the indices of other items that have the same date as the "date" variable
let indices = data!.indices(where: { item in
let sameMonth = Calendar.current.component(.month, from: item.time) == Calendar.current.component(.month, from: date)
let sameYear = Calendar.current.component(.year, from: item.time) == Calendar.current.component(.year, from: date)
let sameDay = Calendar.current.component(.day, from: item.time) == Calendar.current.component(.year, from: date)
return sameDay && sameMonth && sameYear
})
However, the indices(where:) codeblock seems to stop the app from compiling (ONLY on Swift Playgrounds - it works perfectly fine on XCode).
I am getting the following error:
Cannot call value of non-function type 'Range<Array<Int>.Index>' (aka 'Range<Int>')
Please let me know if you have any insight regarding this issue.
-ColoredOwl
I'm trying to fix some Swift6 warnings, this one seems too strict, I'm not sure how to fix it. The variable path is a String, which should be immutable, it's a local variable and never used again inside of the function, but still Swift6 complains about it being a race condition, passing it to the task
What should I do here to fix the warning?
How can I calculate polynomial coefficients for Tone Curve points:
// • Red channel: (0, 0), (60, 39), (128, 128), (255, 255)
// • Green channel: (0, 0), (63, 50), (128, 128), (255, 255)
// • Blue channel: (0, 0), (60, 47), (119, 119), (255, 255)
CIFilter:
func colorCrossPolynomial(inputImage: CIImage) -> CIImage? {
let colorCrossPolynomial = CIFilter.colorCrossPolynomial()
let redfloatArr: [CGFloat] = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]
let greenfloatArr: [CGFloat] = [0, 1, 1, 0, 0, 0, 0, 0, 0, 1]
let bluefloatArr: [CGFloat] = [0, 0, 1, 0, 0, 0, 0, 1, 1, 0]
colorCrossPolynomial.inputImage = inputImage
colorCrossPolynomial.blueCoefficients = CIVector(values: bluefloatArr, count: bluefloatArr.count)
colorCrossPolynomial.redCoefficients = CIVector(values: redfloatArr, count: redfloatArr.count)
colorCrossPolynomial.greenCoefficients = CIVector(values: greenfloatArr, count: greenfloatArr.count)
return colorCrossPolynomial.outputImage
}
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!
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
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?
Hello together,
since Xcode Version > 15 the following error handling causes following error "Pattern of type 'DecodingError' cannot match 'Never'
func getSupportedCountries() async {
// fetch all documents from collection "seasons" from firestore
let queryCountries = try? await db.collection("countries").getDocuments()
if queryCountries != nil {
self.countries = (queryCountries!.documents.compactMap({ (queryDocumentSnapshot) -> Country? in
let result = Result { try? queryDocumentSnapshot.data(as: Country.self) }
switch result {
case .success(let country):
if let country = country {
// A country value was successfully initialized from the DocumentSnapshot
self.errorMessage = nil
return country
}
else {
// A nil value was successfully initialized from the DocumentSnapshot,
// or the DocumentSnapshot was nil
self.errorMessage = "Document doesn't exist."
return nil
}
case .failure(let error):
// A Country value could not be initialized from the DocumentSnapshot
switch error {
case DecodingError.typeMismatch(_, let context):
self.errorMessage = "\(error.localizedDescription): \(context.debugDescription)"
case DecodingError.valueNotFound(_, let context):
self.errorMessage = "\(error.localizedDescription): \(context.debugDescription)"
case DecodingError.keyNotFound(_, let context):
self.errorMessage = "\(error.localizedDescription): \(context.debugDescription)"
case DecodingError.dataCorrupted(let key):
self.errorMessage = "\(error.localizedDescription): \(key)"
default:
self.errorMessage = "Error decoding document: \(error.localizedDescription)"
}
return nil
}
}))
} else {
self.errorMessage = "No documents in 'countries' collection"
return
}
}
the interesting part of the code where XCODE shows an error is from "switch error" downwards.
Does anyone of you have an idea what's wrong?
Ay help appreciated !
Thx, Peter
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?
Hello Im having an error in swiftUI project of mine. I use fullscreencover to navigate through views. Normally it s been working but one point it doesn't. I go through MainMenu -> SomeOtherView -> GameView -> AfterGameView -> SomeOtherView -> MainMenu. When it comes to mainmenu at last, it s showing main menu for a glimpse of a look and then goes back to GameView. In console an error took my notice.
> A new orientation transaction token is being requested while a valid one already exists. reason=Fullscreen transition (dismissing): fromVC=<_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x10795ca00>; toVC=<_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x1071c3400>;; windowOrientation=portrait; sceneOrientation=portrait; existingTransaction=<_UIForcedOrientationTransactionToken: 0x600001804a40; state: active; originalOrientation: portrait (1)>
Cant really finding the solution. Need help asap I will release a bug update to Appstore.
Crash Log
We have a issue with our watch app. When we do a release build with xcode 16 the watch app will not launch and crashes on watchOS 10 and below devices.
It does not do this on debug builds...and it does not do this on xcode 15 release/debug builds.
Anybody running into watch crashes on xcode 16?
Thanks
Hi guys,
I've been struggling for a few days with this really weird behaviour.
We made an app for our e-commerce website and found out that a part of the product page is missing.
For any reason, the header and first blocks of the page and footer are displayed, but then a massive part of the content is missing. This content is not loaded through ajax; that's why I don't understand why it's not displayed.
You can see here 2 screenshots of what the page should look like and what the page looks like with WKWebView.
I've been inspecting this with Safari; there isn't any blocking error in the console, and html elements are just empty. There is the div with class row and nothing in it.
The same website is working perfectly with native Android Webview.
If anyone has any clue to find out what's going wrong