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

Xcode Documentation

Post

Replies

Boosts

Views

Activity

Testing Right-to-Left localization in a macOS app
I’m currently trying to localize one of my Mac apps for Right-to-Left languages. In Xcode, to test this, I set the language to ‘Arabic’ in the scheme, which then displays the language and mirrors the layout accordingly. I have two questions about this: macOS titlebar buttons: In the title bar at the top, shouldn’t the Close and Minimize buttons also be on the right side (mirrored)? How can I test this? Numerals: My UI still displays Latin numerals (123). I know this is correct in some Arabic-speaking regions, but I’d also like to test cases where Arabic-Indic numerals (١٢٣) are used. Is there a way to configure the scheme to test this?
2
0
113
3d
Issue during loading account information on virtual machine
I'm not able to see my account information on the Mac Mini machine with M2 CPU. I log in to my account in Settings, but in Xcode 16.1 it fails with the Decoding Error There was a failure decoding response I think this is the same as here: https://developer.apple.com/forums/thread/767673 https://developer.apple.com/forums/thread/769069 https://developer.apple.com/forums/thread/759877
0
0
37
3d
No screenshot files in XCResult files using Xcode 16.1
Hello, I am using Xcode 16.1 (16B40) on MacOS Sequoia 15.1.0 using a Macbook pro M1 Max I am developing an app for iOS 17 and 18 using SwiftUI I created UITests to take the screenshots for the appStore on the simulator The tests run well and all of them are succeded The problem appears when I try to get the screenshot files from the xcresult files after the test. There is not any screenshot inside it. I found a data folder and a Info.plist file. In the data folder there are a lot of files with this pattern data.03zD4C6IGFFthK14NwA8mNvcwFHT16g6Tl40Tl1YmBC1bNh6d0YIcnWKyUaQPDXoa8fYo6C3Xcv8xvMtE3_NEXA== and other files with this pattern refs.03zD4C6IGFFthK14NwA8mNvcwFHT16g6Tl40Tl1YmBC1bNh6d0YIcnWKyUaQPDXoa8fYo6C3Xcv8xvMtE3_NEXA== Ok, I tryed to use fastlane to automatize the screenshots but the problem is still present. The xcresult files have not any png file. I had no problems doing this action (getting screenshots from a xcresult file) in previous versions of MacOS and Xcode in my current machine. I just updated my machine to MacOS Sequoia 15.1.1 and the problem is still present Honestly I don't know how to fix this situation. With Xcode 15 I had not any problem with that but I am not sure if Xcode 16.0 was runing without problems because I didn't need to use this functionality in those months Here is my code for a UITest: import XCTest final class ScreenshotsUITests: XCTestCase { let app = XCUIApplication() let device = "iPhone16" override func setUpWithError() throws { continueAfterFailure = true } override func tearDownWithError() throws {} @MainActor func testEnglishScreens() throws { let lang = "en" app.launchArguments.append("UITestMode") app.launchArguments += ["-AppleLanguages", "(en)"] app.launchArguments += ["-AppleLocale", "en_US"] app.launch() executeTestsForMenus(lang: lang, backLabel: "Back") executeTestForMatch(lang: lang) } @MainActor func testSpanishScreens() throws { let lang = "es" app.launchArguments.append("UITestMode") app.launchArguments += ["-AppleLanguages", "(es)"] app.launchArguments += ["-AppleLocale", "es_ES"] app.launch() executeTestsForMenus(lang: lang, backLabel: "Atrás") executeTestForMatch(lang: lang) } private func executeTestForMatch(lang: String) { let startButton = app.buttons["start-button"] startButton.tap() let key4 = app.buttons["key-4"] XCTAssertTrue(key4.waitForExistence(timeout: 30), "Key 4 in match screen is not found") key4.tap() let key2 = app.buttons["key-2"] XCTAssertTrue(key2.exists, "Key 2 in match screen is not found") key2.tap() makeScreenShot("playing", lang: lang) let closeButton = app.buttons["close-button"] XCTAssertTrue(closeButton.exists, "Close button in match screen is not found") closeButton.tap() } private func executeTestsForMenus(lang: String, backLabel: String) { let mainHeader = app.staticTexts["Math match"] XCTAssertTrue(mainHeader.exists, "Header in main screen is not found") makeScreenShot("mainMenu", lang: lang) let settingsButton = app.buttons["settings-button"] XCTAssertTrue(settingsButton.exists, "Settings button in main screen is not found") settingsButton.tap() makeScreenShot("Settings", lang: lang) let backButton = app.buttons[backLabel] XCTAssertTrue(backButton.exists, "Back button in match screen is not found") backButton.tap() let helpButton = app.buttons["help-button"] XCTAssertTrue(helpButton.exists, "Help button in main screen is not found") helpButton.tap() makeScreenShot("Help", lang: lang) backButton.tap() let scoreButton = app.buttons["score-button"] XCTAssertTrue(scoreButton.exists, "Scores button in main screen is not found") scoreButton.tap() makeScreenShot("Scores", lang: lang) backButton.tap() let playButton = app.buttons["play-button"] XCTAssertTrue(playButton.exists, "Play button in main screen is not found") playButton.tap() makeScreenShot("matchBuilder", lang: lang) let startButton = app.buttons["start-button"] XCTAssertTrue(startButton.exists, "Start button in match builder screen is not found") } private func makeScreenShot(_ name: String, lang: String) { takeScreenshot(app, named: "\(lang)-\(name)-\(device)") } } import XCTest extension XCTestCase { func takeScreenshot(_ app: XCUIApplication, named name: String, fullScreen: Bool = false) { let screenshot: XCUIScreenshot if fullScreen { screenshot = app.windows.firstMatch.screenshot() } else { screenshot = XCUIScreen.main.screenshot() } let screenshotAttachment = XCTAttachment( uniformTypeIdentifier: "public.png", name: "screenshot-\(name).png", payload: screenshot.pngRepresentation, userInfo: nil) screenshotAttachment.lifetime = .keepAlways add(screenshotAttachment) } } and here is the content of my testplan file: { "configurations" : [ { "id" : "35BC7C0B-9A5A-4027-9F30-36958C4C1AAF", "name" : "Test Scheme Action", "options" : { "preferredScreenCaptureFormat" : "screenshot", "testExecutionOrdering" : "random", "uiTestingScreenshotsLifetime" : "keepAlways", "userAttachmentLifetime" : "keepAlways" } } ], "defaultOptions" : { "targetForVariableExpansion" : { "containerPath" : "container:myAppProject.xcodeproj", "identifier" : "B27D1B022CA00314001A259B", "name" : "MyAppProject" } }, "testTargets" : [ { "parallelizable" : true, "target" : { "containerPath" : "container:MyAppProject.xcodeproj", "identifier" : "B27D1B122CA00315001A259B", "name" : "MyAppProjectTests" } }, { "parallelizable" : true, "target" : { "containerPath" : "container:MyAppProject.xcodeproj", "identifier" : "B27D1B1C2CA00315001A259B", "name" : "MyAppProjectUITests" } } ], "version" : 1 } I made tests with old projects in my machine and those projects have the same problem with screenshot files in the xcresult bundles I don't know if the problem is in my machine, my Xcode, MacOS or other ting. I don't know how to fix this problem Please, can anyone help me? Thanks in advance
1
0
68
3d
New linker in Command Line Tools 16 not working with BLOCK DATA
We've encountered a critical issue with the new linker of CLT16 (version 16.1.0.0.1.1729049160) that prevents proper initialization of BLOCK DATA. BLOCK DATA are used to initialize global variables in our Fortran code, and its failure to initialize those variables leads to a program crash. This affects our community of more that thousand scientists worldwide. The current workaround is using the -ld_classic linker option. However, this option is deprecated and will be removed in a future release, as described in the Xcode release note. I've attached a minimal example that reproduces the problem using GNU gfortran with the following instructions (the attached main.f.txt and bd.f.txt need to be rename to main.f and bd.f, respectively): gfortran -c bd.f gfortran -c main.f ar rv libtest.a bd.o main.o gfortran -ld_classic -o good.x -L. libtest.a gfortran -o bad.x -L. libtest.a Running the two programs, one can see that the BLOCK DATA are not initialised without the option ld_classic, $ > ./good.x 3.7273802569289098 2.8083922366048202 $ > ./bad.x 0.0000000000000000 0.0000000000000000 We kindly request your attention to this matter and a prompt solution or alternative workaround. Best regards main.f.txt bd.f.txt part.txt
0
0
112
4d
Xcode / xcodebuild The operation couldn’t be completed. Unable to log in with account '<APPLE-ID>'. The login details for account '<APPLE-ID>' were rejected.
Despite the recommendation of DTS Engineers at [https://forums.developer.apple.com/forums/thread/766500, Xcode 16.1 ](https://forums.developer.apple.com/forums/thread/766500, Xcode 16.1 ) the same behavior when automatically signing in our CI/CD environment: The operation couldn’t be completed. Unable to log in with account '<APPLE-ID>'. The login details for account '<APPLE-ID>' were rejected. error: No profiles for '<BUNDLE-ID>' were found: Xcode couldn't find any iOS App Development provisioning profiles matching '<BUNDLE-ID>' ** ARCHIVE FAILED ** In addition, we see several orphaned Xcode username entries in the local keychain / Keychain Access app that match the identifier stored in com.apple.dt.Xcode.plist under the key DVTDeveloperAccountManagerAppleIDLists - IDE.Identifiers.Prod. (Preferences read com.apple.dt.Xcode DVTDeveloperAccountManagerAppleIDLists) or we see that the DeveloperID stored in Xcode - Settings - Accounts is lost. We have reset a Mac mini (2023 / arm) to factory settings, reinstalled Sequoia in the current version and installed Xcode 16.1 (16B40). Nevertheless, we see the behavior described above. This behavior is not reproducible for us. We have opened the following tickets, but have not received a response that explains the behavior or offers a solution. Case ID: 9935876 Feedback: FB15700530
1
4
135
4d
Mac mini M2 + Xcode 16.1 can't load the Account information in VM
I’m using a Mac Mini M2 with macOS Sequoia 15.1 and running a virtual machine with the same OS. While logging into my account works in System Settings, adding it to Xcode 16.1 fails after the initial login with a decoding error: Decoding Error There was a failure decoding response: (HTTP 401, 60 bytes). There are similar issues in https://developer.apple.com/forums/thread/767673 and https://developer.apple.com/forums/thread/759877
1
1
39
4d
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
0
110
5d
How to localize permission description string?
What's the problem? My app requests location access and for that I need to provide a description for the user to read so that it is clear why we need this permission. I'm using the latest solution suggested by XCode for my app localization which is using Localizable.xcstrings file. But for the permission description, I'm adding the text to Targets -> Info -> Custom iOS Target Properties -> "Privacy - Location Always and When In Use Usage Description". I understand that the default language is English in this list so I provided it, but now I want this description to be translated to other languages so that my users can read it in their preferred language. What I have tried so far? I tried adding translation to the keys "INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription" and "NSLocationAlwaysAndWhenInUseUsageDescription" in my "Localizable.xcstrings" but it is always showing the description in English
2
0
102
5d
Debug Memory Graph does not show memory leaks.
Here is a modified code from the documentation example https://www.swift.org/documentation/server/guides/memory-leaks-and-usage.html#troubleshooting : class ViewController: UIViewController { var closure: () -> Void = { () } public func doNothing() {} public func doSomethingThatLeaks() { self.closure = { // This will leak as it'll create a permanent reference cycle: // // self -> self.closure -> self self.doNothing() } } override func viewDidLoad() { super.viewDidLoad() // Memory leak example: doSomethingThatLeaks() // Abandoned memory example: // NotificationCenter.default.addObserver(forName: .init("Abandoned"), object: nil, queue: nil) { _ in // print("\(self)") // } } deinit { print(#function, Self.self) } } If you place it, for example, in a navigation controller, do a push-pop several times, deinit will not be printed. But if you look in the Debug Memory Graph, it will not even show that there is a strong reference to this controller: Only if you manually select: You can see that it is held by the closure context, which it holds: This is definitely not abandoned memory (like the commented piece of the code example), but it is not shown either in the Debug Memory Graph or in Instruments Leaks. Why?
0
0
84
5d
Hi, I have an issue with app preview
I can't seem to access preview for any of my views in any of my swift projects at all (using Mac to code and using iPhone 16 pro as preview and simulation, simulation can work), even after restarting Mac and Xcode itself. The preview section has a popup saying "Cannot preview in this file, unexpected error occured" (for every file), please tell me what is wrong and help me solve it to see the preview, thank you! details
1
0
129
5d
Un-Wanted Edit Menu Items
Xcode is adding un-wanted menu items to the Edit menu in a Mac Application. There is an automatically generated separator bar and an AutoFill menu item with two sub-menu items. Looking at the source code I see that two other items were suppressed in the initialize method of the AppController like this: NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary]; //Get rid of Special characters menu item in edit menu: [defaultValues setObject: [NSNumber numberWithBool: YES] forKey: @"NSDisabledCharacterPaletteMenuItem"]; //Get rid of Start Dictation... menu item in edit menu: [defaultValues setObject: [NSNumber numberWithBool: YES] forKey: @"NSDisabledDictationMenuItem"]; [[NSUserDefaults standardUserDefaults] registerDefaults: defaultValues]; I guessed that there would also be a key like this: @"NSDisabledAutoFillMenuItem" but adding this to the code does nothing so apparently not. I searched programming forums and posters say that you can fix this by changing the name of the Edit menu to something like (space)Edit but this doesn't work. I searcher the Developer documentation and the Archives extensively for info about these keys but of course found nothing. Control-clicking on these pops up a menu of ways to search for these but none of them find anything. Control, option and command clicking on these keys results in ”?”. I can probably get a pointer to the menu and use NSMenu’s methods to delete these but something like the above would be better. Is there any documentation about this anywhere?
1
0
102
6d
XCUITest Screen Recording
In WWDC23: Fix failures faster with Xcode test reports, the presenter showed off an Xcode feature called Automation Explorer, that allows playback of a screen recording corresponding to an XCUITest. For the life of me, I have not been able to find out how to enable/use this feature in Xcode 16. I am using Test Plans and have set the UI Testing configuration settings for Automatic Screen Capture to On, and keep all and Preferred Capture Format to Video, but am not seeing any screen recordings being produced after running the tests. Am I doing something wrong?
1
0
140
1w
App alternative icon not working when archieve.
I add the following info in the build settings of my app. Then I also add the icon to my asset. I build the app, it works normally, but I notice that when I changed the icon to 'AppIcon-Defaults', The icon change alert didn't appear. but it succeeds . I uploaded the archive to App Store I got: ITMS-90895: Missing Icon - The Info.plist key CFBundleIcons.CFBundleAlternateIcons contains an entry “AppIcon-Defaults” that references asset “AppIcon-Defaults.” No such asset is present in the asset catalog. Then I use xcrun --sdk iphoneos assetutil --info Assets.car to check the assets inside the archieved app, It have the asset.
1
0
115
1w
Persistent Xcode validation errors
We recently updated the codebase of our existing iOS application to improve compatibility with the latest versions of iOS. For several months, our attempts to deploy the updated application to TestFlight for testing and validation have consistently failed due to four recurring Xcode validation errors. Please see the attached document "X-Code Validation Errors.txt" for details on these errors. <see: XCode Validation Errors (forum).txt> Our application is developed using Visual Studio 2022 for PC with the .NET MAUI framework, as Microsoft no longer supports Visual Studio for Mac. After a successful build and testing using a virtual iPhone interface, Visual Studio connects remotely to the MacBook (Mac OS 15.1) sending the necessary project files that automatically triggers the Xcode (16.1) validation to begin. We have made numerous edits to both the plist.info and the project file in an attempt to resolve the validation errors with little to no success. We are confident that is a configuration mismatch between what the plist says and the structure of the project itself. We are hoping that someone here in the developer group has some answers for us. Our team is relatively new iOS development and have spent hours trying to resolve this issue. What are we doing wrong and what specifically do we need to change to correct these errors so that we can finally get this project into TestFlight? I have attached copies of our plist.info, project structure, and error messages. Please help XCode Validation Errors (forum).txt Info.plist
2
0
118
1w
ERROR: "Failed to build the scheme (APP NAME)"
Hello, I'm kinda new to Xcode and I was trying to get back to programming while I follow a course. There seemed to be a problem with the preview and it looks like there was nothing wrong with the code, at least from what I know. I can say this because the code is the default one that Xcode gives you when you start a new project. here is the error log. == PREVIEW UPDATE ERROR: SchemeBuildError: Failed to build the scheme “App” linker command failed with exit code 1 (use -v to see invocation) Link App.debug.dylib (arm64): Undefined symbols for architecture arm64: "_main", referenced from: ___debug_main_executable_dylib_entry_point in command-line-aliases-file ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) == PREVIEW UPDATE ERROR: SchemeBuildError: Failed to build the scheme “App” linker command failed with exit code 1 (use -v to see invocation) Link App.debug.dylib (arm64): Undefined symbols for architecture arm64: "_main", referenced from: ___debug_main_executable_dylib_entry_point in command-line-aliases-file ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
1
0
129
1w
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
99
1w