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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

Issue of viewing MPSGraph compiled for iOS platform
We convert a .onnx file to mpsgraphpackage for iOS deploymentPlatform with command “Mpsgraphtool convert -deploymentPlatform iOS -minimumDeploymentTarget17.0.0 model.onnx -path .” When open output.mpsgraphpackage with Xcode16, there are only “generic” and “ Apple M2(MTLDevice)” options in the “Device” selection list. Cannot find any option for iOS device. How can we view mpsgraph compiled for iOS platform? We use Xcode16 on a MacBook Pro M2 with macOS 15.
0
0
504
Oct ’24
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
318
Nov ’24
How to run Catalyst xctest bundle with xcrun
I'm trying to run an xctest bundle, built for catalyst, with xcrun. i.e. xcrun xctest path_to_my_test.xctest It fails, complaining that: The bundle "MyBundle" couldn't be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.....but incompatible platform (have 'MacCatalyst', need 'macOS') So it seems like because I'm not executing it in a sim it wants the bundle to be a macOS bundle. But I would have thought it would be possible to run a Mac Catalyst target directly on a macOS host the same as a native macOS test target. Is this not possible?
0
0
393
Nov ’24
Xcode content assist fails when booting from external drive?
I boot from an external drive. Content assist in Xcode seems to not work any more. Is that because it is blocked by the unavailability of predictive code completion? I understand that predictive code completion does not work when booting from externals, and have asked (begged?) for details so that I can migrate to booting from an internal drive: https://developer.apple.com/forums/thread/764688 But would someone (anyone?) please confirm that other forms of content assist still work in Xcode 16 when booting from an external drive? (Then I'll continue looking for why it's not working in my case.) (Separately, I'd love answers to my other posting so I can migrate to booting from the internal drive.)
0
0
219
Oct ’24
Xcode 15 - Vim Mode set clipboard=unnamed
Hi, is there any way to set the clipboard to unnamed in Vim mode? For example, if there were a .vimrc file, I would add: set clipboard=unnamed I'd like to be able to use "y" to yank / copy selected sections of code and paste them in the search bar or external applications. Thanks!
0
0
203
Nov ’24
Getting CXErrorCodeRequestTransactionErrorInvalidAction errors only on older iOS before 16.5
Need help from Apple to provide more details on what can contribute to "CXErrorCodeRequestTransactionErrorInvalidAction". For the same client build, we are seeing a spike of errors only from older OS (< 16.5) with error code 6 (.invalidAction) when requesting a transaction with CXStartCallAction. This happened after we update to XCode 16.1.
0
0
344
Oct ’24
Xcode Fails to Load Products Metadata from the StoreKit Configuration File
I'm on an Intel-based Mac running macOS Sonoma 14.7.1 (23H222) and Xcode Version 16.1 (16B40). I've created a local StoreKit Configuration File that does not synchronise with App Store Connect and selected it in the Scheme. I have some products that are consumable in-app purchase and it loads fine as expected when I run the app and I am able to make transactions. It also show up in the Transaction Manager. After a little while, working on the app, re-running it several times, it stops working. The products do not load the metadata from the StoreKit configuration file. I also get this error in the console: Error enumerating unfinished transactions for first transaction listener: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={AMSStatusCode=0, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <DF5E86B0-0E4A-4982-AF42-FC58FA858C01>.<1>, NSErrorFailingURLKey=http://localhost:51027/inApps/history?guid=F01898465023&reason=initial, _kCFStreamErrorDomainKey=10, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <DF5E86B0-0E4A-4982-AF42-FC58FA858C01>.<1>" ), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=http://localhost:51027/inApps/history?guid=F01898465023&reason=initial, NSUnderlyingError=0x60000038c150 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorDomainKey=10, _kCFStreamErrorCodeKey=-72000, _NSURLErrorNWPathKey_desc=satisfied (Path is satisfied), interface: lo0, _NSURLErrorNWResolutionReportKey_desc=Resolved 0 endpoints in 0ms using unknown from query}}, _kCFStreamErrorCodeKey=-72000} Restarting the computer resolves the issue but I don't want to restart the computer every single time when it happens and it happens quite soon after a short while. How can I make sure that it doesn't happen or if it does happen then fix the issue without restarting the computer? Relaunching Xcode doesn't help and neither does deleting Project Build Data and Indexes.
0
0
481
Nov ’24
Issue with using Swift package with xcframework binaryTarget
Hi! I'm trying to create a target application that depends on multiple targets that all use the same Swift package that has xcframework binaryTarget. Each component can be successfully assembled individually, but when I try to create a core application that depends on these components, I get an error message on Prepare build stage: Multiple commands produce '/Users/<USER>/Library/Developer/Xcode/DerivedData/<PROJECT_ID>/Build/Products/Debug/Frameworks/<FW_NAME>.framework/Versions/A' Target '<COMPONENT1>' has copy command from '/Users/<USER>/Library/Developer/Xcode/DerivedData/<PROJECT_ID>/SourcePackages/artifacts/.../<FW_NAME>/<FW_NAME>.xcframework/macos-arm64_x86_64/<FW_NAME>.framework' to '/Users/<USER>/Library/Developer/Xcode/DerivedData/<PROJECT_ID>/Build/Products/Debug/Frameworks/<FW_NAME>.framework' Target '<COMPONENT2>' has copy command from '/Users/<USER>/Library/Developer/Xcode/DerivedData/<PROJECT_ID>/SourcePackages/artifacts/.../<FW_NAME>/<FW_NAME>.xcframework/macos-arm64_x86_64/<FW_NAME>.framework' to '/Users/<USER>/Library/Developer/Xcode/DerivedData/<PROJECT_ID>/Build/Products/Debug/Frameworks/<FW_NAME>.framework' – where <FW_NAME> is a name of the xcframework which is the binaryTarget in the Swift package. Could someone please explain to me if it is even possible to use xcframeworks packaged in Swift packages in such cases, and if so, how to do it correctly?
0
0
367
Nov ’24
Downloading Xcode 16.0 related runtimes on CI
I'm trying to get our CI working to build our own machine image AMI descriptions. Part of that is to download the correct runtime versions so that we can pre-create the simulators we use for testing on these machine image descriptions. When running the code like xcodebuild -downloadPlatform <platform> -exportPath "$<temp_folder_path>" Locally I get a result and download a runtime, but on CI I just get All available platforms are downloaded. Why is this message happening and how can I specify specific platforms to download over CI to configure our machine setup?
0
0
305
Oct ’24
Undefined symbol: _OBJC_CLASS_$_ADClient
(void)asaAttribution { if (@available(iOS 14.5, *)) { [self asaAttributionToken]; NSLog(@"adServicesToken1:%@",[ConfigModelTool singleton].asaToken); [self attributionWithToken:[ConfigModelTool singleton].asaToken]; }else { if ([[ADClient sharedClient] respondsToSelector:@selector(requestAttributionDetailsWithBlock:)]) { [[ADClient sharedClient] requestAttributionDetailsWithBlock:^(NSDictionary<NSString *,NSObject *> * _Nullable attributionDetails, NSError * _Nullable error) { if (!error) { [self handleAsaData:attributionDetails]; }else { [StatisticsTool buriedPoint:4649 withOther:@{@"s0":[NSString checkNullString:[NSString stringWithFormat:@"%d",(int)error.code]]}]; } }]; } } } I upgraded the code that was compiled correctly before the official version of Xcode16, but now this error occurs. I deleted the relevant code and still compile the error. My writing style is recommended by the installation official. Can someone help me see what the reason is? Save me, save me!
0
0
962
Oct ’24
Can't get Account information with XCode 16.1
I’m trying to add my account to Xcode 16.1, which is running on a virtual machine with macOS Sequoia 15.1. I was able to successfully sign in to my account on the virtual machine itself. I’m using a Mac Mini M2, but when I attempt to add my account in Xcode, I encounter the following 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."
0
3
446
Nov ’24
Seeking advice on building a multiplatform PDF viewer app
Hi everyone, I’m planning to develop a cross-platform PDF viewer app for iOS and macOS that will read PDFs from local storage and cloud services (Google Drive, iCloud, WorkDrive, etc.). The app should be read-only and display both the PDF content and its metadata (author, title, creation date, etc.). Key Features: View PDFs: Local and remote (cloud storage integration). Display metadata: Title, author, page count, etc. Cloud integration: Google Drive, iCloud, Zoho WorkDrive, etc. Read-only mode: No editing features, just viewing. Questions: Xcode Template: Should I use the Document App or Generic App template for this? PDF Metadata: Any built-in libraries for extracting PDF metadata in a read-only app? Performance: Any advice or documentation on handling large PDFs or cloud fetching efficiently? Thanks in advance for any advice or resources!
0
0
282
Nov ’24
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
100
Nov ’24
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.4k
Nov ’24
Missing required modules when enabling Swift 6
Hi team, We're using CocoaPods in our project and we noticed the compiler fails to build certain targets saying it's "Missing required module 'x'" when trying to build them in Swift 6: We realized the modules the compiler is complaining about are pod dependencies required by the other target dependencies, and that this error will only appear when building with Swift 6 unless such dependencies are described on the Podfile as direct dependencies of the target, or we include them in the framework search paths. For example, the error in the image above will show if module 'X' import 'Y' and 'Y' imports 'CocoaLumberJack' and we don't specify a direct dependency between 'X' and 'CocoaLumberJack'. Regardless of the fact that we can manually add the missing module location to the target search paths, we'd like to understand why we're facing this issue in the first place, what changed between Swift 5 and Swift 6 that's requiring us now to explicitly describe these dependencies. I'd appreciate if someone could tell us more about this. We're particularly interested on knowing if this is an intentional change and how to handle it properly. Thanks
0
4
431
Nov ’24