Build, test, and submit your app using Xcode, Apple's integrated development environment.

Xcode Documentation

Post

Replies

Boosts

Views

Activity

How does NSFetchRequest compare custom objects?
I have a CoreData-based app that's many years old, so it's been a long time since I've actually dealt with CoreData. Over recent years, I've noticed that fetch requests aren't finding the object I know is in there. The entity is called Folder and has a single attribute named url, which is of type Transformable. The transformer is a custom one that converts a url into a dictionary with 2 keys; one is a security scoped bookmark created from the url, and the other is the original url in case the bookmark fails. The dictionary is then converted to NSData using NSKeyedArchiver securely. The reverseTransformedValue does the opposite; unarchives the data to a dict, attempts to resolve the bookmark back into the url. The fetch request is set up to fetch all Folder objects where: Custom Predicate: url == $THE_URL So is the fetch request comparing the NSData that's stored in the file and comparing that to $THE_URL after running it through the transformer to arrive at an NSData, or is it running each one through the transformer to get the underlying url and comparing those with $THE_URL? Could there be a better way to compare urls in Core Data, when the app is sandboxed and must use security scoped bookmarks?
0
0
112
2w
change the way build c++ code
when building my project with Xcode16 Beta, I came across several compile errors in c++ code, which used to be ok when building with Xcode15. It's not easy to fix them because some of them came from third part libraries. Is there a way to configure Xcode to build c++ code conforming to the Xcode 15 manner? (I know I can get back to Xcode15 temporarily, but I worry these issue can not be fixed even in the official release version)
2
1
170
2w
Xcode error at preview after changing my macOS user account name
Hello, Today earlier I changed my macOS user account name and now I'm getting error at Xcode 16 at Preview. A piece of error report is: XOJITError: Could not create oop-jit code file directory /Users/victorvaz/Library/Developer/Xcode/UserData/Previews/Simulator Devices/CCCD8E24-3E82-4B02-9D30-0E2B5D09EB4A/data/Containers/Data/Application/D4EA132D-A318-4D58-8618-DFD428FD5F71/tmp/OOPJit/previews: Permission denied But "victorvaz" is my old macOS user account name, how can I make Xcode identify my new account name? Kind regards, Victor de Oliveira
2
0
161
2w
Is there anyway to view output from an Xcode scheme's build pre-action / verify it completed successfully?
I've got a custom run script build phase in my Xcode iOS project, however I want it to run before the items in the Target Dependencies section get built. So I added a Pre-Actions phase to the target's build scheme and pasted the contents there. However, during a build, there's no way to see if the stuff in the pre action is successful or not. It's possible to put echo statements into a run script build phase which is useful to print values such as file paths etc. but these don't work when part of a scheme pre action. Also if I deliberately put garbage into the scheme pre action, then I can see Xcode is still running the pre action, but as its full of garbage it should fail, but Xcode doesn't report any errors anywhere. So, is there any way to see and confirm if a scheme pre-action was successful or not, or to output logging statements from it to verify values its using are as expected?
0
0
138
2w
Xcode 15: Multiple Commands Produce Duplicate Info.plist Error
I am encountering a persistent issue in Xcode 15 where multiple commands produce a duplicate Info.plist error. The specific error message is: M u ltiple commands produce '/Users/josephnicholas/Library/Developer/Xcode/DerivedData/Restaurant_Build-bapndkzqxdjxxbacjwattbpeqof/Build/Products/Debug-iphoneos/Restaurant Build.app/Info.plist': Target 'Restaurant Build' (project 'Restaurant Build') has copy command from '/Users/josephnicholas/Desktop/backups/Restaurant Build/Supporting Files/Info.plist' to '/Users/josephnicholas/Library/Developer/Xcode/DerivedData/Restaurant_Build-bapndkzqxdjxxbacjwattbpeqof/Build/Products/Debug-iphoneos/Restaurant Build.app/Info.plist' Target 'Restaurant Build' (project 'Restaurant Build') has process command with output '/Users/josephnicholas/Library/Developer/Xcode/DerivedData/Restaurant_Build-bapndkzqxdjxxbacjwattbpeqof/Build/Products/Debug-iphoneos/Restaurant Build.app/Info.plist' Despite following numerous troubleshooting steps, including deleting the Info.plist file, cleaning the build folder, and creating a new project from scratch, the issue persists. I have ensured the Info.plist path is correctly set in the Build Settings under Packaging, and verified the file's target membership. However, the error remains unresolved. Here is a detailed list of the steps I have taken: Deleted the Derived Data multiple times. Restarted Xcode. Deleted the Info.plist file and re-added it through File > New File. Created a new project and manually copied all the files. Verified the Info.plist path and target membership. Followed suggestions from various forums, including adjusting paths and cleaning the build folder. Unfortunately, these steps have not resolved the issue. Attached are screenshots detailing the error messages and my current project setup. I would greatly appreciate any insights or solutions to this problem.
4
0
222
2w
XCUITest Screenshots not saving
I have some (very old ObjC) XCUITests, in Xcode 15.2. I recently noticed programmatic screenshots are not saving. The screenshots generated automatically by XCUITest are saving fine. This is code that used to work as expected; I do not know when it broke as I haven't had need to run this in a while. -(void)takeScreenshotWithName:(NSString *)name { XCUIScreenshot *screenshot = XCUIScreen.mainScreen.screenshot; XCTAttachment *attachment = [XCTAttachment attachmentWithScreenshot:screenshot]; attachment.lifetime = XCTAttachmentLifetimeKeepAlways; attachment.name = name; [self addAttachment:attachment]; UIImage *image = screenshot.image; UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); } During testing I added the UIImageWriteToSavedPhotosAlbum call, to verify the code is running and the image is available - and it does. But I really don't want these images cluttering up my library. The results are the same whether I run my tests from within Xcode, or via the command line. I need these screenshots so I have a set in PNG format, with standardized naming, for archiving, searching, and comparisons. The automatic screenshots are in Xcode's format - useful when reviewing a single test, which isn't my use case here.
0
0
117
2w
Swift Package with Demo project with Xcode 16
My current workflow to have a Swift Package with a Demo is like this: PackageFolder > DemoFolder I have a package, with a Demo folder inside. I can open the Demo project and Drag&Drop the local PackageFolder to override the remote dependency with the local one. This allows to edit the package while inside the demo project. With Xcode 16 this does no longer work because Xcode does not allow to drop an ancestor of the file path where the project is located. Xcode does not tell this while you drop, it just does not allow it. But it tells you thats the reason, when you try to add the local package as a dependency to the project: "The selected package cannot be a direct ancestor of the project.". (Dropping other local packages still works, see: https://forums.developer.apple.com/forums/thread/756824) What is the expected way to handle a package with a demo project with Xcode 16?
1
1
238
2w
No option to set baseline for UI Test metrics
I'm trying to measure app launch time in an existing Xcode project. I added a simple test that's supposed to display a "no baseline" message and a button to set a baseline, but when I run the test, it just succeeds without showing the pop-up. It works in a new project, so I suspect there might be a specific setting in my existing project that's causing the issue. The project is about 6 years old. Does anyone know if there's a particular setting I need to enable for launch tests to display the baseline pop-up in older projects? I'm running the test from new project in Xcode 14.2. Existing project in Xcode 15.2 and 14.2 both succeed with no baseline message. Thank you!
3
0
115
2w
Distributing Binary via Cocoapods & Swift Packages
I maintain a library that has thus far used Cocoapods to manage dependencies and also distribute an xcframework of the library. I'd now like to also distribute the same library through Swift Packages but am running into issues. I'm using the same xcframework in a local Swift Package and have added all the necessary dependencies to Package.swift, but when I attempt to add this Swift Package to a test app, the app will build correctly but fail at runtime due to a missing .framework file for a dependency I'll just call THE_DEPENDENCY: dyld[61483]: Library not loaded: @rpath/THE_DEPENDENCY.framework/THE_DEPENDENCY Referenced from: <75074516-C1CD-3251-8807-94A7502176A7> /Users/ME/Library/Developer/Xcode/DerivedData/MY_TEST_APP-bwfsfwjjnagdurdnjrhhdppgitvr/Build/Products/Debug-appletvsimulator/MY_LIBRARY.framework/MY_LIBRARY Reason: tried: '/Users/ME/Library/Developer/Xcode/DerivedData/MY_TEST_APP-bwfsfwjjnagdurdnjrhhdppgitvr/Build/Products/Debug-appletvsimulator/THE_DEPENDENCY.framework/THE_DEPENDENCY' (no such file) Indeed, there is no THE_DEPENDENCY.framework file anywhere, it is only present in a version of the test app that uses Cocoapods. As you can see, the reference to this file arises from MY_LIBRARY, and in MY_LIBRARY.xcodeproj I can see there is a reference to THE_DEPENDENCY.framework, which appears as a consequence of running pod install. Thus, it looks to me like the .framework file appears either as part of Cocoapods dependency injection, or perhaps as a consequence of how that dependency is distributed through Cocoapods. I'm forced to install pods during my build process because, as I understand it, all dependencies must be available during the archiving process to avoid compilation errors. If the dependencies must be available during archiving, but adding the dependencies via Cocoapods creates a reference to .framework files that will not be present in a Swift Package project, what is the best practice for distributing xcframework binaries to both Cocoapods and Swift Package Manager? It looks as though I'll have to build two different xcframeworks: one built with dependencies provided via pods, and the other via swift packages. Is this correct?
0
0
130
2w
Define Custom Tests in Xcode project template
I am using a custom app project template and I would like to also include custom Test files (or implementation) when I select to add Swift Testing or XCTest. What should I add to my TemplateInfo.plist to either extend or override the default templates? This is not documented by Apple and it's hard to figure out. Thanks in advance for any help.
0
0
111
2w