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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

Why can't Xcode find symbols in scope, but still compiles?
My swiftUI project has started to constantly display "Cannot find 'symbol' in scope" errors in code i haven't touched, and the project still compiles fine. Neither cleaning build folder or compiling fix the errors, but if I right click the symbol, select "jump to definition" it will find it without problem and then when I return to the original file the error will be cleared. What can I do to stop these from happening?
0
1
170
Feb ’25
Updating Swift Packages via command line (Xcode 16)
We have a tool in our CI which periodically updates our iOS project's Swift Package Manager dependencies. The script that does a few things, but generally speaking it first removes the existing package.resolved at ./ProjectName.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved and then runs: xcodebuild -resolvePackageDependencies -disablePackageRepositoryCache This regenerated the package.resolved file to reflect the latest, updated versions of the dependencies. It is the equivalent of doing Xcode > File > Packages> Update to Latest Package Versions. This has been working perfectly for a long time, but has stopped working since we moved from Xcode 15.4 to Xcode 16. I have also tested this with Xcode 16.1 and 16.2 - with no luck. I have tried running this command locally, and can confirm it is not an issue with the environment of our CI. I have also tried swift package update. Both of these commands appear to work - no errors are thrown, and the logs say "resolved source packages". However, they are not updating the packages. They are making no changes to the package.resolved file. However, using Xcode > File > Packages> Update to Latest Package Versions in Xcode 16 works as expected - the packages are updated and the .resolved file is updated. Is there now a different way to update Swift packages via the command line, or is this likely an Xcode 16 bug? Update: This feels broken, so I have submitted a Feedback Report (FB16108036) but perhaps someone can suggest a workaround for the time being!
0
3
864
Dec ’24
Error When Trying to Switch from ADEP to AdHoc for iOS App Deployment
I have created two different apps using ADEP, and they were working on iPad with iOS 14.6 and 14.7.1. The environments are as follows: Environment: 1.Mac mini (Mac OS X 10.7.5) Xcode 8.3.2 2.iMac (OS X El Capitan 10.11.6) Xcode 7.3 The certificates were exported from the environment in 1 and imported into 2. When I tried to switch from ADEP to AdHoc for app creation, I encountered an error. Specifically, the app worked fine on an iPad running iOS 12.5.7 in environment 1, but on devices with iOS 14.6, 14.7.1, and 17.7, the installation was successful, but when I tried to open the app, the following error message appeared: “XXXXX” needs to be updated To run this app on this version of iOS, the developer needs to update the app. Additionally, in environment 2, I’m unable to archive the app. Is it possible to create a working app by simply switching from ADEP to AdHoc without making any other changes to the environment?
0
0
110
Feb ’25
boringss1_metrics_log_metric_block_invoke (153) Failed to log metrics
i created a new project and imported firebaseauth , firebasefirestore, firebasefirestoreswift and firebase storage and i run this project any time i run this project the code they are all fine i get this error saying boringss1_metrics_log_metric_block_invoke (153) Failed to log metrics anytime i click create account button note that i get them results in my firebase authentication but it seems not to pass the registration page in my project and prints that error i am stuck somebody please save me even when i try to login the already created account from the userSection from the auth.authservice it still shows this error and wont pass the login page same with the registration page
0
0
233
Nov ’24
`xcodebuild test` stuck because of app data container protection
Hi, I have recently noticed a very-very annoying thing in my CI pipeline, that I managed to reproduce locally. Using macOS Sonoma 14.7.1 and Xcode 15.4, running a test target from Terminal, the first run produces this output: $ xcodebuild test -workspace [redacted].xcworkspace -scheme [redacted] -quiet --- xcodebuild: WARNING: Using the first of multiple matching destinations: { platform:macOS, arch:arm64, id:[redacted], name:My Mac } { platform:macOS, arch:x86_64, id:[redacted], name:My Mac } { platform:macOS, name:Any Mac } Testing started Test suite '[redacted]' started on 'My Mac - [redacted] (75944)' Test case '[redacted].[redacted]()' passed on 'My Mac - [redacted] (75944)' (0.001 seconds) Test case '[redacted].[redacted]()' passed on 'My Mac - [redacted] (75944)' (0.001 seconds) 2024-11-29 19:31:02.311 xcodebuild[75908:47784216] [MT] IDETestOperationsObserverDebug: 1.380 elapsed -- Testing started completed. 2024-11-29 19:31:02.311 xcodebuild[75908:47784216] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start 2024-11-29 19:31:02.311 xcodebuild[75908:47784216] [MT] IDETestOperationsObserverDebug: 1.380 sec, +1.380 sec -- end so the test actually completes, but the process does not end, because I get a popup that “Terminal.app” would like to access data from other apps. Removing the "App Sandbox" entitlement immediately alleviates this problem, but it would be very silly to do so because of unit tests. This ultimately means that whenever we use a new device or include a new project or test target, this popup comes up. Very undesirable for CI servers (especially if the servers are ephemeral virtual machines created for the current job). Is there a permanent solution that disables this popup for test runs?
0
0
748
Nov ’24
Affiliate View Struct is probably hidden by Charts on iOS app
The problem is: As per screenshot below, one can only see the lineChart. I have another struct AffiliateView coded under this Chart: import SnapKit import Charts import DGCharts class AffiliateViewController: UIViewController { private lazy var chartView: LineChartView = { let chart = LineChartView() chart.noDataText = "No data available." chart.chartDescription.enabled = false chart.xAxis.labelPosition = .bottom chart.rightAxis.enabled = false chart.legend.enabled = true chart.backgroundColor = .lightGray // For debugging visibility return chart }() private lazy var containerView: UIView = { let view = UIView() view.backgroundColor = .white return view }() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .white // Add container view and chart view to the main view view.addSubview(containerView) view.addSubview(chartView) // Add SwiftUI View inside the container view let affiliateView = AffiliateView() let hostingController = UIHostingController(rootView: affiliateView) addChild(hostingController) containerView.addSubview(hostingController.view) hostingController.view.frame = containerView.bounds hostingController.didMove(toParent: self) layout() setupChartData() } private func layout() { // Layout the container view (SwiftUI content) containerView.snp.makeConstraints { make in make.top.equalTo(view.safeAreaLayoutGuide.snp.top) make.left.right.equalToSuperview() make.height.equalTo(350) // Increase the height for the SwiftUI content } // Layout the chart view below the container view chartView.snp.makeConstraints { make in make.top.equalTo(containerView.snp.bottom).offset(20) // Space between chart and the affiliate content make.left.equalToSuperview().offset(20) make.right.equalToSuperview().offset(-20) make.height.equalTo(200) // Set a fixed height for the chart } } private func setupChartData() { let dataEntries = [ ChartDataEntry(x: 1, y: 10), ChartDataEntry(x: 2, y: 20), ChartDataEntry(x: 3, y: 15), ChartDataEntry(x: 4, y: 30), ChartDataEntry(x: 5, y: 25) ] let dataSet = LineChartDataSet(entries: dataEntries, label: "Clicks per Day") dataSet.colors = [.blue] dataSet.valueColors = [.black] dataSet.circleColors = [.red] dataSet.circleRadius = 4.0 let data = LineChartData(dataSet: dataSet) chartView.data = data chartView.notifyDataSetChanged() } } // SwiftUI View remains in the same file struct AffiliateView: View { @State private var customMessage: String = "" @State private var uniqueLink: String = "Your unique link will appear here." @State private var clickData: [Double] = [10, 20, 15, 30, 25] // Example data var body: some View { NavigationView { VStack(spacing: 20) { // TextField for custom message input TextField("Enter your custom message...", text: $customMessage) .textFieldStyle(RoundedBorderTextFieldStyle()) .padding(.horizontal) // Generate Link Button Button(action: generateLink) { Text("Generate Sign-Up Link") .font(.headline) .foregroundColor(.white) .frame(maxWidth: .infinity, maxHeight: 50) .background(Color.red) .cornerRadius(10) } .padding(.horizontal) // Generated Link Label Text(uniqueLink) .font(.body) .multilineTextAlignment(.center) .padding(.horizontal) // You can add a chart here if you want to show it in SwiftUI too /* LineChartView(data: clickData, title: "Clicks per Day", legend: "Daily Clicks") */ } .navigationTitle("Affiliate Marketing") .navigationBarTitleDisplayMode(.inline) } } private func generateLink() { let encodedMessage = customMessage.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? "" uniqueLink = "https://affiliate.example.com/referral?message=\(encodedMessage)" addClickData() } private func addClickData() { clickData.append(Double.random(in: 0...100)) } } As you see, the AffiliateView has been declared outside of Controller View class. The View content was visible before the lineChart was added into this code. Now the View content is not visible anymore. I have tried to increment/decrement values at make.height.equalTo() but to no avail. Could anyone kindly point me in the right direction?
0
0
296
Jan ’25
No option for App store / TestFlight for archive
Hi! I have now spend a few days of trying to only get the option in Xcode to distribute to App Store. My app works on my own device, I have paid developer account and created a record for the app and its bundle id in App Store Connect. After archive the only options I can see is "Release testing, Enterprise, Debug and Custom". I have verified a lot of settings in both info.plist and build settings, without luck. I also see that the "Validate" button is greyed out, and the "SKIP_INSTALL" does not do the trick to enable it, and the archive is not a generic one, its explicit for watchOS. Using Xcode 16.2. Any suggestions of what to try before registering a support case.
0
0
178
Jan ’25
Xcode 16.1: Swift macro killing indexing performance?
I'm working on a project with several dozen targets and a Swift macro. Due to the purpose of the macro (generating Codable boilerplate), pretty much all targets depend on it. The project is generated with XcodeGen. Since upgrading to 16.1 (I think), Xcode has basically turned into a glorified TextEdit for me: refactoring, symbol navigation and search don't work. Also, I'm getting a lot of ghost errors that keep popping up hours after I fix them, while at the same time new build errors never show up in the error navigator, so I have to check the build log to see why the build failed. I noticed that project indexing is taking a very long time. As a troubleshooting step, I tried deleting DerivedData (which afaik includes the index) to see if this fixes the problem. Xcode started indexing the project from scratch, and if the progress indicator is to be trusted, After ~40 minutes it's only about 1/3 done. For every target Xcode seems to be spending a lot of time indexing SwiftOperators, SwiftDiagnostics, SwiftParser. I'm assuming these are related to the macro. Does anyone else have this problem? Unfortunately, I can't confirm this is caused by the macro, removing it from the project and seeing if this fixes the issue seems infeasible.
0
0
394
Dec ’24
Fetch Changes not working Xcode 16.2
I have cloned a private repo from GitHub and for the most part it seems to be working fine. e.g. commit, push and pull are working. However, Fetch Changes doesn't seem to work at all. It pops up a brief message as if it is working, but the status of my local branch under the Source Control Navigator -> Repositories does not get updated. Even after a push, the status still tells me I am ahead on the local branch. If I add a new file on the GitHub website, Fetch Changes will not see it and the repository status remains unchanged. All of these changes are immediately visible in 'Fork' (3rd party Git GUI). If I restart Xcode the status is updated correctly, but it does not keep up with further changes. Anything I can do other than avoid using Xcode for GitHub tasks? Update: This might just be a problem with the Source Control Navigator views not updating. I just found that if I change branch, the "Repositories" section will not reflect the branch change until I exit and re-enter that view. e.g. click on "Changes" and back into "Repositores" to see the update. That workaround does not impact the out of date repo status though (how many commits am I ahead or behind). Seems very buggy...
0
2
317
Jan ’25
Any solution yet to not being able to turn off debugging via WiFI?
Debugger on Xcode 16.x is super slow and it turns out it's only this way when Xcode is connected to my iPhone via WiFi. If I disable WiFI on my iPhone everything is just fine. But that's not a solution. An engineer posted this supposed solution, https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes. Forgive me but that's not a solution, especially since we used to be able to shut off "Connect via WiFI." I've seen so many posts here and everywhere else with no one stating any clear answer. Does anyone know why has this been removed? And is anyone aware of it? I've posted in the Feedback Asst. as many others have. What gives?
0
1
212
Jan ’25
Assistance Required for Accessing Non-Secure HTTP API in Ionic Build App
Dear Team, I was previously able to access a non-secure HTTP API in my Ionic-built app. However, I am now encountering an error where the API requests are being rejected. Interestingly, this API works perfectly on Android and web platforms without any issues. As part of my troubleshooting, I have already added the following lines to my Info.plist file: <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> Could you kindly suggest any alternative solutions or additional settings required to access this HTTP API? Your help would be greatly appreciated. Thank you, Mozib
0
0
154
Jan ’25
Configure Format to Multiple Lines?
Is there any way to modify the behaviour of this command? I really dislike that it adds a break after the opening parenthesis and would also prefer it to use the traditional multi-line style where the lines are aligned with their semicolons. Alternatively, is there a way to run the "Format File with 'swift-format'" command without implicitly triggering "Format to Multiple Lines", as it apparently does? Having to reformat my method's signatures afterwards really makes this feature unattractive to me at the moment.
0
0
128
Jan ’25
Unstable `archive` for `Debug` configuration (ld: file cannot be open()ed, errno=2)
We have a relatively big iOS-only project with around 80 build targets from swift packages (local features and external project dependencies) and Xcode 15.4 (originally, migrated to 16.0). Project compiles and runs great, but xcodebuild archive will fail 4 out of 5 tries with this: ld: file cannot be open()ed, errno=2 path=/opt/builds/fLLyxmhG/0/myapp/Build/Intermediates.noindex/ArchiveIntermediates/myapp (Development Flow)/BuildProductsPath/Debug-iphonesimulator/Account.o in '/opt/builds/fLLyxmhG/0/myapp/Build/Intermediates.noindex/ArchiveIntermediates/myapp (Development Flow)/BuildProductsPath/Debug-iphonesimulator/Account.o' Where Account.o is an end product of one of our feature packages linking to an .app itself. This error is not tied to this concrete package/product (which should be compiling almost last relative to build graph) and could appear mid-build in between our service layer packages. It seems (and is approved by Xcode timeline for .app archive log) that module dependency is compiled later than module itself and linker just cant find its dependency object files. The scheme is: Module A (dependency itself) Module B (needs module A) And with build order expected (???) to be A (first) -> B we're getting the B -> A. Error appears only when archiving for Debug configuration, archiving the same end-target with Release configuration results in stable passes 10 out of 10 tries. Setting identical parameters in Build Settings tab for both configurations of a target is not giving any effect. Our current fix is choosing Manual order in scheme Build order setting. Everything works as expected, but i guess it's not optimal 🤧 Sadly can't provide test project, but anything else — welcome.
0
1
428
Dec ’24
Is "remotepairingd" Xcode-related?
Is remotepairingd part of Xcode? It seems to be stuck using 119% CPU. This may have started when I recently paired my new Apple Watch with Xcode - or maybe that is a coincidence. The console is full of: error 16:40:26.237601+0000 remotepairingd socket-1: No more data can be received, connection was closed
0
0
560
Dec ’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
288
Nov ’24
Uncategorized (Xcode): Command ClangStatCache failed with a nonzero exit code
I'm encountering an issue while trying to build my iOS app in Xcode for the simulator. Issue: Xcode Version: 15.x macOS Version: 14.x (Sonoma) Simulator: iPhone 16 Pro Error Message: Command ClangStatCache failed with a nonzero exit code Steps Taken: Cleaned build folder (Shift + Cmd + K) Deleted DerivedData (rm -rf ~/Library/Developer/Xcode/DerivedData) Updated Xcode and checked iOS SDK updates Disabled Clang Static Analyzer Cache None of these steps resolved the issue. Any help would be appreciated! Thanks in advance.
0
0
154
Mar ’25