Swift is a powerful and intuitive programming language for Apple platforms and beyond.

Swift Documentation

Posts under Swift tag

2,073 Posts
Sort by:
Post not yet marked as solved
0 Replies
12 Views
I'm presenting a view controller inside a UIAction handler from the new UIButton init configuration API. But when I do it, its deinit won't get called. I'm thinking there's some sort of retain cycle? I've tried capturing [weak self] inside the closure with no success. Using the addTarget method instead, the deinit gets called as expected. What am I doing wrong? let testVC = TestViewController() lazy var testButton: UIButton = { var configuration = UIButton.Configuration.filled() //button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside) let button = UIButton(configuration: configuration, primaryAction: UIAction(handler: { action in self.present(testVC, animated: true, completion: nil) })) return button }()
Posted
by
Post not yet marked as solved
0 Replies
32 Views
Somehow, I am no longer able to connect to the AppStore in my development build. On a different device, I am running a production build (downloaded from the AppStore) and it works fine. In Xcode console, for the dev build, I get the following: Error enumerating all current transactions: Error Domain=ASDErrorDomain Code=509 "No active account" UserInfo={NSLocalizedDescription=No active account} It's been several months since I've worked on this particular project, and I can't recall what I did to enable the sandbox in the first place. ¯_(ツ)_/¯ Notwithstanding, on each device, I have gone into Settings -> App Store -> Sandbox Account and selected "Sign Out". Within Xcode, there is no Sandbox entry in any Entitlement file that I can find. Under Product -> Scheme -> Edit Scheme -> Run (Debug) -> Options, the StoreKit Configuration is set to None. In addition, 2 years ago Eskimo posted the following command that supposedly identifies if a build is Sandbox-enabled: codesign -d --entitlements - --xml /Applications/PCalc.app | plutil -convert xml1 -o - - I ran this command on my .app - and there was no hint of a sandbox entitlement. And finally, I suspect my "No active account" error is related to Xcode's sandbox feature because, when I tap on my app's Restore Purchases link, I am presented with an os-level dialog box "Sign in with Apple ID". If I do that, then the Settings -> App Store -> Sandbox Account gets filled in... I'm at a loss. Any help will be appreciated.
Posted
by
Post not yet marked as solved
0 Replies
31 Views
Hi! I've found that when presenting a UIDocumentPickerViewController, if you quickly tap twice on a document, both the picker view controller AND its parent view controller gets dismissed. My guess is that the system simply fires off a dismissal twice, closing both views. It's easier to trigger on a simulator than on a real device. Any way to get around this? I guess it would be possible to monitor dismissals and intercept any undesired ones, but it's not great.
Posted
by
Post not yet marked as solved
1 Replies
24 Views
Can you please help us to understand the issue and crash logs. how can we debug this crash? We got crash on CrashAnalytics but did not able to reproduce it and Crash report are also not much helpful. Please help. Attaching crash report.
Posted
by
Post marked as solved
7 Replies
122 Views
I'm getting this error : Picker: the selection "3" is invalid and does not have an associated tag, this will give undefined results. Because new brand doesn't have 3 values and .onChange modifier is not working fast enough. Thanks for your help. Picker("Marka", selection: $brandIndex) { Text("Seçin").tag(0) ForEach(cars.indices, id: \.self) { Text(cars[$0].brand).tag($0 + 1) } } .onChange(of: brandIndex) { if modelIndex != 0 { modelIndex = 0 } } Picker("Model", selection: $modelIndex) { Text("Seçin").tag(0) if brandIndex != 0 { let _ = print(modelIndex) // I'm getting first 3 then 0. And I'm getting error. ForEach(cars[brandIndex - 1].models.indices, id: \.self) { Text(cars[brandIndex - 1].models[$0]) .tag($0 + 1) } } }
Posted
by
Post marked as solved
4 Replies
86 Views
I have this code in a network extension: private func pathForToken(token: audit_token_t) -> String? { var tokenCopy = token let bufferSize = UInt32(4096) let bytes = UnsafeMutablePointer<UInt8>.allocate(capacity: Int(bufferSize)) let length = proc_pidpath_audittoken(&tokenCopy, bytes, bufferSize) if length != 0 { return String(cString: bytes).lowercased() } return nil } bytes appears to be leaked -- the call stack is pathForToken(token:) to specialized static UnsafeMutablePointer.allocate(capacity:) Do I need to do something to ensure bytes is released, since it doesn't seem to be happening on its own?
Posted
by
Post not yet marked as solved
0 Replies
65 Views
I'm attempting to integrate DRM into the app. I've developed a prototype, but the delegate method shouldWaitForLoadingOfRequestedResource isn't being triggered on certain devices, although it functions correctly on others. Notably, it's invoked on Apple TV 4K (3rd generation) Wi-Fi (A2737) but not on Apple TV HD (A1625). Are there any specific configurations needed to ensure this method is invoked? let url = URL(string: RESOURCE_URL)! // Create the asset instance and the resource loader because we will be asked // for the license to playback DRM protected asset. let asset = AVURLAsset(url: url) let queue = DispatchQueue(label: CUSTOM_SERIAL_QUEUE_LABEL) asset.resourceLoader.setDelegate(self, queue: queue) // Create the player item and the player to play it back in. let playerItem = AVPlayerItem(asset: asset) let player = AVPlayer(playerItem: playerItem) // Create a new AVPlayerViewController and pass it a reference to the player. let controller = AVPlayerViewController() controller.player = player // Modally present the player and call the player's play() method when complete. present(controller, animated: true) { player.play() } } //Please note if your delegate method is not being called then you need to run on a REAL DEVICE func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool { // Getting data for KSM server. Get the URL from tha manifest, we wil need it later as it // contains the assetId required for the license request. guard let url = loadingRequest.request.url else { print(#function, "Unable to read URL from loadingRequest") loadingRequest.finishLoading(with: NSError(domain: "", code: -1, userInfo: nil)) return false } // Link to your certificate on BuyDRM's side. // Use the commented section if you want to refer the certificate from your bundle i.e. Store Locally /* guard let certificateURL = Bundle.main.url(forResource: "certificate", withExtension: "der"), let certificateData = try? Data(contentsOf: certificateURL) else { print("failed...", #function, "Unable to read the certificate data.") loadingRequest.finishLoading(with: NSError(domain: "com.domain.error", code: -2, userInfo: nil)) return false } */ guard let certificateData = try? Data(contentsOf: URL(string: CERTIFICATE_URL)!) else { print(#function, "Unable to read the certificate data.") loadingRequest.finishLoading(with: NSError(domain: "", code: -2, userInfo: nil)) return false } // The assetId from the main/variant manifest - skd://***, the *** part. Get the SPC based on the // already collected data i.e. certificate and the assetId guard let contentId = url.host, let contentIdData = contentId.data(using: String.Encoding.utf8) else { loadingRequest.finishLoading(with: NSError(domain: "", code: -3, userInfo: nil)) print(#function, "Unable to read the SPC data.") return false } guard let spcData = try? loadingRequest.streamingContentKeyRequestData(forApp: certificateData, contentIdentifier: contentIdData, options: nil) else { loadingRequest.finishLoading(with: NSError(domain: "", code: -3, userInfo: nil)) print(#function, "Unable to read the SPC data.") return false } // Prepare to get the license i.e. CKC. let requestUrl = CKC_URL let stringBody = "spc=\(spcData.base64EncodedString())&assetId=\(contentId)" let postData = NSData(data: stringBody.data(using: String.Encoding.utf8)!) // Make the POST request with customdata set to the authentication XML. var request = URLRequest(url: URL(string: requestUrl)!) request.httpMethod = "POST" request.httpBody = postData as Data request.allHTTPHeaderFields = ["customdata" : ACCESS_TOKEN] let configuration = URLSessionConfiguration.default let session = URLSession(configuration: configuration) let task = session.dataTask(with: request) { data, response, error in if let data = data { // The response from the KeyOS MultiKey License server may be an error inside JSON. do { let parsedData = try JSONSerialization.jsonObject(with: data) as! [String:Any] let errorId = parsedData["errorid"] as! String let errorMsg = parsedData["errormsg"] as! String print(#function, "License request failed with an error: \(errorMsg) [\(errorId)]") } catch let error as NSError { print(#function, "The response may be a license. Moving on.", error) } // The response from the KeyOS MultiKey License server is Base64 encoded. let dataRequest = loadingRequest.dataRequest! // This command sends the CKC to the player. dataRequest.respond(with: Data(base64Encoded: data)!) loadingRequest.finishLoading() } else { print(#function, error?.localizedDescription ?? "Error during CKC request.") } } task.resume() // Tell the AVPlayer instance to wait. We are working on getting what it wants. return true }
Posted
by
Post not yet marked as solved
0 Replies
73 Views
macOS Sonoma 14.4 Xcode 15.3 Hi, I'm experimenting with C++/Swift interop and am following the official documentation, especially the section "Using Swift APIs of Imported Framework Target". I'm able to call Swift code from C++ when both Swift and C++ source files belong to the same app bundle or framework target, by importing the -Swift.h header. However, I'm not able to import the Swift code from a framework using a different C++ target. This is my test project setup: testApp is my app bundle and subprocesses is my framework, containing the auto-generated and unchanged subprocesses.h and some example swift code with a single public function. The subprocesses framework is added as a dependency to testApp and the framework has the C++ interoperability enabled. But when I try to import the auto-generated -Swift.h in main.cpp, it doesn't show up. What do I need to do so that I can call Swift framework code in a different C++ target? I think I've done everything according to the documentation. Thanks! Addendum I've also experimented with Apple's Xcode example projects. The "Mixing Languages in an Xcode project" (Link) works as expected. I was able to add a command line app target, and when I add the Fibonacci framework as a dependency, I'm able to use #include <Fibonacci/Fibonacci-Swift.h> and access the Swift API. However, the second of Apple's examples, "Calling APIs Across Language Boundaries" (Link) fails to compile out of the box (No member named 'createForest' in 'ForestBuilder::MagicForest').
Posted
by
Post marked as solved
4 Replies
115 Views
Hello, I am unable to move multiple rows in a list, it only allows for one at a time. However, I am able to select multiple rows. Here is my code: import SwiftUI struct ContentView: View { @State var items = ["Test 1", "Test 2", "Test 3", "Test 4", "Test 5", "Test 6"] @State var selectedItems: Set<String> = .init() var body: some View { NavigationView { List(selection: $selectedItems) { ForEach(items, id: \.self) { item in Text(item).tag(item) } .onMove(perform: { indices, newOffset in withAnimation { self.items.move(fromOffsets: indices, toOffset: newOffset) } }) } #if os(iOS) .navigationBarItems(trailing: EditButton()) #endif } .padding() } } I need all the selected rows to move when dragged. Any help would be greatly appreciated, I have tried, and can not find any way to do it. Thanks, Dev_101
Posted
by
Post not yet marked as solved
0 Replies
57 Views
I am an iOS developer experiencing a crash issue related to UITableView’s footer view when using automatic dimension for the footer height calculation. The implementation is as follows: override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return UITableView.automaticDimension } However, this leads to a crash with the following stack trace: Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000000000035f7c7 0 libobjc.A.dylib objc_release_x8 + 8 1 CoreAutoLayout -[NSContentSizeLayoutConstraint initWithLayoutItem:value:huggingPriority:compressionResistancePriority:orientation:] + 208 2 UIKitCore -[UIView _generateContentSizeConstraints] + 352 3 UIKitCore -[UIView _finishTemporaryInternalConstraints:withEngine:] + 220 4 UIKitCore __160-[UIView(UIConstraintBasedLayout) _calculatedSystemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:hasIntentionallyCollapsedHeight:]_block_invoke_2 + 192 5 CoreAutoLayout -[NSISEngine withBehaviors:performModifications:] + 84 6 UIKitCore -[UIView(UIConstraintBasedLayout) _calculatedSystemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:hasIntentionallyCollapsedHeight:] + 1072 7 UIKitCore -[UIView(AdditionalLayoutSupport) _systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:hasIntentionallyCollapsedHeight:] + 436 8 UIKitCore -[UITableView _heightForFooterView:inSection:] + 276 9 UIKitCore -[UITableView _heightForFooterInSection:] + 228 10 UIKitCore -[UISectionRowData heightForFooterInSection:canGuess:] + 64 11 UIKitCore -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 256 12 UIKitCore -[UITableView _updateVisibleHeadersAndFootersNow:] + 620 13 UIKitCore -[UITableView _updateVisibleCellsNow:] + 1292 14 UIKitCore -[UITableView layoutSubviews] + 148 All UI updates in my code are performed on the main thread, and I have verified this with appropriate thread assertions. I believe the correct threading rules are being followed. I am looking for any insights or leads you may have in analyzing this crash. It seems to relate to the auto-layout constraints applied to the content size of the footer view, although my understanding is that using UITableView.automaticDimension should manage these constraints appropriately without issues. Any assistance in understanding the root cause of this issue would be greatly appreciated. If there are any known issues with automatic dimension calculation for table view footers or if additional information is required to assist in resolving this problem, please let me know. Thank you for your time and support. Best regards.
Posted
by
Post not yet marked as solved
0 Replies
77 Views
I am relatively new to swift, and working on an app blocker using flutter and swift. In my Xcode runner file, I used File > New > Target > ShieldConfigurationExtension and File > New > Target > ShieldActionExtension to create the extensions with all the necessary Info.plist values. However, when I try to build, I am presented with this error message: Error (Xcode): Cycle inside Runner; building could produce unreliable results. Cycle details: → Target 'Runner': CodeSign /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app ○ That command depends on command in Target 'Runner': script phase “[CP] Copy Pods Resources” ○ That command depends on command in Target 'Runner': script phase “Thin Binary” ○ Target 'Runner' has process command with output '/Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/Info.plist' ○ Target 'Runner' has copy command from '/Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/shieldAction.appex' to '/Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/PlugIns/shieldAction.appex' 2 Raw dependency cycle trace: target: -> node: <all> -> command: <all> -> node: /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/_CodeSignature -> command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:CodeSign /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app -> node: /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/GoogleSignIn.bundle/ -> directoryTreeSignature: [ -> directoryContents: /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/GoogleSignIn.bundle -> CYCLE POINT -> node: /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/GoogleSignIn.bundle -> command: P2:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:PhaseScriptExecution [CP] Copy Pods Resources /Users/arshgupta/Library/Developer/Xcode/DerivedData/Runner-gkxkhzabeikourbemhpfsdwlgfor/Build/Intermediates.noindex/Runner.build/Debug-iphoneos/Runner.build/Script-F71E8F68D8E3D1B95F11D101.sh -> node: /Users/arshgupta/Library/Developer/Xcode/DerivedData/Runner-gkxkhzabeikourbemhpfsdwlgfor/Build/Intermediates.noindex/Runner.build/Debug-iphoneos/Runner.build/InputFileList-F71E8F68D8E3D1B95F11D101-Pods-Runner-resources-Debug-input-files-276c84640d21f41dd725929b3125799d-resolved.xcfilelist -> command: P2:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:WriteAuxiliaryFile /Users/arshgupta/Library/Developer/Xcode/DerivedData/Runner-gkxkhzabeikourbemhpfsdwlgfor/Build/Intermediates.noindex/Runner.build/Debug-iphoneos/Runner.build/InputFileList-F71E8F68D8E3D1B95F11D101-Pods-Runner-resources-Debug-input-files-276c84640d21f41dd725929b3125799d-resolved.xcfilelist -> node: <target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase4-thin-binary> -> command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase4-thin-binary -> node: <execute-shell-script-18c1723432283e0cc55f10a6dcfd9e02f1eee2015e8ff5ebcd27678f788c2826-target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-> -> command: P2:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:PhaseScriptExecution Thin Binary /Users/arshgupta/Library/Developer/Xcode/DerivedData/Runner-gkxkhzabeikourbemhpfsdwlgfor/Build/Intermediates.noindex/Runner.build/Debug-iphoneos/Runner.build/Script-3B06AD1E1E4923F5004D2608.sh -> node: /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/Info.plist/ -> directoryTreeSignature: R -> directoryContents: /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/Info.plist -> node: /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/Info.plist -> command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:ProcessInfoPlistFile /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/Info.plist /Users/arshgupta/Documents/pledge-1/ios/Runner/Info.plist -> node: /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/PlugIns/shieldAction.appex -> command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:Copy /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/PlugIns/shieldAction.appex /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/shieldAction.appex -> node: <target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase5--cp--copy-pods-resources> -> command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase5--cp--copy-pods-resources -> node: /Users/arshgupta/Documents/pledge-1/build/ios/Debug-iphoneos/Runner.app/GoogleSignIn.bundle What can I do to fix this?
Posted
by
Post not yet marked as solved
0 Replies
82 Views
Hello Developers, We are trying to convert Pytorch models to CoreML using coremltools, while converting we used jit.trace to create trace of model where we encountered a warning that if model has controlflow and conditions it is not advisable to use trace instead convert into TorchScript using jit.script, However after successful conversion of model into TorchScript, Now in the next step of conversion from TorchScript to CoreML here is the error we are getting when we tried to convert to coremltools python package. This root error is so abstract that we are not able to trace-back from where its occurring. AssertionError: Item selection is supported only on python list/tuple objects We trying to add this above error prompt into ChatGPT and we get something like the below response from ChatGPT. But unfortunately it's not working. The error indicates that the Core ML converter encountered a TorchScript operation involving item selection (indexing or slicing) on an object that it doesn't recognize as a Python list or tuple. The converter supports item selection only on these Python container types. This could happen if your model uses indexing on tensors or other types not recognized as list or tuple by the Core ML tools. You may need to revise the TorchScript code to ensure it only performs item selection on supported types or adjust the way tensors are indexed.
Posted
by
Post not yet marked as solved
2 Replies
80 Views
How to using SwiftUI, develop a complex layout page for a social media app. Include components like a profile header, a scrollable feed of posts with images and captions, interactive like and comment buttons, and a navigation bar. Discuss your approach to layout structuring, data flow management, user interaction handling, and responsiveness across different device sizes. Provide code snippets and explanations to illustrate your implementation.
Posted
by
Post not yet marked as solved
1 Replies
178 Views
We received an email from App Store Connect with the subject 'uploaded build for {AppName} has one or more issues' regarding our latest package, {versionNumber}' The email states that we need to add an App Privacy Manifest for our extensions before May 1st, and it specifies which categories need to be added. However, some of the categories mentioned, such as NSPrivacyAccessedAPICategorySystemBootTime, NSPrivacyAccessedAPICategoryFileTimestamp, NSPrivacyAccessedAPICategoryDiskSpace, are not used from our application. Do we still need to add these? If so, under which 'Privacy Accessed API Reasons' code should we add them?
Posted
by
Post marked as solved
1 Replies
116 Views
How can I enable multi-select and then move / reorder selected items in a List with ForEach (in SwiftUI)? I tried the following code. On Mac it works fine - it allows me to select multiple items, and then drag them all together to another place in the list. On iOS it allows me to move individual items with drag-and-drop, and allows me to enter Edit mode to select multiple items but when I try to move the selected items with drag-and-drop, they can be dragged but they can't be dropped elsewhere in the list: struct ExampleListView: View { @State var items = ["Dave", "Tom", "Jeremy", "Luke", "Phil"] @State var selectedItems: Set<String> = .init() var body: some View { NavigationView { List(selection: $selectedItems) { ForEach(items, id: \.self) { item in Text(item).tag(item) }.onMove(perform: move) } .navigationBarItems(trailing: EditButton()) } } func move(from source: IndexSet, to destination: Int) { items.move(fromOffsets: source, toOffset: destination) } } This code has the same behavior: struct ExampleListView: View { @State var items = ["Dave", "Tom", "Jeremy", "Luke", "Phil"] @State var selectedItems: Set<String> = .init() var body: some View { NavigationView { List($items, id: \.self, editActions: .all, selection: $selectedItems) { $item in Text(item).tag(item) } .navigationBarItems(trailing: EditButton()) } } func move(from source: IndexSet, to destination: Int) { items.move(fromOffsets: source, toOffset: destination) } }
Posted
by
Post marked as solved
1 Replies
105 Views
Please see also the video demo of the problem I'm encountering: https://youtu.be/V0ZkF-tVgKE I've noticed that the custom Systems I've been creating for my RealityKit/visionOS app do not get updated every frame as the documentation (and common sense) would suggest. Instead, they appear to tick for a time after each UI interaction and then "stall". The systems will be ticked again after some interaction with the UI or sometimes with a large enough movement of the user. My understanding was that these Systems should not be tied to UI by default so I'm a bit lost as to why this is happening. I've reproduced this by starting from a template project and adding a very simple couple of systems. Here is the main System, which simply rotates the pair of spheres: import RealityKit import RealityKitContent import SwiftUI public struct RotationSystem: System { static let query = EntityQuery(where: .has(RealityKitContent.WobblyThingComponent.self)) public init(scene: RealityKit.Scene) { } public func update(context: SceneUpdateContext) { print("system update, deltaTime: \(context.deltaTime)") let entities = context.scene.performQuery(Self.query).map({ $0 }) for entity in entities { let newRotation = simd_quatf(angle: Float(context.deltaTime * 0.5), axis: [0, 1, 0]) * entity.transform.rotation entity.transform.rotation = newRotation } } } The component (WobblyThingComponent) is attached to a parent of the two spheres in Reality Composer Pro, and both system and component are registered on app start in the usual way. This system runs smoothly in the simulator, but not in the preview in XCode and not on the Vision Pro itself, which is kinda the whole point. Here is a video of the actual behaviour on the Vision Pro: https://youtu.be/V0ZkF-tVgKE The log during this test confirms that the system is not being ticked often. You can see the very large deltaTime values, representing those long stalled moments: system update, deltaTime: 0.2055550068616867 system update, deltaTime: 0.4999987483024597 I have not seen this problem when running the Diaroma sample project, yet when comparing side-by-side with my test projects I cannot for the life of me identify a difference which could account for this. If anyone could tell me where I'm going wrong it would be greatly appreciated as I've been banging my head against this one for days. Xcode: Version 15.3 (15E204a) visionOS: 1.1 and 1.1.1
Posted
by
Post not yet marked as solved
1 Replies
71 Views
I want to get only spatial video while open the Photo library in my app. How can I achieve? One more thing, If I am selecting any video using photo library then how to identify selected video is Spatial Video or not? self.presentPicker(filter: .videos) /// - Tag: PresentPicker private func presentPicker(filter: PHPickerFilter?) { var configuration = PHPickerConfiguration(photoLibrary: .shared()) // Set the filter type according to the user’s selection. configuration.filter = filter // Set the mode to avoid transcoding, if possible, if your app supports arbitrary image/video encodings. configuration.preferredAssetRepresentationMode = .current // Set the selection behavior to respect the user’s selection order. configuration.selection = .ordered // Set the selection limit to enable multiselection. configuration.selectionLimit = 1 let picker = PHPickerViewController(configuration: configuration) picker.delegate = self present(picker, animated: true) } `func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { picker.dismiss(animated: true) { // do something on dismiss } guard let provider = results.first?.itemProvider else {return} provider.loadFileRepresentation(forTypeIdentifier: "public.movie") { url, error in guard error == nil else{ print(error) return } // receiving the video-local-URL / filepath guard let url = url else {return} // create a new filename let fileName = "\(Int(Date().timeIntervalSince1970)).\(url.pathExtension)" // create new URL let newUrl = URL(fileURLWithPath: NSTemporaryDirectory() + fileName) print(newUrl) print("===========") // copy item to APP Storage //try? FileManager.default.copyItem(at: url, to: newUrl) // self.parent.videoURL = newUrl.absoluteString } }`
Posted
by
Post not yet marked as solved
0 Replies
95 Views
I am using the category - playAndRecord and mode - videoChat with options - duckOthers. But during an audio call when I try to call setActive(true) an exception occurs and when I try to setActive(true) again after the audio call ended, I am not getting any exception, but voice is not coming. Below is what I am trying to do. So once initial session active attempt fails the system is not activating the session. I have used AVAudioSession.interruptionNotification already but still its not setting the session as desired when audio call is ended. try session.setCategory(.playAndRecord, mode: .videoChat, options: .duckOthers) try session.setActive(true)
Posted
by
Post not yet marked as solved
0 Replies
194 Views
I am currently using Xcode 15.2, but I am sure this issue exists on other versions too. If you have any packages made pre Xcode 14.3, i.e. ones without an automatically made test plan, then the following issue happens: Let's call the package in this example PackageX, and you have with this a corresponding test scheme, called PackageXTests. PackageXTests is a test scheme saved on disk, that is on the test scheme of PackageX, meaning that when you test the package directly, it will run the test scheme. Now, with test plans becoming the norm, we want to move away from having these test schemes on disk and instead align old packages with new and have each package's tests dictated by its own corresponding test plan, the same way that any newly made package would work. So we click 'convert to test plan', success we have a test plan, we delete the test scheme from the disk. All appears to be working fine. However, if you now swap branch and come back, the test plan will no longer be connected to that package. It will have reverted back to a test scheme. Which in git shows as a test scheme which it has added (i.e. the git diff has an uncommitted test scheme it has made). This is not a derived data issue, as I have deleted my derived data and it still occurs. Similarly with cleaning and building.
Posted
by