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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Created

Xcode 16 beta 3 can't load Teams in VM
I'm currently setting up a new build environment. Our old build server was a small M1 Mac Mini set up to build our, up-to-now, only app. Since we now have a second app (and probably more to come) and have some issues building all on the same mac (gem versions, flutter versions, etc.) I now set up a virtualized build environment. I'm currently running a MacOS 15 beta 3 VM on a M2 Mac Mini also on MacOS 15 beta 3. The VM has all basic tools inside, including Xcode 16 beta 3 and is logged in with our AppleID for our build server. The VM is spun up with a non-persistent storage before the build, installs the gem's/flutter in the correct version, checks out the code and builds it. Now I'm getting an error on the build, that I have to select a development team, but he team is already selected and the build is working fine on the old M1 Mac Mini. It is suggested to login to Xcode, so I logged in to Xcode in the VM, which itself was successful, but when loading the teams I'm getting the following error: Decoding Error There was a failure decoding response: (HTTP 401, 60 bytes) The data couldn't be read because it isn't in the correct format.. The account info is correct, it's the same account that is logged in to MacOS and it's the same account from the old build system. I guess this somehow has to do with the MacOS VM (before MacOS 15 it was not possible to signin to an apple id, this is also the reason why I use the beta). Is there any chance to fix this and get it working? We are not able to use Xcode cloud builds (or any other cloud services) due to corporate policies. We are also not able to buy a dedicated Mac Mini for every app (too expensive and too much time needed for maintenance).
6
2
3k
Jul ’24
Xcode UI test cannot tap menu button in form
Apparently UI tests are unable to tap menu buttons but can tap regular buttons inside forms. Earlier today I was able to see in the Simulator that the UI test tries to tap the button by tapping the center of the containing form row, which works for regular buttons, but not for menu buttons. In fact, when trying in the SwiftUI preview in Xcode it seems that menu buttons have to be tapped exactly on top of them, while regular buttons can be tapped anywhere in the form row. (Now I’m not able to see touches performed by the UI test anymore in the Simulator for an unknown reason, even though I have “Show single touches” enabled in the Simulator settings.) How can I open a menu button in a UI test? The UI code: struct ContentView: View { @State private var label1 = "Menu 1" @State private var label2 = "Menu 2" var body: some View { NavigationStack { Form { LabeledContent("Menu 1") { Button(label1) { label1 = "Menu 1 tapped" } .accessibilityIdentifier("menu1") } LabeledContent("Menu 2") { Menu(label2) { Button("Button") { } .accessibilityIdentifier("button") } .accessibilityIdentifier("menu2") } } } } } #Preview { ContentView() } And the test: final class problemUITests: XCTestCase { func testExample() throws { // UI tests must launch the application that they test. let app = XCUIApplication() app.launch() app.collectionViews.element(boundBy: 0).buttons["menu1"].tap() app.collectionViews.element(boundBy: 0).buttons["menu2"].tap() app.collectionViews.element(boundBy: 0).buttons["button"].tap() } }
2
0
674
Jul ’24
Could not build module 'UIKit' - XCode 16 Beta 3
I have an old project that combines Objective-C with Swift and it is compiling just fine in XCode 15 but is not compiling on XCode 16 Beta 3. There are multiple errors such as: "could not build module 'UIKit'" "could not build module 'CoreMedia'" "could not build module 'CoreLocation'" Among the errors there is this one about failing to emit precompiled header in the Bridging header file of the project. I've tried re-installing XCode 16 Beta 3, re-installing the simulator, restarting the computer and I've also created a sample project that also combines swift and Ojb-c and that one compiles just fine. Any clues? Thanks!
11
3
5.1k
Jul ’24
Xcode Preview says:Cannot preview in this file: Failed to launch (App Name)
When I attempt to preview my code, I encounter an error message stating, “Cannot preview in this file: Failed to launch (App Name).” This issue is specific to this particular app. I attempted creating a new project, and that works fine. This is what it says in the diagnostics: | [Remote] JITError | | ================================== | | | [Remote] LLVMError | | | | LLVMError: LLVMError(description: "The file was not recognized as a valid object file")
12
3
2.6k
Aug ’24
Unable to debug app on phone
After updating macOS (macbook M2 Max) to Version 15.0 Beta (24A5298h) and running Xcode version 16.0 beta 4 (16A5211f), I am no longer able to debug apps on phones due to that I can not load them to the phone (even with cable connection). I had no issues in the past with these phones. The error message in Xcode is "Previous preparation error: Developer Mode disabled; To use iPhone for development, enable Developer Mode in Settings → Privacy & Security." But the phones are in Developer mode. Updating phones to a later iOS version does not help. Also, going back in Xcode does not help, as with macOS 15.0 Beta you need to have Xcode 16.0 Trying other phones that worked in the past does not help. Reinstalling Xcode does not help either. I see the phones in Finder, so there is a connection. Enabling/Disabling the Developer mode switch on the phone does not help either. Rebooting devices neither. Tried everything available on the internet, but no results. Need to test on phones, as I am using AR, which doesn't to run with the simulator.
13
3
1.6k
Aug ’24
Xcode 16 no longer sets ENABLE_PREVIEWS=YES for preview builds
Up until now, it was possible to check in build scripts via the ENABLE_PREVIEWS environment variable whether a build for a SwiftUI preview is being executed. In addition, it was also possible to conditionally compile code for SwiftUI or exclude it from compilation using this variable. This no longer works with Xcode 16 and the new SwiftUI Preview compilation! There is still the option to switch to the old system with the "Use Legacy Previews Execution" setting, but as stated in the release notes, this option will be removed at some point. Which brings us back to the old problem of not being able to exclude build scripts from preview builds and not being able to prevent certain code from being compiled / add special code for SwiftUI previews. This is a terrible situation, especially for more complex projects in which precisely the points mentioned are important for the build process. I seriously hope Apple provides us with another environment variable for SwiftUI preview builds that we can use.
12
17
6.1k
Aug ’24
ERROR: Unrecognized attribute string flag '?' in attribute string "T@"NSString",?,R,C" for property debugDescription
Hello, I'm seeing many errors like this in the Xcode debug console when I build and run my app: ERROR: Unrecognized attribute string flag '?' in attribute string "T@"NSString",?,R,C" for property debugDescription The app project makes heavy use of Logger(), and I suspect it is related to that logging in some way, but I haven't been able to narrow down the issue to specific log calls. I have Category, Subsystem and Timestamp enabled in the Xcode console, but none of those are displayed for this output. What causes this? Or how can I better narrow down the source?
4
3
949
Aug ’24
App is crashing when using "withCheckedContinuation" in Xcode 15 beta 5
We are experiencing an issue with withCheckedContinuation in our Swift project. Our implementation was working perfectly in a previous version of Xcode and continues to work in the simulator. However, it fails to work on a real device. Here’s a brief description of the problem: • Environment: - Xcode Version: Xcode 16.0 Beta 5 - Swift Version: Swift 5 - OS: IOS18 beta 5 • Problem: The code using withCheckedContinuation behaves as expected in the simulator but fails on a physical device. We are receiving a “bad access to memory” error when running on a real device. • What We’ve Tried: 1. Verified that the code works in previous Xcode versions. 2. Tested on different simulators, where it runs without issues. 3. Checked for any obvious errors in memory handling or threading. Code Example: Here’s a simplified version of the problematic code: var body: some View { VStack { Text("Hello, world!") } .padding() .onAppear { Task { await self.checkTrialOrIntroductoryDiscountEligibilityAsync() } } } func checkTrialOrIntroductoryDiscountEligibilityAsync() async { return await withCheckedContinuation { continuation in checkTrialOrIntroDiscountEligibility() { continuation.resume() } } } func checkTrialOrIntroDiscountEligibility(completion: () -> Void) { completion() } }
18
9
3.8k
Aug ’24
Xcode 16 warning about missing symbols of static framework
I work on an SDK, and one of the ways we distribute it is as a pre-compiled static XCFramework. As far as I know, it’s the nature of a static framework to not contain symbols since the framework will be embedded in the final app binary, and the symbols should then be generated. However, when testing the "Validate" function of the Xcode 16 deployment process, our users are receiving a warning that says the framework does not contain symbols. Is my assumption about static frameworks and symbols incorrect? Could this be a bug in Xcode 16? Should we modify something in our framework to inform Xcode that symbols are not needed?
45
24
41k
Aug ’24
xcode16.1beta compile error
SDK has some compile errors, when it can be fixed? We want to develop iOS 18 new features in our application. /Users/***/XcodeBeta/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.1.sdk/usr/include/c++/v1/__type_traits/is_arithmetic.h:24:29 'std::is_arithmetic' has different definitions in different modules; defined here /Users/***/XcodeBeta/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.1.sdk/usr/include/c++/v1/__type_traits/is_integral.h:53:29 'std::is_integral' has different definitions in different modules; defined here
3
1
821
Aug ’24
The requested device could not be found because multiple devices matched the request.
I'm facing this issue intermittently since using Xcode 16 beta 4 on macOS 14.5 when starting xcodebuild build with -destination option. 20:56:07 ▸ xcodebuild: error: Unable to find a device matching the provided destination specifier: 20:56:07 ▸ { platform:iOS Simulator, OS:15.4, name:iPhone 13 Pro } 20:56:07 ▸ The requested device could not be found because multiple devices matched the request. ( 20:56:07 ▸ "<DVTiPhoneSimulator: 0x151fb1fe0> {\n\t\tSimDevice: iPhone 13 Pro (CB36E92A-C32D-481C-A407-28123ABEBF66, iOS 15.4, Shutdown)\n}", 20:56:07 ▸ "<DVTiPhoneSimulator: 0x151fb4070> {\n\t\tSimDevice: iPhone 13 Pro (0EBBCB9A-5FBA-4998-903B-1415315D1533, iOS 15.4, Shutdown)\n}" 20:56:07 ▸ ) This mac is mac mini 2023 M2 Pro 32GB memory, running with multiple simruntimes installed: $ sudo xcrun simctl runtime list Password: == Disk Images == -- iOS -- iOS 17.5 (21F79) - 9FC1CFB3-33A4-4F31-AF40-BAB448F6FA0D (Ready) iOS 16.4 (20E247) - 3BFB66B1-075B-4B17-951C-B691BAC41C73 (Ready) iOS 17.2 (21C62) - C8D4111F-1F7A-4FC2-AC6A-BF68A47EEDCE (Ready) iOS 17.4 (21E213) - 0B8ECC25-EF76-4744-9D77-8256A57D1605 (Ready) iOS 18.0 (22A5326g) - 7217B9B2-A113-4B6B-915E-CAB70431B415 (Ready) iOS 17.0.1 (21A342) - C4FE430B-DD3F-4108-B2E7-B13A04989863 (Ready) iOS 15.4 (19E240) - CAB77B36-B6D3-4F5D-8956-E7A3105AC910 (Ready) iOS 18.1 (22B5023e) - 9E53F2C6-BA91-421C-848F-F78043179361 (Ready) -- tvOS -- tvOS 17.2 (21K364) - 8A9929AE-0521-498D-884A-F87BD16612CD (Ready) tvOS 16.4 (20L494) - 3354C9A4-E177-4030-98F2-0735970E1607 (Ready) tvOS 17.4 (21L224) - 724CD6DA-EAC2-4076-A578-C84872A36E5E (Ready) tvOS 15.2 (19K50) - 0AE51520-B1E2-4ED9-80A4-717291FC5E96 (Ready) tvOS 18.0 (22J5335e) - E839E471-AA01-46E1-A4AD-DF4B98B46525 (Ready) tvOS 17.5 (21L569) - C432547A-F7EF-4B34-AD43-D3E839CB49E1 (Ready) tvOS 17.0 (21J353) - 6A08D50B-D9BF-4496-A5C5-FE21373B11DD (Ready) tvOS 18.0 (22J5324f) - B2C7CA72-AAE6-4DF9-A4B0-26A0EB9462F7 (Ready) -- watchOS -- watchOS 11.0 (22R5318h) - 56250DF3-CF78-4C5D-B502-0B53DE16ABEB (Ready) watchOS 10.4 (21T214) - CC71D3D3-EA19-4F0B-BF3E-388D686AB300 (Ready) watchOS 10.0 (21R355) - 3623992D-88CF-41CB-8091-AF1F8CE16717 (Ready) watchOS 10.2 (21S364) - C0666241-AA31-4CF7-98B9-EA5394331DC6 (Ready) watchOS 9.4 (20T253) - EED82B11-589D-41AF-B290-844F59AECECB (Ready) watchOS 10.5 (21T575) - 0D749B4E-DC69-4F27-8982-510AB985B822 (Ready) watchOS 8.3 (19S51) - 8123ABC7-5465-4467-A5DA-CE9C50E1081D (Ready) watchOS 11.0 (22R5328f) - 648646A0-A370-48A4-881B-15B2422DE698 (Ready) -- xrOS -- xrOS 2.0 (22N5297g) - C2C8E4EE-3738-4706-823E-2B4138CE90BE (Ready) xrOS 1.0 (21N305) - 29EAB8D4-160D-4A3B-AB7C-7325D205AC4C (Ready) xrOS 2.0 (22N5286g) - 1F92EE9A-A5F9-45F7-8075-7FD7BC4EF81E (Ready) xrOS 1.1 (21O209) - DB15F0B2-C9E4-424D-9A50-8D6EDB131142 (Ready) xrOS 1.2 (21O5565d) - 83A26410-A8A8-41F6-A5A1-E0A7E24B8BA0 (Ready) I've never seen this kind of simulator missing error. Nor installing any duplicate runtime(s) on the same machine because it will show error message like 'unable to use this runtime' on xcrun simctl runtime list. Could anyone give me a tip of avoiding this kind of error?
3
0
1.1k
Aug ’24
SPM Package resources bundle id format has changed in Xcode 16
I have a project that uses local SPM packages for modularization. In one of my local SPM packages I have a .storyboard file that gets packaged as a resource in the SPM package and consumed inside the parent. In Xcode 15.4, the resource bundle for my local SPM Package has the bundle id PackageName-TargetName-resources. I use this inside a parent storyboard to reference the storyboard from the SPM package. In Xcode 16, however, the resource bundle for my SPM Package gets assigned the bundle id packagename.TargetName.resources. This, of courses, introduces a crash in builds of my app done with Xcode 16 due to the incorrect bundle id. There is no documentation of this change that I could find by Apple or by the SPM team. Apple Team: There is a Feedback Report FB14803020 with the build files attached from Xcode 15.4 and Xcode 16. I cannot attach those here due to the public nature of this forum
3
1
988
Aug ’24
Unable to connect Xcode 16 Beta to iPhone
I am unable to connect iPhone to Xcode. Getting error - The developer disk image could not be staged on the host.; Couldn’t communicate with a helper application. Xcode - 16 Beta Mac OS - Sonoma 14.6.1 iOS - 17.6.1 VPN - No Details are as follows: The developer disk image could not be staged on the host. Domain: com.apple.dt.CoreDeviceError Code: 12045 Failure Reason: Couldn’t communicate with a helper application. User Info: { DVTErrorCreationDateKey = "2024-08-21 11:04:09 +0000"; DeviceIdentifier = "01162B62-9C06-48A4-B2F7-D17ABD2D35B0"; NSURL = "file:///Library/Developer/DeveloperDiskImages/iOS_DDI.dmg"; "com.apple.dt.DVTCoreDevice.operationName" = enablePersonalizedDDI; } -- Couldn’t communicate with a helper application. Domain: NSCocoaErrorDomain Code: 4099 Recovery Suggestion: Try your operation again. If that fails, quit and relaunch the application and try again. User Info: { NSDebugDescription = "The connection to service created from an endpoint was invalidated: failed at lookup with error 9 - Bad file descriptor."; } -- System Information macOS Version 14.6.1 (Build 23G93) Xcode 16.0 (23047) (Build 16A5221g) Timestamp: 2024-08-21T16:34:09+05:30 **Tried so far - ** Xcode Quit and Reopen Restart iPhone Restart Mac Reinstalling Xcode Reset Network Settings on iPhone Developer mode ON/OFF Unpair and Pair Again Clear Trusted Computers Tried with different iPhone Cables(Not needed one but tried) Factory Reset of iPhone Please guide how to resolve this.
2
0
794
Aug ’24
SwiftData/ModelCoders.swift:1762: Fatal error: Passed nil for a non-optional keypath
I updated today at Xcode 16 beta 6, and my app using SwiftData on iOS 18 (beta 6) is getting now this new error when saving the model in the modelContext. I don't understand if it is a regression introduced in the beta 6 or if it is enforced something that previously wasn't. It seems to be always referred to the ID property, for example: SwiftData/ModelCoders.swift:1762: Fatal error: Passed nil for a non-optional keypath \MyModel.id In this case (and in most of the cases in my models) the ID is defined as following @Attribute(.unique) public var id: UUID I also tried to add the initialization inline, but didn't help @Attribute(.unique) public var id: UUID = .init() I also tried to remove the @Attribute(.unique), didn't help as well. Does any of you have the same issue?
7
3
1.6k
Aug ’24
How to delete built in iOS Simulator in Xcode 14
I am using Xcode 14, but the built in iOS 16 simulator does not run properly on my device, so I use iOS 14 simulator. If I use the old version of Xcode then I will have to compromise with many labraries, frameworks and features and I don't want that. So I want to delete the built in iOS 16 simulator of Xcode 14 to free up memory, because I don't need this. please help me ?
2
0
676
Aug ’24