I want a solution to keep tracking the user once he started in driving state until parking.
I tried many solutions like use significant location changes, and silent push notifications and background tasks, but no one of them worked as expected.
I need when user started in driving the app be active until the user parked his car.
I'm using CoreMotion and CoreLocation.
The challenge is when the app is not active like killed or suspended.
So, how to do this? is this possible or not?
Dive into the world of programming languages used for app development.
Post
Replies
Boosts
Views
Activity
I'm experiencing a persistent issue with CloudKit sharing in my iOS application. When attempting to present a UICloudSharingController, I receive the error message "Unknown client: ChoreOrganizer" in the console.
App Configuration Details:
App Name: ChoreOrganizer
Bundle ID: com.ProgressByBits.ChoreOrganizer
CloudKit Container ID: iCloud.com.ProgressByBits.ChoreOrganizer
Core Data Model Name: ChoreOrganizer.xcdatamodeld
Core Data Entity: Chore
Error Details:
The error "Unknown client: ChoreOrganizer" occurs when I present the UICloudSharingController
This happens only on the first attempt to share; subsequent attempts during the same app session don't show the error but sharing still doesn't work
All my code executes successfully without errors until UICloudSharingController is presented
Implementation Details:
I'm using NSPersistentCloudKitContainer for Core Data synchronization and UICloudSharingController for sharing. My implementation creates a custom CloudKit zone, saves both a record and a CKShare in that zone, and then presents the sharing controller.
Here's the relevant code:
@MainActor
func presentSharing(from viewController: UIViewController) async throws {
// Create CloudKit container
let container = CKContainer(identifier: containerIdentifier)
let database = container.privateCloudDatabase
// Define custom zone ID
let zoneID = CKRecordZone.ID(zoneName: "SharedChores", ownerName: CKCurrentUserDefaultName)
do {
// Check if zone exists, create if necessary
do {
_ = try await database.recordZone(for: zoneID)
} catch {
let newZone = CKRecordZone(zoneID: zoneID)
_ = try await database.save(newZone)
}
// Create record in custom zone
let recordID = CKRecord.ID(recordName: "SharedChoresRoot", zoneID: zoneID)
let rootRecord = CKRecord(recordType: "ChoreRoot", recordID: recordID)
rootRecord["name"] = "Shared Chores Root" as CKRecordValue
// Create share
let share = CKShare(rootRecord: rootRecord)
share[CKShare.SystemFieldKey.title] = "Shared Tasks" as CKRecordValue
// Save both record and share in same operation
let recordsToSave: [CKRecord] = [rootRecord, share]
_ = try await database.modifyRecords(saving: recordsToSave, deleting: [])
// Present sharing controller
let sharingController = UICloudSharingController(share: share, container: container)
sharingController.delegate = shareDelegate
// Configure popover
if let popover = sharingController.popoverPresentationController {
popover.sourceView = viewController.view
popover.sourceRect = CGRect(
x: viewController.view.bounds.midX,
y: viewController.view.bounds.midY,
width: 1, height: 1
)
popover.permittedArrowDirections = []
}
viewController.present(sharingController, animated: true)
} catch {
throw error
}
}
Steps I've already tried:
Verified correct bundle ID and container ID match in all places (code, entitlements file, Developer Portal)
Added NSUbiquitousContainers configuration to Info.plist
Ensured proper entitlements in the app
Created and configured proper provisioning profiles
Tried both default zone and custom zone for sharing
Various ways of saving the record and share (separate operations, same operation)
Cleaned build folder, deleted derived data, reinstalled the app
Tried on both simulator and physical device
Confirmed CloudKit container exists in CloudKit Dashboard with correct schema
Verified iCloud is properly signed in on test devices
Console Output:
1. Starting sharing process
2. Created CKContainer with ID: iCloud.com.ProgressByBits.ChoreOrganizer
3. Using zone: SharedChores
4. Checking if zone exists
5. Zone exists
7. Created record with ID: <CKRecordID: 0x3033ebd80; recordName=SharedChoresRoot, zoneID=SharedChores:__defaultOwner__>
8. Created share with ID: <CKRecordID: 0x3033ea920; recordName=Share-C4701F43-7591-4436-BBF4-6FA8AF3DF532, zoneID=SharedChores:__defaultOwner__>
9. About to save record and share
10. Records saved successfully
11. Creating UICloudSharingController
12. About to present UICloudSharingController
13. UICloudSharingController presented
Unknown client: ChoreOrganizer
Additional Information:
When accessing the CloudKit Dashboard, I can see that data is being properly synced to the cloud, indicating that the basic CloudKit integration is working. The issue appears to be specific to the sharing functionality.
I would greatly appreciate any insights or solutions to resolve this persistent "Unknown client" error. Thank you for your assistance.
Is the title possible ? I tried [[thread valueForKey:@"_private"] valueForKey:@"tid"] but the tid was not kvc compliant. private apis are alright because this is just for testing remote process thread creation. I already have a working method but it has hardcoded assembly so you can't do anything else.
this question is mainly for Quinn (figured he may know something about this)
Hello,
I have a test variable here which works fine:
var quotes: [(quote: String, order: Int)] = [
("I live you the more ...", 1),
("There is nothing permanent ...", 2),
("You cannot shake hands ...", 3),
("Lord, make me an instrument...", 4)
]
and I have a test function which successfully pulls data from a mysql database via a web service and displays it via the "print" function:
func getPrice(){
if let url = URL(string:"https://www.TEST.com/test_connection.php"){
URLSession.shared.dataTask(with: url) { (data, response, error) in
if let data = data{
if let json = try? JSONDecoder().decode([[String:String]].self, from: data){
json.forEach { row in
print(row["quote"]!)
print(row["order"]!)
}
}
else{
}
}
else{
print("wrong :-(")
}
}.resume()
}
}
Please can you tell me how to re-write the quotes variable/array so that it returns the results that are found in the getPrice() function?
NSPredicate(format: "SELF MATCHES %@", "^[0-9A-Z]+$").evaluate(with: "126𝒥ℰℬℬ𝒢𝒦𝒮33")
Returns true, and I don't know why. 𝒥ℰℬℬ𝒢𝒦𝒮 is not between 0-9 and A-Z, and why it returns true? How to avoid similar problem like this when using NSPredicate?
public static func fetch(in context: NSManagedObjectContext, configurationBlock: (NSFetchRequest) -> () = { _ in }) -> [Self] {
let request = NSFetchRequest(entityName: Self.entityName)
configurationBlock(request)
return try! context.fetch(request)
}
context.fetch(request), 'fetch' function has error. Thread 24: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
After ther Mac application is launched:
Log error: CGSWindowShmemCreateWithPort failed on port 0
and when the application quit:
No error handler for XPC error: Connection invalid
Appear with Xcode 15.4 but not with 12.4
As repported by Steve4442 in "Can someone explain this message" https://Forums.Developer.Apple.com/Forums/Thread/727803
.
The code don't use "windowNumbersWithOptions"
Can I ignore this log message ?
I have configured DateFormatter in the following way:
let df = DateFormatter()
df.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
df.locale = .init(identifier: "en")
df.timeZone = .init(secondsFromGMT: 0)
in some user devices instead of ISO8601 style it returns date like 09/25/2024 12:00:34
Tried to change date format from settings, changed calendar and I think that checked everything that can cause the problem, but nothing helped to reproduce this issue, but actually this issue exists and consumers complain about not working date picker.
Is there any information what can cause such problem? May be there is some bug in iOS itself?
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.
For my app I've created a Dictionary that I want to persist using AppStorage
In order to be able to do this, I added RawRepresentable conformance for my specific type of Dictionary. (see code below)
typealias ScriptPickers = [Language: Bool]
extension ScriptPickers: @retroactive RawRepresentable where Key == Language, Value == Bool {
public init?(rawValue: String) {
guard let data = rawValue.data(using: .utf8),
let result = try? JSONDecoder().decode(ScriptPickers.self, from: data)
else {
return nil
}
self = result
}
public var rawValue: String {
guard let data = try? JSONEncoder().encode(self), // data is Data type
let result = String(data: data, encoding: .utf8) // coerce NSData to String
else {
return "{}" // empty Dictionary represented as String
}
return result
}
}
public enum Language: String, Codable, {
case en = "en"
case fr = "fr"
case ja = "ja"
case ko = "ko"
case hr = "hr"
case de = "de"
}
This all works fine in my app, however trying to run any tests, the build fails with the following:
Conflicting conformance of 'Dictionary<Key, Value>' to protocol 'RawRepresentable'; there cannot be more than one conformance, even with different conditional bounds
But then when I comment out my RawRepresentable implementation, I get the following error when attempting to run tests:
Value of type 'ScriptPickers' (aka 'Dictionary<Language, Bool>') has no member 'rawValue'
I hope Joseph Heller is out there somewhere chuckling at my predicament
any/all ideas greatly appreciated
I found a similar problem here https://developer.apple.com/forums/thread/764777 and I could solve my problem by wrapping the call to requestAutomaticPassPresentationSuppression in a call to DispatchQueue.global().async.
But my question is if this is really how things should work. Even with strict concurrency warnings in Swift 6 I don't get any warnings. Just a runtime crash.
How are we supposed to find these problems? Couldn't the compiler assist with a warning/error.
Why does the compiler make the assumptions it does about the method that is declared like this:
@available(iOS 9.0, *)
open class func requestAutomaticPassPresentationSuppression(responseHandler: @escaping (PKAutomaticPassPresentationSuppressionResult) -> Void) -> PKSuppressionRequestToken
Now that we have migrated to Swift 6 our code base contains a bunch of unknown places where it will crash as above.
According to the doc:
The value returned is the same as the value returned in the kEventParamKeyCode when using Carbon Events.
So where can I find kEventParamKeyCode?
❌ Could not find email_ai.py in the app bundle. Available files: []
The error above is what I’m encountering.
I’ve placed the referenced file both in the project directory and inside the app. However, every time I remove and reinsert the file into the folder within the app, it prompts me to designate the targets—I select all, but this doesn’t resolve the issue.
I’m unsure how to properly reference the file so that it is recognised and included in the bundle. Any guidance would be greatly appreciated.
this is my build phase:
#!/bin/sh
set -x # Prints each command before running it (for debugging)
pwd # Shows the current working directory
echo "$SRCROOT" # Shows what Xcode thinks is the project root
ls -l "$SRCROOT/EmailAssistant/EmailAssistant/PythonScripts" # Lists files in the script folder
export PYTHONPATH="/Users/caesar/.pyenv/versions/3.11.6/bin"
/Users/caesar/.pyenv/versions/3.11.6/bin/python3 "$SRCROOT/EmailAssistant/EmailAssistant/PythonScripts/email_ai.py"
echo "Script completed."
I notice that Swift Data type's hashValue collision when first 80 byte of data and data length are same because of the Implementation only use first 80 bytes to compute the hash.
https://web.archive.org/web/20120605052030/https://opensource.apple.com/source/CF/CF-635.21/CFData.c
also, even if hash collision on the situation like this, I can check data is really equal or not by ==
does there any reason for this implementation(only use 80 byte of data to make hashValue)?
test code is under below
let dataArray: [UInt8] = [
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
]
var dataArray1: [UInt8] = dataArray
var dataArray2: [UInt8] = dataArray
dataArray1.append(contentsOf: [0x00, 0x00, 0x00, 0x00])
dataArray2.append(contentsOf: [0xff, 0xff, 0xff, 0xff])
let data1 = Data(dataArray1)
let data2 = Data(dataArray2) // Only last 4 byte differs
print(data1.hashValue)
print(data2.hashValue)
print(data1.hashValue == data2.hashValue) // true
print(data1 == data2) // false
Hi the below array and code to output a list item works fine:
var quotes = [
[
"quote": "I live you the more ...",
"order": "1"
],
[
"quote": "There is nothing permanent ...",
"order": "2"
],
[
"quote": "You cannot shake hands ...",
"order": "3"
],
[
"quote": "Lord, make me an instrument...",
"order": "4"
]
]
cell.textLabel?.text = quotes[indexPath.row]["quote"]
However if I change the "order" values to be numbers rather than text like below then for the above line I get an error message in Xcode "No exact matches in call to subscript". Please could someone tell me how to make it work with the numbers stored as numbers? (I'm wondering if creating an any array type and using the .text function has caused a conflict but I can't find how to resolve)
[
"quote": "I live you the more ...",
"order": 1
],
[
"quote": "There is nothing permanent ...",
"order": 2
],
[
"quote": "You cannot shake hands ...",
"order": 3
],
[
"quote": "Lord, make me an instrument...",
"order": 4
]
]
Thank you for any pointers :-)
I am using Xcode 15 and working on a localised app. I use the new String Catalogs feature which works great for my app. In my app I created some local package like Apple has done it in the Backyard Birds example. However the translations I did in the package's String Catalog won’t be used in the app. What am I doing wrong?
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
The following code works when compiling for macOS:
print(NSMutableDictionary().isEqual(to: NSMutableDictionary()))
but produces a compiler error when compiling for iOS:
'NSMutableDictionary' is not convertible to '[AnyHashable : Any]'
NSDictionary.isEqual(to:) has the same signature on macOS and iOS. Why does this happen? Can I use NSDictionary.isEqual(_:) instead?
I am encountering a strange issue. I have a class that manages a selection of generic items T in an Array. It's a work in progress, but I'l try to give a gist of the setup.
class FileManagerItemModel: NSObject, Identifiable, Codable, NSCopying, Transferable, NSItemProviderReading, NSItemProviderWriting {
var id: URL
static func == (lhs: FileManagerItemModel, rhs: FileManagerItemModel) -> Bool {
lhs.fileURL == rhs.fileURL
}
var fileURL: URL {
FileManagerItemModel.normalizedFileURL(type: type,
rootURL: rootURL,
filePath: filePath)
}
init(type: FileManagerItemType, rootURL: URL, fileURL: URL) {
self.type = type
self.rootURL = rootURL
self.filePath = FileManagerItemModel.filePathRelativeToRootURL(fileURL: fileURL, rootURL: rootURL) ?? "[unknown]"
self.id = FileManagerItemModel.normalizedFileURL(type: type,
rootURL: rootURL,
filePath: filePath)
}
}
The class that manages the selection of these FileManagerItemModels is like so:
@Observable
class MultiSelectDragDropCoordinator<T: Hashable>: ObservableObject, CustomDebugStringConvertible {
private(set) var multiSelectedItems: [T] = []
func addToSelection(_ item: T) {
if !multiSelectedItems.contains(where: { $0 == item }) {
multiSelectedItems.append(item)
}
}
...
}
My issue is that the check if !multiSelectedItems.contains(where: { $0 == item }) in func addToSelection fails. The if is always executed, even if multiSelectedItems contains the given item.
Now, my first thought would be to suspect the static func == check. But that check works fine and does what it should do. Equality is defined by the whole fileURL.
So, the if should have worked. And If I put a breakpoint in func addToSelection on the if, and type po multiSelectedItems.contains(where: { $0 == item }) in the debug console, it actually returns true if the item is in multiSelectedItems. And it properly return false if the item is not in multiSelectedItems.
Still, if I then continue stepping through the app after the breakpoint was hit and I confirmed that the contains should return true, the app still goes into the if, and adds a duplicate item.
I tried assigning to a variable, I tried using a function and returning the true/false. Nothing helps.
Does anyone have an idea on why the debugger shows one (the correct and expected) thing but the actual code still does something different?
On iOS 18 some string functions return incorrect values in some cases.
Found problems on replacingOccurrences() and split() functions, but there may be others.
In the results of these functions in some cases a character is left in the result string when it shouldn't.
This did not happen on iOS17 and older versions.
I created a very simple Test Project to reproduce the problem.
If I run these tests on iOS17 or older the tests succeed.
If I run these tests on iOS18 the tests fail.
test_TestStr1() function shows a problem in replacingOccurrences() directly using strings.
test_TestStr2() function shows a problem in split() that seems to happen only when bridging from NSString to String.
import XCTest
final class TestStrings18Tests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func test_TestStr1()
{
let str1 = "_%\u{7}1\u{7}_";
let str2 = "%\u{7}1\u{7}";
let str3 = "X";
let str4 = str1.replacingOccurrences(of: str2, with: str3);
//This should be true
XCTAssertTrue(str4 == "_X_");
}
func test_TestStr2()
{
let s1 = "TVAR(6)\u{11}201\"Ã\"\u{11}201\"A\"";
let s2 = s1.components(separatedBy: "\u{11}201");
let t1 = NSString("TVAR(6)\u{11}201\"Ã\"\u{11}201\"A\"") as String;
let t2 = t1.components(separatedBy: "\u{11}201");
XCTAssertTrue(s2.count == t2.count);
let c = s2.count
//This should be True
XCTAssertTrue(s2[0] == t2[0]);
}
}