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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

Uncategorized (Xcode): Command ClangStatCache failed with a nonzero exit code
I'm encountering an issue while trying to build my iOS app in Xcode for the simulator. Issue: Xcode Version: 15.x macOS Version: 14.x (Sonoma) Simulator: iPhone 16 Pro Error Message: Command ClangStatCache failed with a nonzero exit code Steps Taken: Cleaned build folder (Shift + Cmd + K) Deleted DerivedData (rm -rf ~/Library/Developer/Xcode/DerivedData) Updated Xcode and checked iOS SDK updates Disabled Clang Static Analyzer Cache None of these steps resolved the issue. Any help would be appreciated! Thanks in advance.
0
0
154
Mar ’25
Xcode 16 Automatically Builds & Runs Simulator While Editing Storyboard
I’m experiencing an issue in Xcode 16 where the app randomly builds and runs in the simulator while I’m designing items in the storyboard. Here’s what I’ve tried so far to stop this behavior: Disabled "Show Live Issues" in the General settings Removed all key bindings related to Build & Run in the Key Bindings settings Checked for unintentional shortcut triggers, but nothing seems to be causing it Update XCode from 16.1 to 16.2 Delete Derived Data Despite these actions, Xcode still automatically builds and launches the simulator at unexpected times, disrupting my workflow. Is there any setting or hidden configuration that could be causing this? How can I completely prevent Xcode from running the simulator automatically while editing UI in the storyboard? Would really appreciate any guidance on this!
0
0
85
Mar ’25
When connecting xcode and iPhone
When connecting xcode and iPhone, the keypad does not appear on the screen where you enter the device password to trust the computer, so the connection is not possible. How do I make the keypad appear? There is no response when I tap the text box.
0
0
105
Nov ’24
Can I use ARGeoAnchor with simulated locations
I'm trying to evaluate if we can support AR navigation with MapKit. The feature is supposed to be available for users in US. I tried to run the sample on my iPhone: https://developer.apple.com/documentation/arkit/tracking-geographic-locations-in-ar?language=objc But I'm in a location that ARGeoTrackingConfiguration.checkAvailabilityWithCompletionHandler: always return false. I think ARGeoAnchor isn't supported in my location. I tried to use simulated locations by Adding a gpx file when launching the app. Enabling Xcode -> Debug -> Simulate Location -> New York, NY, US But the availability for ARGeoAnchor is still false. Is that possible for me to develop the ARGeoAnchor feature outside of the covered areas?
0
0
60
Mar ’25
Swift 6 concurrency error of passing sending closure
I am getting this error in a couple of places in my code with Task closure after setting Swift 6 as Language version in XCode. Passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure Below is minimally reproducible sample code. import Foundation final class Recorder { var writer = Writer() func startRecording() { Task { await writer.startRecording() print("started recording") } } func stopRecording() { Task { await writer.stopRecording() print("stopped recording") } } } actor Writer { var isRecording = false func startRecording() { isRecording = true } func stopRecording() { isRecording = false } } While making the class Recorder as Actor would fix the problem, I fear I will have to make too many classes as Actors in the class and in my scenario, there could be performance implications where real time audio and video frames are being processed. Further, I don't see any race condition in the code above. Does the error talk about possible race conditions that could arise if I were to call other functions on the self in future, or the current code itself is not safe?
0
2
1.2k
Jan ’25
Issue using RealmSwift in a framework versus using it in an app
If I install RealmSwift into an ios app using SPM, I have no problems. However if I install it into an ios framework, then when building there is this error: error: missing required modules: 'Realm.Private', 'Realm', 'Realm.Swift' I have discovered that if I change the import statement from: import RealmSwift to private import RealmSwift then doing that makes this build error goes away (but doing that isn't a feasible workaround as I would like to publicly export classes stored in Realm from the framework). There's no point in posting issues with Realm on their support board as its being deprecated and its tumble weeds on their forum. But I would be very interested in hearing from the Apple expects explanation or speculation on: why is importing the same framework via SPM into a framework xcode project resulting in different behavior then when importing it into an app? why would changing import to private import make the build error go away? TIA
0
0
70
Mar ’25
Xcode is is throwing error when I run my Unity Build
When I try to build my project in Xcode (from Unity AR) project, it throws me these errors: I feel like I've tried everything to make the LaunchScreen work. I downloaded xcode the night I tried running this build, so the whole deleting and redownloading and restarting everything didn't work. I've tried making sure my macbook and terminal are fully up to date. I literally can't find a solution! Please help!! I will also say, I'm fairly new to App building, Xcode, and Unity. But this does seem like a barrier that is stopping me from testing my project.
0
0
154
Mar ’25
Random "<unknown>:0: warning: default will never be executed" Xcode warning
Hello! I'm experiencing a persistent SwiftCompile warning that I haven't been able to resolve for several months: <unknown>:0: warning: default will never be executed Observations: Appears randomly across different files during the build. No source location or line highlighting is provided. Persists across clean builds and project reopenings. Occurs in both Xcode Cloud and local builds. What I’ve tried: Ensuring all switch statements on enums explicitly handle every case. Removing default cases from fully covered enum switches. Refactoring optional enum handling (e.g., using if let instead of switch). None of these resolved the issue. Any guidance would be greatly appreciated! Project details: Xcode: 16.2 Swift: 6 iOS Target: 17.0+ UI: SwiftUI-only (no UIKit) Dependencies: SwiftPM
0
1
270
Mar ’25
Xcode Doesn't recognises the git worktree version of the swift package
I'm building an iOS app using Xcode, and I frequently modify code within a package. To do this, I drag and drop a locally cloned version of the package into my project as a local package. However, when working across multiple branches of my app, I need different versions of the package as well. To achieve this, I use Git worktrees to create branch-specific copies of the package. Unfortunately, when I drag and drop these worktree copies into Xcode, the IDE doesn't seem to recognize them. Could you kindly guide me on resolving this?
0
0
251
Dec ’24
XCode Error Code: Failed to Save
I have a Mac Mini (M4) running macOS Sequoia 15.3.1. I very recently downloaded and installed the current version of XCode from the app store. I have not added any extensions - it's a vanilla, un-customized, un-enhanced installation. I have two user profiles (accounts) on my Mac: one Administrator and one Standard, each using a different apple account. I am using the Standard user account to learn XCode. When I attempt to set up a project, I get an error message when Xcode initially tries to save the (provided) project template file. The error states: "Failed to save Project2.xcodeproj. The backing file has been modified outside of XCode." I am using a NAS drive to store my project file. I have also tried saving it to the Desktop. It makes no difference to the error wherever the file is being saved. Similarly, I tried changing the Standard user account to an Administrator account to see if it was a privileges problem. Again, it made no difference to the error message. (So I changed the account back to a Standard user). I have tried googling the error but I only find references to problems related to extension/add-in products to XCode: none of which have I added to my XCode installation. I am attaching screenshots of the steps through the project creation process. Hopefully someone can tell me what I am doing wrong or what the problem is. Thank you.
0
0
294
Mar ’25
Xcode 16 is running on an iPhone 7 with iOS 12.1.3. The application fails to open normally and crashes immediately upon startup.
I am currently using Xcode 16 (16A242d) and testing on an iPhone 7 running iOS 12.1.3. However, when I try to launch the app on the device, it crashes immediately. Below are the crash logs from the iPhone 7: 错误 11:54:55.731858+0800 kernel Sandbox: assertiond(62) System Policy: deny(1) file-read-metadata /private/var/mobile/Library/DuetExpertCenter/caches/ATXCacheFile-_ATXAppPredictor-TotalScore 错误 11:54:55.731897+0800 kernel Sandbox: assertiond(62) System Policy: deny(1) file-read-metadata /private/var/mobile/Library/DuetExpertCenter/caches 错误 11:54:55.754498+0800 kernel Sandbox: duetexpertd(132) deny(1) mach-lookup com.apple.proactive.ActionPrediction.predictions 错误 11:54:55.756102+0800 duetexpertd Unable to remove recent engagement cache file. Error: Error Domain=NSCocoaErrorDomain Code=4 UserInfo={NSFilePath=, NSUserStringVariant=, NSUnderlyingError=0x100db60a0 {Error Domain=NSPOSIXErrorDomain Code=2}} 错误 11:54:56.571640+0800 symptomsd Attempt to add an app with insufficient id, info { BKSApplicationStateAppIsFrontmost = 1; BKSApplicationStateExtensionKey = 0; SBApplicationStateDisplayIDKey = "com.igetcool.app"; SBApplicationStateKey = 8; SBApplicationStateProcessIDKey = 696; SBApplicationStateRunningReasonsKey = ( { SBApplicationStateRunningReasonAssertionIdentifierKey = UIApplicationLaunch; SBApplicationStateRunningReasonAssertionReasonKey = 10000; } ); SBMostElevatedStateForProcessID = 8; } 错误 11:54:56.829372+0800 assertiond [IGCProject:696] SyscallError: setpriority(PRIO_DARWIN_ROLE, 696, 3): No such process 错误 11:54:56.944833+0800 dasd Activity not tracked as being started, ignoring it 错误 11:55:06.153790+0800 symptomsd Attempt to add an app with insufficient id, info { BKSApplicationStateAppIsFrontmost = 1; BKSApplicationStateExtensionKey = 0; SBApplicationStateDisplayIDKey = "com.igetcool.app"; SBApplicationStateKey = 8; SBApplicationStateProcessIDKey = 697; SBMostElevatedStateForProcessID = 8; } 错误 11:55:06.430433+0800 assertiond [IGCProject:697] SyscallError: setpriority(PRIO_DARWIN_ROLE, 697, 3): No such process 错误 11:55:13.158889+0800 symptomsd Attempt to add an app with insufficient id, info { BKSApplicationStateAppIsFrontmost = 1; BKSApplicationStateExtensionKey = 0; SBApplicationStateDisplayIDKey = "com.igetcool.app"; SBApplicationStateKey = 8; SBApplicationStateProcessIDKey = 699; SBMostElevatedStateForProcessID = 8; } 错误 11:55:13.416290+0800 assertiond [IGCProject:699] SyscallError: setpriority(PRIO_DARWIN_ROLE, 699, 3): No such process I am trying to understand what is causing this issue. Even after archiving and installing the app, it still crashes. According to the official documentation, Xcode 16 is supposed to support iOS 12, but this issue persists. I would like to know the possible reasons for this behavior.
0
0
293
Mar ’25
Using a Sysdiagnose Log to Debug a Hard-to-Reproduce Problem
I regularly talk to developers debugging hard-to-reproduce problems. I have some general advice on that topic. I’ve posted this to DevForums before, and also sent similar info to folks who’ve opened a DTS incident, but I figured I should write it down properly. If you have questions or comments, put them in a new thread here on DevForums. Put it in the Developer Tools & Services > General topic area and tag it with Debugging. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Using a Sysdiagnose Log to Debug a Hard-to-Reproduce Problem Some problems are hard to reproduce in your office. These usually fall into one of two categories: Environment specific — This is where some of your users can easily reproduce the problem, but you can’t reproduce it in your environment. Intermittent — In this case the problem could affect any user, but it’s hard to predict when a given user will see the problem. A key tool in debugging such problems is the sysdiagnose log. This post explains how to make this technology work for you. IMPORTANT A sysdiagnose log might contain private information. If you ask a user to send you a log, make sure they understand the privacy impact of that. If you want to see how Apple handles this, run the sysdiagnose command on a fresh Mac and read through it’s initial prompt. Sysdiagnose Logs All Apple platforms can generate sysdiagnose logs. For instructions on how to do this, see our Bug Reporting > Profiles and Logs page. The resulting log is a .tar.gz file. Unpacking that reveals a bunch of files. The most critical of these is system_logs.logarchive, which is a snapshot of the system log. For more information about the system log, including links to the documentation, see Your Friend the System Log. This log snapshot includes many thousands of log entries (I just took a log snapshot on my Mac and it had 22.8 million log entries!). That can be rather daunting. To avoid chasing your tail, it pays to do some preparation. Preparation The goal here is to create a set of instructions that you can give to your user to capture an actionable sysdiagnose log. That takes some preparation. To help orient yourself in the log, add log points to your code to highlight the problem. For example, if you’re trying to track down a keychain problem where SecItemCopyMatching intermittently fails with errSecMissingEntitlement ( -34018 ), add a log point like this: import os.log let log = Logger(subsystem: "com.example.waffle-varnish", category: "keychain") func … { let err = SecItemCopyMatching(…) log.log("SecItemCopyMatching failed, err: \(err)") } When you look through a log, find this specific failure by searching for SecItemCopyMatching failed, err: -34018. You might also add log points at the start and end of an operation, which helps establish a time range of interest. Log points like this have a very low overhead and it’s fine to leave them enabled in your released product. However, in some cases you might want to make more extensive changes, creating a debug build specifically to help investigate your problem. Think about how you’re going to get that debug build to the affected users. You might, for example, set up a special TestFlight group for folks who’ve encountered this issue. Go to Bug Reporting > Profiles and Logs and look for debug profiles that might help your investigation. For example, if you’re investigating a Network Extension issue, the VPN (Network Extension) debug profile will enable useful debug logging. Now craft your instructions for your user. Include things like: Your take on the privacy impact on this Instructions on how to get the necessary build of your product If there’s a debug profile, instructions on how to install that Instructions on how to trigger the sysdiagnose log And on how to send it to you IMPORTANT Make sure to stress how important it is that the user triggers the sysdiagnose immediately after seeing the problem. Finally, test your steps. Do an initial test in your office, to make sure that the log captures the info you need. Then do an end-to-end test with someone who’s about as technically savvy as your users, to make sure that your instructions make sense to Real People™. Prompting for a Sysdiagnose Log In some cases it might not be obvious to the user when to trigger a sysdiagnose log. Imagine you’re hunting the above-mentioned errSecMissingEntitlement error and it only crops up when your product is performing some task in the background. The user doesn’t see that failure, they’re not even running your app!, so they don’t know that action is required. A good option here is to add code to actively monitor for the failure and post a local notification requesting that the user trigger a sysdiagnose log. Continuing the above example, you might write code like this: func … { let err = SecItemCopyMatching(…) log.log("SecItemCopyMatching failed, err: \(err)") if err == errSecMissingEntitlement { … post a local notification … } } Obviously this is quite intrusive so, depending on the market for your product, you might not want to deploy this to all users. Perhaps you can restrict it to your internal testers, or your external beta testers, or a particularly savvy set of customers. You can use the applefeedback URL scheme to make it easy for users to run Feedback Assistant. For more info about that, see Developer > Bug Reporting. Looking at the System Log Once you have your sysdiagnose log, unpack it and open the system log snapshot (system_logs.logarchive) in Console. The hardest part is knowing where to start. That’s why adding your own log entries, as discussed in Preparation, is so important. A good general process is: Search for log entries from your subsystem. An easy way to initiate that search is to paste the text subsystem:SSS, where SSS is your subsystem, into the Search field. Continuing the above example, find that log entry by pasting in subsystem:com.example.waffle-varnish. Identify the log entry that indicates the problem and select it. Then remove your search and work backwards through the log looking for system log entries related to your issue. The relevant log entries might not be within the time range shown by Console. Customise that by selecting values from the Showing popup in the pane divider. Once you have a rough idea of the timeframe involved, select Custom from that popup to focus on that range. If the log is showing stuff that’s not relevant to your problem, Console has some great facilities for filtering those out. For the details, choose Help > Console Help. Talk to Apple A key benefit of this approach is that, if your investigation suggests that this is a system bug, you can file a bug report and attach this sysdiagnose log to it. The setup described above is exactly the sort of info needed to analyse the bug. Likewise, if you start a thread here on DevForums about your issue, your friendly neighbourhood DTS engineer will find that sysdiagnose log very handy. Revision History 2024-11-14 Added a reference to the applefeedback URL scheme. Made other minor editorial changes. 2023-10-13 First posted.
0
0
3.6k
Nov ’24
Error Missing required module 'RxCocoaRuntime' in xcframeworks
Hi. I have a xcframework that has a dependency on 'RxSwift' and 'RxCocoa'. I deployed it using SPM by embedding it in a Swift Package. However when I import swift package into another project, I keep getting the following error: "Missing required module 'RxCocoaRuntime" How can I fix this? Below are the steps to reproduce the error. Steps Create Xcode proejct, make a dependency on 'RxSwift' and 'RxCocoa' (no matter doing it through tuist or cocoapods) Create XCFramework from that proejct. (I used commands below) xcodebuild archive \ -workspace SimpleFramework.xcworkspace \ -scheme "SimpleFramework" \ -destination "generic/platform=iOS" \ -archivePath "./SimpleFramework-iphoneos.xcarchive" \ -sdk iphoneos \ SKIP_INSTALL=NO \ BUILD_LIBRARY_FOR_DISTRIBUTION=YES xcodebuild archive \ -workspace SimpleFramework.xcworkspace \ -scheme "SimpleFramework" \ -archivePath "./SimpleFramework-iphonesimulator.xcarchive" \ -sdk "iphonesimulator" \ SKIP_INSTALL=NO \ BUILD_LIBRARY_FOR_DISTRIBUTION=YES xcodebuild -create-xcframework \ -framework "./SimpleFramework-iphoneos.xcarchive/Products/Library/Frameworks/SimpleFramework.framework" \ -framework "./SimpleFramework-iphonesimulator.xcarchive/Products/Library/Frameworks/SimpleFramework.framework" \ -output "./SimpleFramework.xcframework" Embed in Swift Package, and deploy. // swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "SimplePackage", platforms: [.iOS(.v16)], products: [ .library( name: "SimplePackage", targets: ["SimplePackage"]), ], dependencies: [ .package(url: "https://github.com/ReactiveX/RxSwift", from: "6.8.0") ], targets: [ .binaryTarget( name: "SimpleFramework", path: "Sources/SimpleFramework.xcframework" ), .target( name: "SimplePackage", dependencies: [ "SimpleFramework", "RxSwift", .product(name: "RxCocoa", package: "RxSwift") ] ) ] ) Download Swift Package in another project and import module. I resolved this by removing dependencies from the Swift Package, downloading package in another project, and fetching dependencies by cocoapods. Thist works, but I don't want to use another dependency manager while using SPM. Development Environment CPU : Apple M4 Max MacOS : Sequoia 15.3 Xcode : 16.2
0
0
193
Mar ’25
Proxies Simulator
I have a VPN installed (Global Protect) on my company computer, which is a MacBook Pro M2, to access the company network, internal URLs, websites, and run the app I work on. However, even with the VPN installed, I am having trouble accessing certain resources. The solution found was to manually configure the proxies for my Wi-Fi network. After configuring the proxies, I was able to access all the company's URLs and everything I needed. However, the Xcode Simulator is not picking up these network configurations, and when I try to run the project, it does not work. How can I solve this?
0
0
154
Feb ’25
Getting an error in Xcode after resting simulator
I just made clean data on simulator then started getting the below error built on Xcode ? Showing Recent Issues Entitlements file "Clinic.entitlements" was modified during the build, which is not supported. You can disable this error by setting 'CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION' to 'YES', however this may cause the built product's code signature or provisioning profile to contain incorrect entitlements.
0
0
280
Feb ’25
How to retrieve overall memory peak in C++
I'm trying to retrieve the overall memory peak of a process. I've looked into retrieving it through task_vm_info struct defined in task_info.h By logging the members of the struct, it seems neither resident_size_peak, internal_peak or ledger_phys_footprint_peak is matching what the peak memory value that's being detected by xcode instrument. Can anyone point me to the correct way to retrieve that peak value? Is it the summation of some of the fields in task_vm_info` or is there a more complicated algorithm involved in deriving that value?
0
0
325
Nov ’24
Gathering Required Information for Troubleshooting Xcode Previews or Swift Previews Issues
Hi, You're here because your project has issues related to Xcode Previews or Swift Previews. The issue you're experiencing may be the result of any of the following: An error in your SwiftUI app, Xcode previews, or on-device previews. A configuration error in your Xcode project, including any third-party dependencies or packages. A system issue in the operating system, SwiftUI, or in Xcode Previews. Based on your request, I need more information about your SwiftUI app when rendering Xcode Previews or on-device previews. Specifically, I’ll need the diagnostics Swift Previews generates to make sure I understand the error encountered by the preview system. Please create a report in Feedback Assistant to share the details requested in the instructions below. For issues with macOS, Mac Catalyst, on-device iOS, or on-device visionOS previews, perform the following steps to gather diagnostics: Download and install the Swift Previews logging profile for your device. Reproduce the error while previewing on device, taking note of the timestamp when the error occurred. Attach the Previews diagnostics, sysdiagnose from your Mac, a sysdiagnose from the previewing iOS or visionOS device. For issues with Xcode Previews, perform the following steps to gather diagnostics: Download and install the Swift Previews logging profile for your device. Reproduce the error in Xcode Previews, if you haven’t already done so. If an error banner appears in the canvas, click the "Diagnostics" button within the banner, then go to Step 5; otherwise, continue to Step 4. If the error banner is missing, navigate to the menu in Xcode: Editor > Canvas > Diagnostics In the presented sheet, click the "Generate Report" button. Attach a zip file containing the diagnostic report to your bug report (it will be named something like previews-diagnostics-0123456789.zip). Submitting your feedback Before you submit to Feedback Assistant, please confirm the following information is included in your feedback: with the Swift Previews logging profile installed, attach the sysdiagnose logs gathered after reproducing the issue the Previews diagnostics generated by Xcode timestamp identifying when the issue was reproduced focused sample Xcode project that reproduces the issue (if applicable) screenshots or videos of the error (optional) Please include all requested information to prevent delays in my investigation. After your submission to Feedback Assistant is complete, please respond to your original Forums post with the Feedback ID. Once received, I can begin my investigation and determine if this issue is caused by an error within your SwiftUI app, a configuration issue within your Xcode project, or an underlying issue in the operating system, SwiftUI, in Xcode Previews, or on-device previews. Cheers, Paris X Pinkney |  WWDR | DTS Engineer
0
0
396
Feb ’25