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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

watchOS-Questions about HealthKit privileges
The WatchOS developer is not allowed to obtain healthKit permission status. The result is always unauthorized (either by clicking the dot/cross in the upper left corner or by turning on all Health, on some, off all). WatchOS 开发获取 healthKit 的权限状态authorizationStatus不准。结果始终都是未授权(无论是点击左上角的点叉号还是开启全部健康项开关,开启部分,关闭所有),怎么处理?
0
0
58
Apr ’25
Cannot assign build target to usdz file
I’m working in the app playground and want to add my usdz file but when i drag drop the file to my main folder i cannot add target to it which leads to a resource not found error while I build my app. It was working on a normal xcode project but while transitioning to app playground it is not working. How can I fix this issue?
0
0
387
Jan ’25
SceneKit Performance Issues with Large Node Counts on iPad (10th Gen, iPadOS 18.3)
We’re developing an iPad application that visualizes 2D and 3D building floor plans, including a mesh network of nodes that control lighting and climate. The node count ranges from 1,000 to 15,000. We’re using SceneKit to dynamically render the floor plan and node mesh on an iPad 10th generation running iPadOS 18.3. While the core visualization works, we are experiencing significant performance degradation as the node count increases. Specifically: At 750–1,000 nodes, UI responsiveness noticeably declines. At 2,000 nodes, navigating the floor plan becomes nearly unusable. We attempted to optimize performance with a Geometric Pool algorithm, but the impact was minimal. Strangely, the same iPad handles 30,000+ 3D objects effortlessly when using Unity or Unreal Engine, raising the question of whether SceneKit may not be optimized for this scale. Our questions: Is SceneKit suitable for visualizing such large node counts, or are we hitting an inherent limitation of the framework? Are there best practices or optimization techniques for SceneKit that we might be missing? Should we consider a hybrid approach or fully transition to a different 3D engine for this use case? We’ve attached a code sample below demonstrating the issue. Any insights, suggestions, or experiences would be greatly appreciated! ContentView.swift
0
1
354
Feb ’25
Xcconfig variables doesn't get loaded automatically in project settings
Hi, I am using xcode build that receive it's configuration using xcconfig files, those add some new definitions to the project, like the location of openssl library. If xcode environment variable include prefix that matches one of the fields in the project settings, it is automatically referred to as if you added it to that field. for example : the var HEADER_SEARCH_PATHS_openssl_libopenssl has value (openssl headers' path) that should be automatically added to the field Headers Search Paths under project settings. For some reason it stopped working for me and i'm not sure why (i've tried to release the xcconfig files). any idea why ? Thanks !
0
1
342
Jan ’25
{Project}-LinkMap-normal-arm64.txt changed?
I upgraded xcode to 16.2 and found that the txt file generated by Write Link Map File is different from before, no longer containing detailed data. So, how to set it up to obtain the same link map file as the previous xcode version. # Path: /Users/....../xxx.app/__preview.dylib # Arch: arm64 # Object files: [ 0] linker synthesized # Sections: # Address Size Segment Section 0x00004000 0x00000000 __TEXT __text # Symbols: # Address Size File Name
0
0
82
Mar ’25
SchemeBuildError: Failed to build the scheme
I have an iOS app, and I am trying to add a companion WatchOS app. My iOS app depends on 2 libraries: GoogleMobileAds FirebaseAnalyticsWithoutAdIdSupport When I add a new target for WatchOS, the preview build starts to fail. I am not adding any libraries to WatchOS. The Google Ads and Firebase Analytics libs are only under the iOS target. I am unable to run the preview, I get an error when trying to build the watch scheme. The preview does not work. The build just crashes. I've included the error log below. But, here are the steps I've tried so far: Delete folders inside Derived Data Run a clean build (Cmd + Option + Shift + K) Delete scheme and create a new one Reset Package Cache Restart Xcode Restart Macbook But, it just does not work. I do not understand why the watchOS target is erroring for "GoogleUserMessagingPlatform" and "GoogleMobileAdsTarget" when those packages are not linked/used for the watchOS. SchemeBuildError: Failed to build the scheme “timerWatch Watch App” While building for watchOS Simulator, no library for this platform was found in '/Users/k/Library/Developer/Xcode/DerivedData/timer-dhkdhvfcqtfgskfdxpmupujswtuh/SourcePackages/artifacts/swift-package-manager-google-user-messaging-platform/UserMessagingPlatform/UserMessagingPlatform.xcframework'. (in target 'UserMessagingPlatformTarget' from project 'GoogleUserMessagingPlatform') Build target UserMessagingPlatformTarget: /Users/k/Library/Developer/Xcode/DerivedData/timer-dhkdhvfcqtfgskfdxpmupujswtuh/SourcePackages/artifacts/swift-package-manager-google-user-messaging-platform/UserMessagingPlatform/UserMessagingPlatform.xcframework:1:1: error: While building for watchOS Simulator, no library for this platform was found in '/Users/k/Library/Developer/Xcode/DerivedData/timer-dhkdhvfcqtfgskfdxpmupujswtuh/SourcePackages/artifacts/swift-package-manager-google-user-messaging-platform/UserMessagingPlatform/UserMessagingPlatform.xcframework'. (in target 'UserMessagingPlatformTarget' from project 'GoogleUserMessagingPlatform') Build target GoogleMobileAdsTarget: /Users/k/Library/Developer/Xcode/DerivedData/timer-dhkdhvfcqtfgskfdxpmupujswtuh/SourcePackages/artifacts/swift-package-manager-google-mobile-ads/GoogleMobileAds/GoogleMobileAds.xcframework:1:1: error: While building for watchOS Simulator, no library for this platform was found in '/Users/k/Library/Developer/Xcode/DerivedData/timer-dhkdhvfcqtfgskfdxpmupujswtuh/SourcePackages/artifacts/swift-package-manager-google-mobile-ads/GoogleMobileAds/GoogleMobileAds.xcframework'. (in target 'GoogleMobileAdsTarget' from project 'GoogleMobileAds')
0
0
86
Apr ’25
Preview broken
Hello, I am doing the SwiftUI tutorial with Xcode 16.2 For the watch app the simulator working fine but the preview keep saying “This app cannot run on the selected target device.” while the preview is working …… For the macOS part the simulator working fine but the preview is totally broken with -> ”ContentView.swift” not found in any targets. While it is correctly added to the target … Please fix or make tutorial clear.
0
0
150
Feb ’25
Swift Package Manager - Package Download Issue
We have developed a custom iOS framework called PaySDK. Earlier we distributed the framework as PaySDK.xcframework.zip through GitHub (Private repo) with two dependent xcframeworks. Now, one of the clients asking to distribute the framework through Swift Package Manager. I have created a new Private repo in the GitHub, created the new release (iOSSDK_SPM_Test) tag 1.0.0. Uploaded the below frameworks as Assets and updated the downloadable path in the Package.Swift and pushed to the GitHub Main branch. PaySDK.xcframework.zip PaySDKDependentOne.xcframework.zip PaySDKDependentTwo.xcframework.zip When I try to integrate (testing) the (https://github.com/YuvaRepo/iOSSDK_SPM_Test) in Xcode, am not able to download the frameworks, the downloadable path is pointing to some old path (may be cache - https://github.com/YuvaRepo/iOSSDK_SPM/releases/download/1.2.0/PaySDK.xcframework.zip). Package.Swift: // swift-tools-version:5.3 import PackageDescription let package = Package( name: "iOSSDK_SPM_Test", platforms: [ .iOS(.v13) ], products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( name: "iOSSDK_SPM_Test", targets: ["PaySDK", "PaySDKDependentOne", "PaySDKDependentTwo"] ) ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .binaryTarget( name: "PaySDK", url: "https://github.com/YuvaRepo/iOSSDK_SPM_Test/releases/download/1.0.0/PaySDK.xcframework.zip", checksum: " checksum " ), .binaryTarget( name: "PaySDKDependentOne", url: "https://github.com/YuvaRepo/iOSSDK_SPM_Test/releases/download/1.0.0/PaySDKDependentOne.xcframework.zip", checksum: " checksum " ), .binaryTarget( name: "PaySDKDependentTwo", url: "https://github.com/YuvaRepo/iOSSDK_SPM_Test/releases/download/1.0.0/PaySDKDependentTwo.xcframework.zip", checksum: " checksum " ), .testTarget( name: "iOSSDK_SPM_TestTests", dependencies: ["PaySDK", "PaySDKDependentOne", "PaySDKDependentTwo"] ) ] ) Steps I followed: I have tried below steps, Removed the local repo and cloned new rm -rf ~/Library/Caches/org.swift.swiftpm/ rm -rf ~/Library/Developer/Xcode/DerivedData/* Can anyone help to identify the issue and resolve? Thanks in advance.
0
0
426
Jan ’25
XCode 16 run Fastlane fail when called get_version_number function after convert project from groups to folders
My project is using Fastlane 2.226.0. After converted groups to folders on XCode 16, I got an error when executed below function in Fastfile: get_version_number(xcodeproj: "MyProject.xcodeproj", target: "MyProject") Below is the error message output after I ran fastlane: Unable to find XCode build setting: MARKETING_VERSION
0
0
99
Mar ’25
Classic Linker error after renaming project
We are renaming the project and a Static Library the is critical to the operation on the app is not found during compiling. We have the same project working fine. We have reviewed the project.pbxproj file and searched for erroneous linking, reviewed the Target settings and there is nothing obviously wrong. (Copied and secured the original) Typically workflow is: Clean Delete Derived Data dir D/l Swift Packages Build/Run The team has many years using Xcode / Swift and the project and this is not clear how to resolve. We have scoured SO and the solutions do not apply. Facts: -No cocoapods -Search Paths all set Linker all set Thoughts?
0
0
138
Mar ’25
Rare EXC_BAD_ACCESS (SIGBUS) KERN_PROTECTION_FAILURE crash when running function?
The following function could run several hundred times with no problem but will occasionally cause a EXC_BAD_ACCESS (SIGBUS). The last time it was a KERN_PROTECTION_FAILURE perhaps meaning it is trying to write to a read only memory but previously it was KERN_INVALID_ADDRESS. I have tried debugging tools to no avail. Can anyone see any reason why the following function could be causing this. Just in case the function is a red herring the only other thing that was running is a AVQueuePlayer that contains 11 tracks, but the crash happens mid song making it unlikely. The function includes running other functions so below is all related functions that happen as a result of a swipe gesture. func completeLeft() { let add1 = Int(tiles[Square - (squares2move + 2)].name ?? "0") ?? 0 let add2 = Int(currentNode.name ?? "0") ?? 0 let add = add1 + add2 if add.isMultiple(of: 9) == false { if squares2move == 0 { self.moveinprogress = 0 return } moveLeft1() } if add.isMultiple(of: 9) { squares2move += 1 moveLeft2() } func moveLeft1() { var duration = TimeInterval(0.1) duration = Double(squares2move) * duration self.soundEffect = "swipe" self.playEffects(Volume: self.effectsVolume) let move = SKAction.move(to: positions[Square - (squares2move + 1)], duration: duration) currentNode.run(move, completion: { self.tiles[Square - (squares2move + 1)].name = self.currentNode.name self.tiles[Square - 1].name = "" self.currentNode.position = self.positions[Square - (squares2move + 1)] self.newNumber() }) } func moveLeft2() { var duration = TimeInterval(0.1) duration = Double(squares2move) * duration self.soundEffect = "swipe" self.playEffects(Volume: self.effectsVolume) let move = SKAction.move(to: positions[Square - (squares2move + 1)], duration: duration) currentNode.zPosition = currentNode.zPosition - 1 currentNode.run(move, completion: { self.currentNode.position = self.positions[Square - (squares2move + 1)] self.tiles[Square - 1].name = "" self.currentNode.name = "\(add)" self.tiles[Square - (squares2move + 1)].name = "\(add)" if add > self.score { self.score = add } if add > self.currentgoal { self.levelComplete()} else { self.playEffects2(soundEffect: "Tink", Volume: self.effectsVolume, Type: "caf")} if self.currentNode.childNode(withName: "Label") == nil { self.currentNode.texture = SKTexture(imageNamed: "0.png") let Label = SKLabelNode(fontNamed: "CHALKBOARDSE-BOLD") Label.text = "\(add)" Label.name = "Label" let numberofdigits = Label.text!.count if numberofdigits == 1 { Label.fontSize = 45 * self.hR} if numberofdigits == 2 { Label.fontSize = 40 * self.hR} if numberofdigits == 3 { Label.fontSize = 32 * self.hR} if numberofdigits == 4 { Label.fontSize = 25 * self.hR} Label.horizontalAlignmentMode = .center Label.verticalAlignmentMode = .center Label.fontColor = .systemBlue Label.zPosition = 2 self.currentNode.addChild(Label) self.currentNode.zPosition = self.currentNode.zPosition + 1 var nodes = self.nodes(at: self.positions[Square - (squares2move + 1)]) nodes = nodes.filter { $0.name != "Tile" } nodes = nodes.filter { $0 != self.currentNode } nodes = nodes.filter { $0 != self.currentNode.childNode(withName: "Label") } for v in nodes { v.removeFromParent()} } else { let Lbl = self.currentNode.childNode(withName: "Label") as? SKLabelNode Lbl!.text = "\(add)" let numberofdigits = Lbl!.text!.count if numberofdigits == 1 { Lbl!.fontSize = 45 * self.hR} if numberofdigits == 2 { Lbl!.fontSize = 40 * self.hR} if numberofdigits == 3 { Lbl!.fontSize = 32 * self.hR} if numberofdigits == 4 { Lbl!.fontSize = 25 * self.hR} self.currentNode.zPosition = self.currentNode.zPosition + 1 var nodes = self.nodes(at: self.positions[Square - (squares2move + 1)]) nodes = nodes.filter { $0.name != "Tile" } nodes = nodes.filter { $0 != self.currentNode } nodes = nodes.filter { $0 != self.currentNode.childNode(withName: "Label") } for v in nodes { v.removeFromParent()} } self.moveinprogress = 0 }) } } func moveLeft() { var duration = TimeInterval(0.1) duration = Double(squares2move) * duration self.soundEffect = "swipe" self.playEffects(Volume: self.effectsVolume) let move = SKAction.move(to: positions[Square - (squares2move + 1)], duration: duration) currentNode.run(move, completion: { self.tiles[Square - (squares2move + 1)].name = self.currentNode.name self.tiles[Square - 1].name = "" self.currentNode.position = self.positions[Square - (squares2move + 1)] self.newNumber() }) }
0
0
209
Mar ’25
Shared dependencies between test and production code creates library duplication
When test support code relies on production code, a diamond can occur. If this occurs across packages, it can lead to duplicated symbols and incorrect behavior at runtime despite no warnings at build time. This only occurs in Xcode and top-level application testing. This doesn't occur when the code being tested is in a separate package. I'm trying to understand how to correctly manage shared test support code which needs to access production code, or if this is the correct way and it is an Xcode bug. For a minimized example project, see https://github.com/rnapier/SupportCode. The setup includes three packages: Dependencies, which manages all the dependencies for the app and tests; Core which contains core logic and test support; and Feature, which relies on Core an contains feature-related logic and test support. Building this system causes Core.framework to show up three times in DerivedData: ./App.app/PlugIns/AppTests.xctest/Frameworks/Core_59974D35D_PackageProduct.framework ./App.app/Frameworks/Core_59974D35D_PackageProduct.framework ./PackageFrameworks/Core_59974D35D_PackageProduct.framework When unit tests are run, there is a collision on the symbol for Keychain: objc[48914]: Class _TtC8Keychain8Keychain is implemented in both /Users/ornapier/Library/Developer/Xcode/DerivedData/App-grdjljgevqofhqgflgtrqvhvbtej/Build/Products/Debug-iphonesimulator/PackageFrameworks/Core_59974D35D_PackageProduct.framework/Core_59974D35D_PackageProduct (0x100a98118) and /Users/ornapier/Library/Developer/CoreSimulator/Devices/216C441E-4AE5-45EC-8E52-FA42D8562365/data/Containers/Bundle/Application/7197F2F2-EB26-42FF-B7DB-67116159897D/App.app/PlugIns/AppTests.xctest/AppTests (0x1011002c0). One of the two will be used. Which one is undefined. This is not a benign warning. There are two distinct copies of _TtC8Keychain8Keychain and test cases will access one and the app will access a different one. This leads to mismatches when accessing static instances such as .shared. I believe this dependency graph should work, and it does work as long as the top-level testing system is a Swift module. But if it is the application, it builds successfully, but behaves incorrectly in subtle ways.
0
5
515
Feb ’25
The behavior of the app using the Promises library changes between Xcode 15.4 and Xcode 16.2.
I’m creating code that performs asynchronous processing using the Promises library (https://github.com/google/promises). In this context, when building the app in Xcode 15.4 and Xcode 16.2, the behavior differs between the two. I’m using version 2.1.1 of the library. Also, I’ve tried using the latest version, 2.4.0, but the result was the same. Has anyone encountered the same issue or know an effective solution? Here's a simple code that reproduces this issue. @IBAction func tapButton(_: UIButton) { _ = getInfo() } func getInfo() -> Promise<Void> { Promise(on: .global(qos: .background)) { fulfill, _ in self.callApi() .then { apiResult -> Promise<ApiResult> in print("\(#function), first apiResult: \(apiResult)") return self.callApi() // #1 } .then { apiResult in print("\(#function), second apiResult: \(apiResult)") // #2 fulfill(()) } } } func callApi() -> Promise<ApiResult> { Promise(on: .global(qos: .background)) { fulfill, _ in print("\(#function), start") self.wait(3) .then { _ in let apiResult = ApiResult(message: "success") print("\(#function), end") fulfill(apiResult) } } } struct ApiResult: Codable { var message: String enum CodingKeys: String, CodingKey { case message } } The Swift Language version in the build settings is 5.0. The console output when running the above code is as follows: When built with Xcode 15.4: 2025/03/21 10:10:46.248 callApi(), start 2025/03/21 10:10:46.248 wait 3.0 sec 2025/03/21 10:10:49.515 callApi(), end 2025/03/21 10:10:49.535 getDeviceInfo(), first apiResult: ApiResult(message: "success") 2025/03/21 10:10:49.535 callApi(), start 2025/03/21 10:10:49.536 wait 3.0 sec 2025/03/21 10:10:52.831 callApi(), end 2025/03/21 10:10:52.832 getDeviceInfo(), second apiResult: ApiResult(message: "success") The process proceeds from #1 to #2 after completing the code comment in #1. When built with Xcode 16.2: 2025/03/21 09:45:33.399 callApi(), start 2025/03/21 09:45:33.400 wait 3.0 sec 2025/03/21 09:45:36.648 callApi(), end 2025/03/21 09:45:36.666 getDeviceInfo(), first apiResult: ApiResult(message: "success") 2025/03/21 09:45:36.666 callApi(), start 2025/03/21 09:45:36.666 wait 3.0 sec 2025/03/21 09:45:36.677 getDeviceInfo(), second apiResult: Pending: ApiResult 2025/03/21 09:45:39.933 callApi(), end The process does not wait for the code comment in #1 to finish and outputs the #2 print statement first. Additionally, even with Xcode 16.2, when changing the #2 line to "print("(#function), second apiResult: (apiResult.message)")", the output becomes as follows. From this, it seems that referencing the ApiResult type, which is not a String, might have some effect on the behavior. 2025/03/21 10:05:42.129 callApi(), start 2025/03/21 10:05:42.131 wait 3.0 sec 2025/03/21 10:05:45.419 callApi(), end 2025/03/21 10:05:45.437 getDeviceInfo(), first apiResult: ApiResult(message: "success") 2025/03/21 10:05:45.437 callApi(), start 2025/03/21 10:05:45.437 wait 3.0 sec 2025/03/21 10:05:48.706 callApi(), end 2025/03/21 10:05:48.707 getDeviceInfo(), second apiResult: success Thank you in advance
0
0
151
Mar ’25
iOS devices in CI get lost
Hello. We have a few iOS devices connected to CI macs. We test our 3D engine, so we really need hardware devices for that. The issue is that Xcode loses connection to the devices once in a while, mostly after mac reboot, which requires a human to enter test room and unplug and plug cable again. Even if device is visible and accessible in Finder, Xcode may still don't see it, and devicectl shows it as disconnected. Are there any hacks to make connection stable? The best what we could achieve so far was to remove iOS device screen lock - otherwise mac reboot would in 100% cases require human interaction to reconnect the device. Both iOS and mac are logged into the same Apple ID. Mac is logged in automatically after reboot iOS devices have no screen lock Thank you.
0
0
186
Jan ’25
FamilyControls Framework info.plist missing
We are trying to create a screentime app using the Family Controls as well as Device activity frameworks. The build succeeds but while pushing to an iphone we are getting an info.plist file for deviceactivity.framework could not be found error. For reference when using the Screentime API a physical device must be used not a simulator. When we remove the device activity framework this error also occurs for the family controls framework. We have added the Family Controls(development) Capability and applied for the distribution capability. We have redownloaded xcode multiple times on the main device, deleted derived data, and redownloaded all of the iphone SDKs and the issue still persists.
0
0
235
Mar ’25
Apple developer
in xcode i have select the developer team. but show some error that is here, "Communication with Apple failed Your team has no devices from which to generate a provisioning profile. Connect a device to use or manually add device IDs in Certificates, Identifiers & Profiles. https://developer.apple.com/account/" and show this error also "No profiles for 'com.kuntaldoshi.homeautomation' were found Xcode couldn't find any iOS App Development provisioning profiles matching 'com.kuntaldoshi.homeautomation'."
0
0
354
Feb ’25