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

All subtopics

Post

Replies

Boosts

Views

Activity

Placing object in AR without hittest or plane
Hi, i want to place a object in 3d world space without the use of hittest or plane detection in ios swift code. Suggest the best method. Now, I take the camera center matrix and use simd_mul to place the object, it works but the object gets placed at the centre of the mobile screen. I want to select the x and y positino on the screen 2d coordinate and place the object. I tried using the unprojectpoint function, to get the AR scene world coordinate of the point i touch on the mobile screen. I get the x, y,z values, they are very close to the values from camera center matrix. When i try to replace the unprojectpoint values in the cameracenter matrix, i dont see a difference in the location of the placed object. The below code always place object from center screen with specified depth, But i need to place object in user specified position(x,y) of the screen with depth. 2D pixel coordinate system of the renderer to the 3D world coordinate system of the scene. /* Create a transform with a translation of 0.2 meters in front of the camera. */ var translation = matrix_identity_float4x4 translation.columns.3.z = -0.2 let transform = simd_mul(view.session.currentFrame.camera.transform, translation) Refer from : [https://developer.apple.com/documentation/arkit/arskview/providing_2d_virtual_content_with_spritekit) The code i used for replacing the camera center matrix with the unprojectpoint is let vpWithZ = SCNVector3(x: 100.0, y: 100.0, z: -1.0) let worldPoint = sceneView.unprojectPoint(vpWithZ) var translation = matrix_identity_float4x4 translation.columns.3.z = Float(Depth) var translation2 = sceneView.session.currentFrame!.camera.transform translation2.columns.3.x = worldPoint.x translation2.columns.3.y = worldPoint.y translation2.columns.3.z = worldPoint.z let new_transform = simd_mul(translation2, translation) /* add object name you wanted in your project*/ let sphere = SCNSphere(radius: 0.03) let objectNode = SCNNode(geometry: sphere) objectNode.position = SCNVector3(x: transform.columns.3.x, y: transform.columns.3.y, z: transform.columns.3.z) The below image shows outline of my idea.
0
0
370
Apr ’24
User cannot sign in after the app is deleted and reinstalled
ive been having an issue with my code. If the user registers an account it brings them to the Main View, which is what I want however if the user uninstalls the app and reinstalls it they are unable to sign in. The app provides the user with the error "An error occurred. Please make sure your account details are accurate" and prints on Xcode "Account Found, Error fetching user document: User data is missing or could not be parsed Login error: User data is missing or could not be parsed." Im not too sure if this is an Xcode error or Firebase error. Everything on firebase seems to work when a user creates an account it has the correct info on firebase.
1
0
186
Mar ’24
Is it possible to fix slow CKAsset loading on Cloudkit?
I am trying to create a specialised photo sharing social network using CloudKit alone. The app will never need to be non iOS, so on the surface Cloudkit has seemed like a perfect backend. However, I've found at random but semi frequent times, the loading of CKAssets from records can be very slow. For example, at normal times, all of the assets can load in a second or less. However at other times, it can take from 5 to 15 seconds. This is on a public database using a fetch operation where I already have the record IDs. Here is my code that performs that: mainDatabase.fetch(withRecordIDs: recordIDS, desiredKeys: ["image"]) { results in var recordsToReturn: [CKRecord] = [] switch results { case .success(let success): for (_, result) in success { switch result { case .success(let record): // If the result is success, append the record to the successfulRecords array recordsToReturn.append(record) break case .failure(_): break } } completion(.success(recordsToReturn)) case .failure(let failure): completion(.failure(failure)) } } } Of note, I have also tried using a database operation at set the qualityOfService to userInitiated, which has had the same noticeable load times. I have also tested this on different devices, on different networks (both cellular & different WiFi connections) and found also the same noticeable load times at random occurrences. Therefore, what I am trying to find out: Is this an expected behaviour from using CloudKit? Is there a much better way to load CKAssets that would drastically help this load time issue? Is CloudKit even a viable option for this kind of app, or is it not designed for this type of app? What alternative approaches could be taken? (Eg. store assets in AWS...) Would truly appreciate any feedback & guidance on this issue.
2
0
325
Mar ’24
I plan to study iOS Development. I need to buy a MacBook.
Hello everyone! I have questions, especially for experienced Apple developers. In short, I will start with the most important issue. I am going to study iOS development. As I understand, this is only possible if I am a Mac user. Unfortunately, at this stage, I don't have the financial means to buy a MacBook Pro. This is where my first and most important question arose - for learning (and preferably not only learning) and possibly working on large projects in Xcode (I will also most likely install and use Swift Playgrounds during the learning process) how useful will it be to buy a MacBook Air 13-inch? (If it's better to stop at the 15-inch model anyway? I like the 13-inch one because it's smaller and lighter to move around) I'll probably buy it with an M2 or M3 chip. (Is the chip crucial?) Also, the initial specs I saw for the 13-inch model are: 8-Core CPU 8-Core GPU 8GB Unified Memory 256GB SSD Storage Will this be enough, or must it be better if there were more of them? What would be the most optimal option for me? Thank you very much in advance for your time and honest answers.
4
0
1.4k
Mar ’24
Rotate and move entity same as windows move and rotate in visionOS
Hi! I am making an app where I have a scene with main entity in immersive space. Since my entity is fixed in space I added a reposition entity that allows users to reposition the whole entity in space. I use the drag gesture and translation to move the whole entity in x, y and z coordinates. I wanted to implement the same behaviour that we have when we drag the window bar in visionOS windows. I tried using basic trigonometry and calculate entity rotation and translation relative to the movement but I am not getting the same movement and rotation as in visionOS windows. Does anybody have a working solution for this? I would appreaciate it a lot. :)
1
0
461
Mar ’24
BGTask running while iPad is awake--how is this possible?
We have been using the BGTask (specifically a BGProcessingTask) reliably for the last couple of years for our app. Up until now they wake up automatically while the screen is off, the iPad is plugged in, and the app is running (that is, in the background), but never while the screen is on (that is, never when the scenePhase == .active). For the last month or so, I've noticed that they are triggering now while the screen is displayed. How is this possible??? Did something change with a recent version of iOS? It's violating Apple's own documentation, which describes the BGProcessingTask as: "A time-consuming processing task that runs while the app is in the background."
2
0
468
Mar ’24
Swift, C, and memory leaks
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?
4
0
486
Mar ’24
shouldWaitForLoadingOfRequestedResource delegate method not getting called on TVOS app
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 }
0
0
525
Mar ’24
Swift/C++ interop: missing -Swift.h header for framework
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').
4
0
461
Mar ’24
ShieldActionExtension and ShieldConfigurationExtension not working
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?
0
0
335
Mar ’24
Getting issue in convert PyTorch model to CoreML using CoreMLTool Kit.
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.
0
0
468
Mar ’24
Missing API Decleration - Request for Not Used Privacy Accessed API Categories
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?
1
0
560
Mar ’24
RealityKit Systems Not Ticking Every Frame on visionOS
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
1
0
418
Mar ’24
How to show only Spatial video using PHPickerFilter in swift 5.0
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 } }`
1
0
514
Mar ’24
Test plans being deleted and replaced by old test schemes
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.
0
0
486
Mar ’24
Capturing depth using the lidar camera sample code: Caused GPU Timeout Error (00000002:kIOGPUCommandBufferCallbackErrorTimeout)
Similar post on StackOverflow and multiple people reported this (you will encounter it if you run the app for like 10 minutes). I'm hoping this could get Apple's attention somehow After downloading the project code (https://developer.apple.com/documentation/avfoundation/additional_data_capture/capturing_depth_using_the_lidar_camera) and running the Swift sample code on an iPhone 14 Pro, the app crashes intermittently, throwing this error: Execution of the command buffer was aborted due to an error during execution. Caused GPU Timeout Error (00000002:kIOGPUCommandBufferCallbackErrorTimeout) Sometimes it will crash within a few seconds, sometimes it can take around 10 minutes. Has anyone here experienced this crash from the sample code, or using the LiDAR camera? I have spent a long time trying to solve this issue, I have searched the web high and low and submitted (I think) a report to Apple about it. I am unable to get xcode to show me the line of code where the crash is happening. Any help would be greatly appreciated.
0
0
340
Mar ’24
How can I prevent objects from aligning in RoomPlan?
I am making an app with RoomPlan using the official sample code. A model of the room is generated as it is scanned, and when the scan is complete, chairs and other objects are aligned parallel to the desk. I wanted to stop this behavior, so I decided to use the option beautifyObjects. import UIKit import RoomPlan class RoomCaptureViewController: UIViewController, RoomCaptureViewDelegate, RoomCaptureSessionDelegate { @IBOutlet var exportButton: UIButton? @IBOutlet var doneButton: UIBarButtonItem? @IBOutlet var cancelButton: UIBarButtonItem? @IBOutlet var activityIndicator: UIActivityIndicatorView? private var isScanning: Bool = false private var roomCaptureView: RoomCaptureView! private var roomCaptureSessionConfig: RoomCaptureSession.Configuration = RoomCaptureSession.Configuration() private var roomBuilder: RoomBuilder! private var processedResult: CapturedRoom? private var finalResults: CapturedRoom? override func viewDidLoad() { super.viewDidLoad() // Set up after loading the view. setupRoomBuilder() setupRoomCaptureView() activityIndicator?.stopAnimating() } private func setupRoomBuilder() { let beautifyObjectsEnabled = UserDefaults.standard.bool(forKey: "beautifyObjectsEnabled") if beautifyObjectsEnabled { roomBuilder = RoomBuilder(options: [.beautifyObjects]) } else { roomBuilder = RoomBuilder(options: []) } } private func setupRoomCaptureView() { roomCaptureView = RoomCaptureView(frame: view.bounds) roomCaptureView.captureSession.delegate = self roomCaptureView.delegate = self view.insertSubview(roomCaptureView, at: 0) } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) startSession() } override func viewWillDisappear(_ flag: Bool) { super.viewWillDisappear(flag) stopSession() } private func startSession() { isScanning = true roomCaptureView?.captureSession.run(configuration: roomCaptureSessionConfig) setActiveNavBar() } private func stopSession() { isScanning = false roomCaptureView?.captureSession.stop() setCompleteNavBar() } // Decide to post-process and show the final results. func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: Error?) -> Bool { Task { do { let capturedRoom = try await roomBuilder.capturedRoom(from: roomDataForProcessing) DispatchQueue.main.async { self.finalResults = capturedRoom self.exportButton?.isEnabled = true self.activityIndicator?.stopAnimating() } } catch { print("Error processing room data: \(error.localizedDescription)") } } return true } // Access the final post-processed results. func captureView(didPresent processedResult: CapturedRoom, error: Error?) { finalResults = processedResult self.exportButton?.isEnabled = true self.activityIndicator?.stopAnimating() } @IBAction func doneScanning(_ sender: UIBarButtonItem) { if isScanning { stopSession() } else { cancelScanning(sender) } self.exportButton?.isEnabled = false self.activityIndicator?.startAnimating() } @IBAction func cancelScanning(_ sender: UIBarButtonItem) { navigationController?.dismiss(animated: true) } // Export the USDZ output by specifying the `.parametric` export option. // Alternatively, `.mesh` exports a nonparametric file and `.all` // exports both in a single USDZ. @IBAction func exportResults(_ sender: UIButton) { let destinationFolderURL = FileManager.default.temporaryDirectory.appending(path: "Export") let destinationURL = destinationFolderURL.appending(path: "Room.usdz") let capturedRoomURL = destinationFolderURL.appending(path: "Room.json") do { try FileManager.default.createDirectory(at: destinationFolderURL, withIntermediateDirectories: true) let jsonEncoder = JSONEncoder() let jsonData = try jsonEncoder.encode(finalResults) try jsonData.write(to: capturedRoomURL) try finalResults?.export(to: destinationURL, exportOptions: .parametric) let activityVC = UIActivityViewController(activityItems: [destinationFolderURL], applicationActivities: nil) activityVC.modalPresentationStyle = .popover present(activityVC, animated: true, completion: nil) if let popOver = activityVC.popoverPresentationController { popOver.sourceView = self.exportButton } } catch { print("Error = \(error)") } } private func setActiveNavBar() { UIView.animate(withDuration: 1.0, animations: { self.cancelButton?.tintColor = .white self.doneButton?.tintColor = .white self.exportButton?.alpha = 0.0 }, completion: { complete in self.exportButton?.isHidden = true }) } private func setCompleteNavBar() { self.exportButton?.isHidden = false UIView.animate(withDuration: 1.0) { self.cancelButton?.tintColor = .systemBlue self.doneButton?.tintColor = .systemBlue self.exportButton?.alpha = 1.0 } } } The func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: Error?) is mainly changed. I have confirmed in the debugger that the roomBuilder options are changed according to the buttons in the UI. Anyone who knows more about the behavior of this option, please give me an advice.
0
0
426
Mar ’24