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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

EXC_BAD_ACCESS if Address or Thread Sanitizer is enabled
I'm getting EXC_BAD_ACCESS (code=2, address=0x7ff8a6e2fcce) when launching my app on the simulator with Address or Thread Sanitizer enabled. I'm running Xcode 16.3 (16E140) on macOS Sequoia 15.4.1 (24E263). The call stack looks like the following. On the device, there is no crash, but this message is printed to the console: malloc: nano zone abandoned due to inability to reserve vm space. (Not sure if it's related.) Does anybody know what is causing the crash? Thread 1 #0 0x0000000103361f5b in __sanitizer::MemoryMappingLayout::Next () #1 0x000000010336034b in __sanitizer::MemoryRangeIsAvailable () #2 0x000000010334db77 in __asan::InitializeShadowMemory () #3 0x0000000103395069 in __asan::AsanInitInternal() (.cold.1) () #4 0x000000010334d352 in __asan::AsanInitInternal () #5 0x0000000103394f65 in __asan_init.cold.1 () #6 0x000000010334d325 in __asan::AsanInitFromRtl () #7 0x0000000103343289 in wrap_malloc_default_zone () #8 0x00007ff801b15f86 in __malloc_init () #9 0x00007ffa160080be in libSystem_initializer () #10 0x000000010306eb11 in invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const () #11 0x000000010308f364 in invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const () #12 0x00000001030aad7c in invocation function for block in mach_o::Header::forEachSection(void (mach_o::Header::SectionInfo const&, bool&) block_pointer) const () #13 0x00000001030a83c9 in mach_o::Header::forEachLoadCommand () #14 0x00000001030a98c8 in mach_o::Header::forEachSection () #15 0x000000010308ef62 in dyld3::MachOAnalyzer::forEachInitializer () #16 0x000000010306e9ac in dyld4::Loader::findAndRunAllInitializers () #17 0x0000000103074da1 in dyld4::JustInTimeLoader::runInitializers () #18 0x00000001030807c5 in dyld4::APIs::runAllInitializersForMain () #19 0x000000010305efac in dyld4::prepare () #20 0x000000010305e36e in _dyld_sim_prepare () #21 0x000000010993b2a0 in dyld4::prepareSim () #22 0x0000000109939963 in dyld4::prepare () #23 0x000000010993981f in dyld4::start(dyld4::KernelArgs*, void*, void*)::$_0::operator()() const () #24 0x00000001099394da in start ()
8
1
317
Jun ’25
Custom font doesn't appear on Storyboard custom font list
Hi everyone, (you can answer in french) I’m french-rookie in xcode, and I have a problem: I’m trying to choice my custom font to add it in my Main.storyboard button, but it not works. I have my « Font provided by application » line in my Info.plist, with the name of my font in [0] (See images below) When I’m on storyboard button, I chose « custom » in font selector, then display font list but my custom font doesn’t appear. I already tried to install the font in my mac, but still stucked, nothing change 😭 Could you help me please? Thanks a lot (I specify that I scrupulously followed the way of doing explained on the Apple official page: Adding a Custom Font to Your App )
8
3
3.5k
12h
xcode 16 ios 18.0 simulator download failed
I installed xcode 16 and both Predictive Code Completion Model and iOS 18.0 Simulator Failed Download. I can live without the code completion, but I can not get any Simulator to install. I clicked of the info button and it shows the following: Download failed. Domain: DVTDownloadableErrorDomain Code: 41 User Info: { DVTErrorCreationDateKey = "2024-09-30 15:57:24 +0000"; } Download failed. Domain: DVTDownloadableErrorDomain Code: 41 Failed fetching catalog for assetType (com.apple.MobileAsset.iOSSimulatorRuntime), serverParameters ({ RequestedBuild = 22A3351; }) Domain: DVTDownloadsUtilitiesErrorDomain Code: -1 Download failed as the server said authentication failed. (Catalog download for com.apple.MobileAsset.iOSSimulatorRuntime) Domain: com.apple.MobileAssetError.Download Code: 41 User Info: { checkServer = 1; } System Information macOS Version 15.0 (Build 24A335) Xcode 16.0 (23051) (Build 16A242d) Timestamp: 2024-09-30T10:57:24-05:00
8
2
6.3k
Apr ’25
Xcode 16.1 & iOS 18.1
After upgrading to mac os 15.1 my Xcode has been complaining about iOS 18.1 that is missing. No matter what I do I cannot get it installed, I ended up clearing all caches, re-installing Xcode but that also failed. Downgrading to 16.0 or upgrading to 16.2 beta has the same issue. Currently I cannot create any simulator or install any version of the iOS platform. Xcode would say it's installing but the runtime would not show up in the list. I have tried adding runtimes using xcrun simctl and also other methods indicated here. Another colleague of mine that updated to OSX 15.1 also has the same issue so this doesn't seem like a isolated problem. In the screenshots below you'll see 18.1 is installed but does not show up as an installed runtime.
8
4
4.8k
Oct ’24
Xcode 16 Beta not recognizing Apple Vision Pro on devices
I downloaded the new Xcode 16 Beta and AVP OS 2.0, But I saw that in Windows --> Devices + Simulators, my Mac was not recognizing that I had updated the Vision Pro's OS. So, I disconnected the AVP and tried connecting it again, but the device is not showing up. I've tried going into Remote Devices within the headset, disabling/enabling Developer Mode, turning off/on Wifi, restarting both devices. Is this an issue with XCode 16 Beta and/or Vision OS 2.0?
8
2
1.4k
Nov ’24
Can't add capabilities in Xcode
We had push notifications and associated domains capabilities to our app but something happened either with my certificates or Xcode and they disappeared and can't add any capabilities anymore. https://imgur.com/peRXNO6 Our App ID, certificate and provisioning profile are all correct and contain the correct capabilities.
8
1
2.7k
Jan ’25
Xcode 16 RC - Cannot add packages
When opening the package management sheet there is a loading indicator going forever preventing the button to be enabled. The window displays collections but not "Recently used" (which also loads indefinitely). Anyone else seeing this? Any way to clear Xcode preferences/caches for the manager?
8
8
2.2k
Sep ’24
Intelligence Features not available in Xcode 26 beta 1
At the Platform State of the Union, Apple demoed clicking a ✨ button in the Xcode toolbar to use Apple Intelligence in Xcode. I don't see that button in Xcode Version 26.0 beta (17A5241e). Am I missing it? It's supposed to be in the upper-left corner, right? Do I need to turn it on or something? I'm on macOS 15.5 Sequoia, on a 16-inch, 2021 MacBook Pro
8
7
724
Jun ’25
Mergeable Libraries: Missing Resources
It's not possible to merge a framework with resource into an iOS app target because the resource are not included in the app bundle. Steps to reproduce: Create an Xcode Project with iOS App Template Add a Framework Target (make sure to "Embed in Application") Add an Asset Catalog to Framework Target Add an Color Resource (or Image Set, or any other Resource) Reference the Resource in App Target (I have used a SwiftUI View) Run on Device (!) to make sure everything works as expected Change "Create Merged Binary (MERGED_BINARY_TYPE)" build setting of app target to "Automatic (automatic)" Change app target settings to link, but not embed framework target (e.g. change from "Embed and Sign" to "Do Not Embed" in "Frameworks, Libraries and Embedded Content" section in "General" tab) Run again (on Device!) and observe how the resources framework resource cannot be found anymore (using SwiftUI you will see a "No image/color named '...' in asset catalog for ..." error message in console logs) Note: Everything works fine in Simulator Same behavior for Release and Debug configuration Same behavior for manual and automatic merging Same behavior for resources which are not bundled in Asset Catalog When archiving the app, an "Assets.car" file is never present (even when creating archiving for Simulator target, when "Allow archiving for Simulator" is enabled) Reported as FB13716505 Test Project: https://github.com/iteracticman/MergeableResources/
8
1
2.3k
Oct ’24
Xcode 16.3 repeatedly log causing CPU leak
Xcode 16.3 repeatedly logs a same message very frequently, as fast as a single thread can. I use Instruments and Console and find out the log is: Needs flush! by -[DNTBrotliDecoder decodeBytes:length:] in DNTDocumentationSupport. The call is on a single non-main thread. I've tried to clear caches and it seems doesn't change. Yet I don't know exact point when the logging starts since launch. Fortunately, this thread is dispatched at E cores, bringing approximately 2 watts of power load to my Mac. Environments: macOS 15.4 (24E248) Xcode 16.3 (16E140) M4 chip
7
3
234
May ’25
How to prevent duplicate resource bundles from SPM dynamic framework in app extensions?
We use a local swift package in 6 of our app extensions. The product from the local package that we link to each app extension is a dynamic framework. And while the dynamic framework is copied into the final app bundle once, the resource bundles of each target that comprise the dynamic framework is copied into each app extension. I'd much rather have the bundles be copied into the dynamic framework once to prevent app bloat. Here is a visualization of the issue: . └── MyApp.ipa/ ├── MyApp (executable) ├── MyDynamicFramework_TargetA.bundle ├── MyDynamicFramework_TargetB.bundle ├── MyDynamicFramework_TargetC.bundle ├── Frameworks/ │ └── MyDynamicFramework.framework/ │ ├── TargetA │ ├── TargetB │ └── TargetC └── PlugIns/ ├── Widgets.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle ├── Intents.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle ├── IntentsUI.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle ├── NotificationContent.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle ├── RichPushContent.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle └── NotificationService.appex/ ├── MyDynamicFramework_TargetA.bundle ├── MyDynamicFramework_TargetB.bundle └── MyDynamicFramework_TargetC.bundle Notice that the resource bundles of Target A, B, and C are copied multiple times causing an unhealthy app size. I'd either like the resource bundles to be copied into MyDynamicFramework or copied once into the app bundle and let the app extensions reference them. Given the SPM + Xcode linking is a black box for the most part, how would I accomplish this?
7
2
1.9k
Dec ’24
Xcode - Product > Archive files
Hello. I'm working on an app which works on multiple platforms (iOS, macOS, watchOS, tvOS). It builds and runs fine on the simulator and a real device but when trying to create a Product > Archive on macOS, it fails. Here's the error message I get: Build target RailBoardMac Project RailBoard | Configuration Debug | Destination Any Mac | SDK macOS 15.1 Link RailBoardMac (x86_64) 0.3 seconds Could not parse or use implicit file '/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/SwiftUlCore.framework/ Versions/A/SwiftUlCore.tbd': cannot link directly with 'SwiftUlCore' because product being built is not an allowed client of it less Undefined symbol: _main × Linker command failed with exit code 1 (use -v to see invocation) Build failed 20/09/2024, I know this used to work. I must have changed something somewhere and it no longer does. I'd be grateful for any assistance.
7
0
694
Nov ’24
SwiftData error: NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
I am using SwiftData for my model. Until Xcode 15 beta 4 I did not have issues. Since beta 5 I am receiving the following red warning multiple times: 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release This seems to be a CoreData warning. However, I am not using CoreData directly. I have no way to change the config of CoreData as used by SwiftData. My model just uses UUID, Int, String, Double, some of them as optionals or Arrays. I only use one attribute (.unique).
7
3
3.1k
May ’25
cannot find text1 in scope
import SwiftUI struct viewdetail: View { @State var text1:String = "" @State var tip1:String = "" @State var text23:String = "" @State var tip23:String = "" var body: some View { Text(text1);Text(tip1);Text(text23);Text(tip23) } } func detailLine(costa:inout [Double],tipa:inout [Double]) { print(costa,tipa) text1 = "125" cannot find 'text1' in scope print("detail") } func delete(costa:inout [Double],tipa:inout [Double],number: inout Int) { print(costa,tipa) tipa.removeLast() costa.removeLast() number -= 1 print(costa,tipa) } #Preview { viewdetail() } Does anyone know why I'm getting "cannot find text1 in scope"?
7
0
302
Dec ’24
Xcode won't execute code?
Hi everyone. I have the following code that I am trying to execute in Xcode. I then install it on my iPhone. It doesn't run at all and I don't know why. Any thoughts? Thank you. import CoreMotion class MyViewController: UIViewController { let motionManager = CMMotionManager() func startAccelerometer() { if motionManager.isAccelerometerAvailable { motionManager.accelerometerUpdateInterval = 0.1 // 10 updates per second motionManager.startAccelerometerUpdates(to: .main) { (data, error) in guard let accelerometerData = data else { return } let x = accelerometerData.acceleration.x let y = accelerometerData.acceleration.y let z = accelerometerData.acceleration.z // Process the x, y, and z acceleration values here print("X: \(x), Y: \(y), Z: \(z)") } } } }
7
0
145
3w
Command line argument behaviour in macOS 15 after compiling with Xcode 16
I encountered this issue with an app I'm writing that accepts arguments. With some troubleshooting I've determined that this is an inherent behaviour in how Xcode 16 compiles SwiftUI apps and how macOS 15 launches them. The issue: Launching the app as open /Applications/AppName.app --args --arg1 --arg2 --arg3 etc should allow the app to process the arguments as CommandLine.arguments and this is still the case. How the app sees arguments is unchanged and doesn't matter if you use CommandLine.arguments or swift argument parser or don't have arguments at all. This will affect any SwiftUI app as I'll demonstrate below. The problem is that if you use a mix of arguments as --arg value pairs or --arg as a flag, then depending on the order the arguments are provides, the app won't launch properly. The icon will appear in the dock but no window appears until you click the icon in the dock. (BTW, having "Application is agent (UIElement)" set to YES in the Info.plist makes this task rather difficult.) In testing if you use all flags, it's fine. if the flags are in pairs, it's fine. if you have one flag and then a --arg value pair, you will see the issue. If you reverse the order so the flag is after then it works fine. How to replicate: On macOS 15 and Xcode 16 Open Xcode Create a new macOS App (called demoapp in my example) Select SwiftUI as the interface Build That it. Don't add anything and just build the boilerplate hello world app that Xcode makes for you. Once that's built, cd to your /Build/Products/Debug/ directory in terminal and try the following (this happens if you build for release as well): note, the app window will display when you click the icon in the dock, just not on initial launch # three single arguments open ./demoapp.app --args --foo --bar --baz # App window displays as expected # one single argument, one arg value pair open ./demoapp.app --args --foo --bar baz # The app window will not appear. # same arguments as before but the single argument is after the arg value pair open ./demoapp.app --args --bar baz --foo # App window displays as expected # arg[1] without `-` or `--` prefix open ./demoapp.app --args foo --bar --baz # The app window will not appear. # arg[1] and arg [2] without prefix open ./demoapp.app --args foo bar --baz # The app window will not appear. # single - in front of the first two arguments open ./demoapp.app --args -foo -bar baz # The app window will not appear. # single - in front of the first three arguments open ./demoapp.app --args -foo -bar -baz bob # App window displays as expected No idea what is going on but I suspect macOS does some pre-processing before launching the app, for example you can do stuff like open /Applications/SomeApp.app --args -AppleLanguages '(de)' to run using a specific language. I presume the OS is pre-processing arguments before launching the app proper. If I compile the app using Xcode 15.4 then this issue is not present. Also Apps compiled with Xcode 16 do not exhibit the issue on macOS 14 or earlier. It's a specific Xcode 16, macOS 15 thing in the way the app is compiled that makes it behave this way. I hope I've explained it correctly, but it's very easy to replicate. I filed a feedback for it (under a different apple account), FB15577018. Any insight into what's going on here would be helpful. Also if there's any compiler flags I could be setting. In my actual project, I'm not making any other changes. The same code compiled under Xcode 16 (.0 or .1RC) behaves differently to Xcode 15.4.
7
1
590
May ’25
Predictive Code Completion stopped working on new MacBook Pro
Happy to have a new MacBook Pro M4 now - the new machine was setup from time machine backup of my old MacBook Pro M1. Sadly Predictive Code Completion does not work on the new M4 (it was working great on the M1). Xcode shows as downloaded component: Predictive Code Completion Model [com.apple.fm.code.generate_small_v1.base: 500.1.81600.13.200772,0] [com.apple.fm.code.generate_safety_guardrail.base: 1.6.81619.13.200716,0] [com.apple.gm.safety_deny.input.code_intelligence.base: 32024010.20241007.171244.100.377,0] [com.apple.gm.safety_deny.output.code_intelligence.base: 32024010.20241007.171244.100.377,0] (Installed) Things I already tried: Removed and reinstalled Xcode 16 (also latest beta). Disabled/enabled Xcode Editor Settings for predictive code completion Many many reboots Removed Xcode cache Maybe the downloaded Model is somehow locked to the old machine? How can I remove, redownload or reinstall it again? Thank you very much. Tobias
7
5
1.7k
Dec ’24
MacOSX Sonoma 14.7 + XCode 16.0 + iOS 17.6.1:
I am trying to install an app from a XCode project onto a iOS 17.6.1 device. The Macbook is a MacOSX Sonoma 14.7, Apple M2 Pro. I'm running XCode 16.0. I receive a series of alerts before receiving the final message. I tried to delete everything in this folder: rm ~/Library/Caches/com.apple.dt.Xcode/Downloads/* I reviewed the XCode components currently installed: I downloaded more runtime simulators from this link. I then followed the instructions provided in this link. For example: xcrun simctl runtime add "~/Downloads/iOS_17.4_Simulator_Runtime.dmg" xcrun simctl runtime add "~/Downloads/iOS_17.5_Simulator_Runtime.dmg" I'm still getting a message beside the device I want to install my app: The Developer Disk Image Could Not Be Staged On The Host I need help. I don't know what else to do. I don't see any matching simulators available for 17.6.1 and 17.7. Does anyone have any ideas?
7
0
2.5k
Oct ’24
How to turn off "connect via network" on Xcode 15?
This is really a disgusting function and I can't turn it off. Because the check box is grey, no way to turn it off. Even I connect my device via cables. Debug becomes slow. Although I connect my device via cable. And I'm developing a VPN application, it's rediculous that once I connect VPN from my device, Xcode will disconnect from my device. I can't stand this function any m ore. Does anyone know how to turn it off?
7
4
2.7k
Oct ’24