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

Xcode Documentation

Post

Replies

Boosts

Views

Activity

My App crashes run-time occasionally when I use AVFoundation and related code
I am developing an app for Vehicle owners with a built-in map navigation feature with voice navigation support. The app works fine without voice navigation but when I use voice navigation it occasionally crashes and it crashes while voice navigation is not in progress. What makes it impossible to diagnose is that even though it crashed 10 times on the flight, I don't see any crash reports in 'Apple Connect'. I tried running it in a simulator and it didn't crash there! but on a real device, when I drive with the app navigating me I crashes abruptly after a few minutes and it's not while the voice navigation is speaking! I also ran the app without AVFoundation and it did not crash then. So I am 100% sure it is something with this AVFoundation framework. If anyone can help find the problem in my following code it would be really helpful. import SwiftUI import AVFoundation struct DirectionHeaderView: View { @Environment(\.colorScheme) var bgMode: ColorScheme var directionSign: String? var nextStepDistance: String var instruction: String @Binding var showDirectionsList: Bool @Binding var height: CGFloat @StateObject var locationDataManager: LocationDataManager @State private var synthesizer = AVSpeechSynthesizer() @State private var audioSession = AVAudioSession.sharedInstance() @State private var lastInstruction: String = "" @State private var utteranceDistance: String = "" @State private var isStepExited = false @State private var range = 20.0 var body: some View { VStack { HStack { VStack { if let directionSign = directionSign { Image(systemName: directionSign) } if !instruction.contains("Re-calculating the route...") { Text("\(nextStepDistance)") .onChange(of: nextStepDistance) { let distance = getDistanceInNumber(distance: nextStepDistance) if distance <= range && !isStepExited { startVoiceNavigation(with: instruction) isStepExited = true } } } } Spacer() Text(instruction) .onAppear { isStepExited = false utteranceDistance = nextStepDistance range = nextStepRange(distance: utteranceDistance) startVoiceNavigation(with: "In \(utteranceDistance), \(instruction)") } .onChange(of: instruction) { isStepExited = false utteranceDistance = nextStepDistance range = nextStepRange(distance: utteranceDistance) startVoiceNavigation(with: "In \(utteranceDistance), \(instruction)") } .padding(10) Spacer() } } .padding(.horizontal,10) .background(bgMode == .dark ? Color.black.gradient : Color.white.gradient) } func startVoiceNavigation(with utterance: String) { if instruction.isEmpty || utterance.isEmpty { return } if instruction.contains("Re-calculating the route...") { synthesizer.stopSpeaking(at: AVSpeechBoundary.immediate) return } let thisUttarance = AVSpeechUtterance(string: utterance) lastInstruction = instruction if audioSession.category == .playback && audioSession.categoryOptions == .mixWithOthers { DispatchQueue.main.async { synthesizer.speak(thisUttarance) } } else { setupAudioSession() DispatchQueue.main.async { synthesizer.speak(thisUttarance) } } } func setupAudioSession() { do { try audioSession.setCategory(AVAudioSession.Category.playback, options: AVAudioSession.CategoryOptions.mixWithOthers) try audioSession.setActive(true) } catch { print("error:\(error.localizedDescription)") } } func nextStepRange(distance: String) -> Double { var thisStepDistance = getDistanceInNumber(distance: distance) if thisStepDistance != 0 { switch thisStepDistance { case 0...200: if locationDataManager.speed >= 90 { return thisStepDistance/1.5 } else { return thisStepDistance/2 } case 201...300: if locationDataManager.speed >= 90 { return 120 } else { return 100 } case 301...500: if locationDataManager.speed >= 90 { return 150 } else { return 125 } case 501...1000: if locationDataManager.speed >= 90 { return 250 } else { return 200 } case 1001...10000: if locationDataManager.speed >= 90 { return 250 } else { return 200 } default: if locationDataManager.speed >= 90 { return 250 } else { return 200 } } } return 200 } func getDistanceInNumber(distance: String) -> Double { var thisStepDistance = 0.0 if distance.contains("km") { let stepDistanceSplits = distance.split(separator: " ") let stepDistanceText = String(stepDistanceSplits[0]) if let dist = Double(stepDistanceText) { thisStepDistance = dist * 1000 } } else { var stepDistanceSplits = distance.split(separator: " ") var stepDistanceText = String(stepDistanceSplits[0]) if let dist = Double(stepDistanceText) { thisStepDistance = dist } } return thisStepDistance } } #Preview { DirectionHeaderView(directionSign: "", nextStepDistance: "", instruction: "", showDirectionsList: .constant(false), height: .constant(0), locationDataManager: LocationDataManager()) }
2
0
185
2w
Xcode 16 missing the DeviceSupport for iOS17 and above
i am unable to deploy the iOS app with automation using below command: ios-deploy --bundle /Users/XXXX/Library/Developer/Xcode/DerivedData/iOSClient2-XXXXXXX/Build/Products/Debug-iphoneos/iOSClient2.app/ --id 00008020-XXXXXXXXX --justlaunch --verbose with the error: ------ Debug phase ------ Starting debug of 00008120-000C713236E0A01E (D38AP, D38AP, uknownos, unkarch, 18.1, 22B83) a.k.a. 'Svt’s iPhone' connected through USB... Device Class: iPhone build: 22B83 version: 18.1 Found Xcode developer dir /Applications/Xcode.app/Contents/Developer version: 18.0 version: 18 2024-11-08 15:26:09.531 ios-deploy[33496:644410] [ !! ] Unable to locate DeviceSupport directory with suffix 'DeveloperDiskImage.dmg'. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown! Observation: Xcode 16 missing the DeviceSupport for iOS17 and above. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/.... Xcode: Version 16.1 (16B40 iOS: iOS17 and above
0
0
126
2w
Mac Issue with Developer ID certificate and Sign in with Apple capability
Hello I have a problem with provisionprofile file. I have created Identifier with Sign in with Apple capability turned on, created Profile with Developer ID selected and now I try to export archive with generated Developer ID provision file but it says "Profile doesn't support Sign in with Apple" Also interesting thing that default provisions like macOS App Development Mac App Store Connect don't show such error when I try to export archive Maybe this problem is only related to Developer ID provision and Direct Distribution doesn't support Sign in with Apple, but I havent found proves about this idea
1
0
130
3w
On Xcode16, when using the xcodebuild command to package, the developer account will be logged out, and then the packaging will fail.
Our CI process uses XcodeBuild tools. It used to work very well. The shell code is as follows: step 1 "++++++++++++++++clean++++++++++++++++" xcodebuild clean -workspace ${WORKSPACE_NAME}.xcworkspace \ -scheme ${SCHEME_NAME} \ -configuration ${configuration} step 2 "+++++++++++++++++archive+++++++++++++++++" xcodebuild archive -workspace ${WORKSPACE_NAME}.xcworkspace \ -scheme ${SCHEME_NAME} \ -configuration ${configuration} \ -archivePath ${ARCHIVE_PATH} -allowProvisioningUpdates YES step 3 "+++++++++++++++++ipa+++++++++++++++++" xcodebuild -exportArchive \ -archivePath ${ARCHIVE_PATH} \ -exportPath "${IPA_PATH}" \ -exportOptionsPlist ${EXPORT_METHOD_PLIST_PATH} \ -allowProvisioningUpdates YES But after upgrading to xcode16, every time I execute the step3, it fails. The error log is like this ** ARCHIVE SUCCEEDED ** 2024-11-08 16:19:54.360 xcodebuild[36487:6743710] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path "/var/folders/ch/1mvd9gz11cn8zy9h254qz2600000gn/T/***.xcdistributionlogs". error: exportArchive No Accounts error: exportArchive Provisioning profile "iOS Team Store Provisioning Profile: com.***" doesn't include signing certificate "Apple Distribution: *** Co Ltd (***)". ** EXPORT FAILED ** At this time, my Apple developer account disappeared in xcode-setting-account, and it automatically logged out. If I log in again and execute the shell command, the above phenomenon will reappear. What is the cause of this, and what do I need to do to solve this problem? I look forward to your reply
2
0
290
3w
XCode 16: Multiple commands produce '{Path}Info.plist'
Hey guys, so I've read a lot of previous issues opened before opening this one, and I am doing it because none of the info found solved my problem. So, I am trying to build my app which it has a custom Info.plist file. But i keep getting the issue of multiple command when trying to build. Here is how it;s configured: Info.plist has the target membership correct Build Setting is set to 'NO' under "Generate Info.plist File" The path is correct, in the same folder as the ContentView And here is what I've already tried to fix the issue: Check in Build Phases if the wasn't a duplication: There isn't Removing the Info.plist from the "Copy Bundle Resources": When I do this, than I get another issue which is "Build input file cannot be found. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?" Switching the Build to Legacy Build System: Nothing changed Deleting the manually created Info.plist file and changing the Build Settings to 'YES' under "Generate Info.plist File": I get the same issue "Build input file cannot be found. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?" Deleted the Derived Data multiple times Deleted the Info.plist file and re-added it through File > New File Anyway, this is my last resource to find some help here in the forum. Any insight is valid P.S: XCode version 16.1
1
1
269
3w
iPhone 7 with iOS 15.8.2 never completes "Preparing for development"
PLATFORM AND VERSION iOS Development environment: Xcode 15.4, macOS 14.6.1 Run-time configuration: iOS 15.8.2 DESCRIPTION OF PROBLEM The only test phone that I have available is an iPhone 7 running iOS 15.8.2 (the latest iOS available for that device). When I connect the phone to XCode, it displays "Preparing Richard Cunningham's iPhone" indeterminately. I have tried many things including downloading new device support files, adding provisioning profiles, downgrading XCode, restarting both devices, wiping the phone, and setting the target SDK to match that of the test device. Despite all of this, XCode continues to display "Preparing ..." indeterminately. The issue can be found here on the developer forums: https://forums.developer.apple.com/forums/thread/692230 STEPS TO REPRODUCE Create a blank XCode iOS project (Multiplatform App, iOS App, it doesn't seem to make a difference) and connect the iPhone 7 (15.8.2) to the laptop. Select "Trust" on the phone to initialize the connection, and observe XCode display "Preparing iPhone" in the top bar. Cmd + Shift + 2 to open the Devices Window, and see "iPhone is busy: Preparing iPhone". Allow this to continue for some time (I have left it for over a day) and observe that there are no changes.
3
0
243
Oct ’24
Are umbrella frameworks possible/discouraged?
I want to release a Framework F, containing several other frameworks (such as Realm, Appetitive, Cocoalumberjack, PhoneNumberKit) for use by app A. According to this article: https://medium.com/@bittudavis/how-to-create-an-umbrella-framework-in-swift-ca964d0a2345 They write, without referencing a source: "Although Apple discourage creating umbrella framework". Is that true, do Apple discourage umbrella frameworks, if so why and is it a very strong discourage or a mild one? If not discouraged, then how can this be achieved with Xcode 16? I've been attempting to follow a few tutorial to achieve this, such as https://medium.com/john-lewis-software-engineering/adding-a-third-party-framework-inside-a-first-party-framework-in-xcode-3ba58cfd08da however so far without any success. This last article mentions the Link Binary With Libraries section, which doesn't exist in Xcode 16. There's the Frameworks, Libraries, and Embedded Content section where I have been attempting to add the frameworks into my Framework F (choosing Embed without Signing). I'm able to successfully build Framework F, but when app A attempts to use it (adding F to the Frameworks, Libraries, and Embedded Content section with option embed and sign, or embed and don't sign, makes no difference) then I get run time errors about the umbrellaed frameworks not being able to be found.
1
0
196
Oct ’24
Error: captureSession(_:didEndWith:error:) nearly matches defaulted requirement in RoomCaptureSessionDelegate
Hello, I’m working with the RoomPlan API to capture and export 3D room models in an iOS app. My goal is to implement the RoomCaptureSessionDelegate protocol to handle the end of a room capture session. However, I’m encountering a cautionary warning in Xcode: Warning: "captureSession(:didEndWith:error:) nearly matches defaulted requirement captureSession(:didEndWith:error:) of protocol RoomCaptureSessionDelegate." I’ve verified that my delegate method signature matches the protocol, but the warning persists. I suspect this might be due to minor discrepancies in the parameter types or naming conventions required by the protocol. Below is my full RoomScanner.swift file: import RoomPlan import SwiftUI import UIKit func exportModelToFiles() { let exportURL = FileManager.default.temporaryDirectory.appendingPathComponent("RoomModel.usdz") let documentPicker = UIDocumentPickerViewController(forExporting: [exportURL]) documentPicker.modalPresentationStyle = .formSheet if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, let rootViewController = windowScene.windows.first?.rootViewController { rootViewController.present(documentPicker, animated: true, completion: nil) } } class RoomScanner: ObservableObject { var roomCaptureSession: RoomCaptureSession? private let sessionConfig = RoomCaptureSession.Configuration() private var capturedRoom: CapturedRoom? func startSession() { roomCaptureSession = RoomCaptureSession() roomCaptureSession?.delegate = self roomCaptureSession?.run(configuration: sessionConfig) } func stopSession() { roomCaptureSession?.stop() guard let room = capturedRoom else { print("No room data available for export.") return } let exportURL = FileManager.default.temporaryDirectory.appendingPathComponent("RoomModel.usdz") do { try room.export(to: exportURL) print("3D floor plan exported to \(exportURL)") } catch { print("Error exporting room model: \(error)") } } } // MARK: - RoomCaptureSessionDelegate extension RoomScanner: RoomCaptureSessionDelegate { func captureSession(_ session: RoomCaptureSession, didUpdate room: CapturedRoom) { // Handle real-time updates if necessary } func captureSession(_ session: RoomCaptureSession, didEndWith capturedRoom: CapturedRoom, error: Error?) { if let error = error { print("Capture session ended with error: \(error.localizedDescription)") } else { self.capturedRoom = capturedRoom } } }
1
0
215
3w
Elementos no responden a un toque xcode
Desarrolle una app en xcode 16 para version minima de ios 16, todo funcionaba bien hasta la version 17 de ios, pero para ios 18 empezaron los problemas, los botones no responden a un toque, se deben sostener con un toque largo para que funcionen, ahora de un momento a otro ya no funciona para ninguna version de ios, los eventos tactiles deben ser prolongados para que se activen, en los botones o elementos que usan el tapgesture, he probado de todo versiones de xcode, versiones de swiftui, dispostivos reales, emuladores de todo y nada funciona, algun consejo o solucion gracias
0
0
131
3w
Xcode 16.x Simulators sometimes draw the screen with the wrong aspect ratio and appear distorted
Simulators sometimes draw the screen with the wrong aspect ratio and appear distorted. I'm on macOS 14.7 and using Xcode 16.1, but Xcode 16 was also sometimes doing this. This is happening in both iPhone simulator and iPad simulators. Is anyone else seeing this? It's not just the Home Screen, it happens in apps too. I have a weird bug when testing on the iPad simulators and I can't tell if it is a bug in the simulator or in my app. All my iPads are broken, so I can't actually test on device right now.
0
0
228
3w
[Bug] std::variant in containers triggers UBSan error in Xcode 16.x
I've discovered a bug in Xcode 16.0/16.1 where using std::variant in containers across compilation units triggers UBSan errors. This is a regression as it works correctly in Xcode 15.4. Here's a minimal reproduction case: [base.h] #pragma once #include <string> #include <variant> #include <forward_list> class Item { public: std::variant<std::monostate, std::string> value; }; typedef std::forward_list<Item> ItemList; class Test { public: void addItem(const Item& item); ItemList items; }; [base.cpp] #include "base.h" void Test::addItem(const Item& item) { items.push_front(item); } [main.cpp] #include "base.h" int main() { Test t; Item item; t.addItem(item); return 0; } To reproduce: Compile with UBSan enabled (-fsanitize=undefined) Occurs on both arm64 and x86_64 Occurs in both Xcode 16.0 and 16.1 Works correctly in Xcode 15.4 I've filed a Feedback Assistant report: FB15710420 Workaround: The issue can be avoided by implementing the addItem method in the header file instead of a separate compilation unit. Has anyone else encountered this issue? Are there other workarounds besides moving the implementation to the header?
4
0
115
3w
Login to azure devops account from xcode
How do I sign in to Azure devops accounts from xcode preferences. The account for Azure doesn't show up. The code is already hosted on Azure Devops and I was working on an already made project and the repo is already in the azure devops account. The previous account was obselete and now I need to login to my own account to push the changes. Whenever I am trying to push and commit the changes I get an error: remote: You are not authorized to access this collection. (-20)
1
1
973
Aug ’21
Xcode 16 won't connect to or compile to my iPhone since upgrade
I upgraded Xcode to 16, my Mac to Sequoia and my iphone and iPad to IOS 18. My developer devices are my iPhone, my iPad, my Husband's iPad and iPhone, all running IOS 18. Before upgrading Xcode to 16 I could compile onto all of these devices with no difficulty. But now, Xcode 16 recognises and compiles to all of my developer devices except my iPhone. My Mac recognises my iPhone when I plug it into a USB-C port, but Xcode does not. Xcode does not even try to pair with it or let me try to add it as a device. I have tried switching off dev mode on the phone, switching it back on again, plugging and replugging, rebooting Xcode. But Xcode will not recognise my iPhone, which is a 13 mini. Any idea what to do? I plugged my iPhone into a usb port using a vanilla Apple lightning cable and typed this into Terminal: xcrun devicectl list devices then lists the following. And for info, MCW's iPad and MCW's iPhone are in Shanghai at the moment, I am in the UK. Devices: Name Hostname Identifier State Model EasterdownDev1 00008020-00094D403C41402E.coredevice.local DE6CB0B3-399A-4B54-9ADD-E8758D8D4837 available (paired) iPad mini (5th generation) (iPad11,1) MCW's iPad 00008030-001E18E90AF0C02E.coredevice.local 3AE52B50-D69F-4827-82DA-E6968B0D5A5F unavailable iPad (9th generation) (iPad12,1) MCW's iPhone 00008101-001868D20222001E.coredevice.local 13AABF38-441B-4C4D-9FE8-440D3D9472CC unavailable iPhone 12 mini (iPhone13,1)
4
0
645
3w
Xcode 16 and iOS 18 project not compiling
I updated Xcode and MacOS recently and haven't been able to compile my Flutter app on iOS devices/simulators since then. The error keeps changing every time I run it but here's one of the output in the terminal after running flutter run: Uncategorized (Xcode): Command SwiftGeneratePch emitted errors but did not return a nonzero exit code to indicate failure Error (Xcode): no such file or directory: '/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation' Error (Xcode): stat cache file '/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator18.0-22A3362- db63dc9361471f152f572502bdbfe70a.sdkstatcache' not found Error (Xcode): unable to rename temporary '/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/3F9VRK3CXAUUD/UIKit-1KHQ7M05IF VXC-56601391.pcm.tmp' to output file '/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/3F9VRK3CXAUUD/UIKit-1KHQ7M05IF VXC.pcm': 'No such file or directory' Error (Xcode): could not build module 'UIKit' /Users/chiragbhansali/Chirag/Coding/Projects/app/test/build/ios/Debug-iphonesimulator/Flutter.framewo rk/Headers/FlutterAppDelegate.h:7:8 Error (Xcode): could not build module 'Flutter' /Users/chiragbhansali/Chirag/Coding/Projects/app/test/ios/Runner/GeneratedPluginRegistrant.h:9:8 Error (Xcode): failed to emit precompiled header '/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/Runner-eifcguceazlwumgsyzegclqdrbqt/Build/Intermed iates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_PB6A5GFLTNPC-clang_3F9VRK3CXAUUD.pch' for bridging header '/Users/chiragbhansali/Chirag/Coding/Projects/app/test/ios/Runner/Runner-Bridging-Header.h' Uncategorized (Xcode): Command PrecompileSwiftBridgingHeader emitted errors but did not return a nonzero exit code to indicate failure Uncategorized (Xcode): Command SwiftEmitModule failed with a nonzero exit code Uncategorized (Xcode): Command SwiftCompile failed with a nonzero exit code Could not build the application for the simulator. Error launching application on iPhone 16 Pro. What I have tried so far: Deleting iOS SDK and simulators Cleaning Xcode build cache using cmd+shift+k Creating a new Flutter project and trying to compile it (it failed so that reduces the chances of it being a Flutter issue) Clearing the DerivedData folder Clearing settings and cache of simulators Restarting laptop Versions: Xcode: 16.0 iOS: 18.0 MacOS: 15.1 (didn't work with 15.0 either) Flutter: 3.24
7
2
1.2k
Oct ’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
267
Sep ’24
How do simulate custom moving location
For some background, my app is a Flutter app and I have opened it in xcode to try the following, I can build and run it on a simulator from xcode as well. I want to be able to simulate custom moving locations for my app. I tried going to Debug -> Simulate Location like online tutorials show but it is all greyed out. I have location simulation enabled (I have tried changing the default location too): Within the simulator itself I only have the predefined routes or a custom static location with no option for a moving location. How can I simulate a custom moving location? If it isn't possible is there anyway to simulate the location for a Mac app as I can build the Flutter app for Mac as well?
3
0
268
Oct ’24