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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

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
324
Jan ’25
Stale Issues, refreshAllObjects() is not working
Hi Experts, Could you please help. Issue at high level: After Editing a View contains a Table entries, saved and hit back button to display View, Table entries are duplicated or displaying previous and current entries together. Here is my Issue in detailed. List view display, clicking on any row, would navigate to DisplayView of a record. I am displaying a table in DisplayView. DisplayView contains "row" as parameter, and it must be initialized in "init" method, where I use row.key and fetch another table (say ColorTab) using Color.Key. DisplayView contains "NavigationView", with Edit button. it displays fetched Colors. example Red and Green. when user click on Edit, it takes to EditPage. user can remove / add colors. Once user made changes, saved and hit back button. Table entries are duplicated or showing previous and current entries. Options tried, a) init method is only triggering 1st time, not triggering when back button clicked, I failed to use FetchRequest outside of init method, I tried on OnAppear too. i didn't trigger. b) Failed to use FetchRequest inside of var Body too. c) tried using viewContext.refreshAllObjects() .. it is not refreshing the table. Could you please help if there is solution for the issue. Thanks, Bhanu
0
0
78
May ’25
Undefined time_t in openssl
I'm having trouble compiling my project for the iOS 18.2 simulator. I'm getting the following error: `Missing '#include <sys/_types/_time_t.h>'; 'time_t' must be declared before it is used` The error points to to simulartor-iOS 18.2 > user/include/sys/_types/_time_t.h #ifndef _TIME_T #define _TIME_T #include <machine/types.h> /* __darwin_time_t */ typedef __darwin_time_t time_t; #endif /* _TIME_T */ This suggests that the time_t type should be defined, but the compiler isn't seeing it. I suspect there might be a problem with preprocessor definitions. Is there anything I set wrong? I am using OpenSSL.xcframework.
0
1
230
Jan ’25
Xcode16.x+ios18.x simulator crashing and tests are failing
We are seeing crashes after upgrading to xcode16.x ( tested with 16.1 , 16.2 and 16.3) and ios 18.1, 18.2, 18.3.1 and 18.4 . when tests are running simulator is crashing with mulitple reasons. CoreSimulatorService[85444] <Error>: Failed to get a device identity for simulator device BFAD684E-A48A-4170-80E1-8FBC04744E79, error: Error Domain=com.apple.MobileActivation.ErrorDomain Code=-1 "Failed to create BAA info." UserInfo={NSLocalizedDescription=Failed to create BAA info., NSUnderlyingError=0x600002072a60 {Error Domain=com.apple.MobileActivation.ErrorDomain Code=-1 "Failed to query baa info." UserInfo={NSLocalizedDescription=Failed to query baa info., NSUnderlyingError=0x600002073390 {Error Domain=com.apple.MobileActivation.ErrorDomain Code=-1 "Failed to load cryptex1 manifest." UserInfo={NSLocalizedDescription=Failed to load cryptex1 manifest., NSUnderlyingError=0x600002071110 {Error Domain=com.apple.MobileActivation.ErrorDomain Code=-1 "Failed to load firmware data from /System/Volumes/iSCPreboot/F743DA4B-92E7-4E92-ACD2-40775DF4B5A2/cryptex1/current/apticket.j274ap.1A256C21D3001E.im4m." UserInfo=0x600003b47bc0 (not displayed)}}}}}} sometimes crashing with [02:47:24]: ▸ Tests_iOS-Runner encountered an error (Failed to prepare device 'Clone 2 of iPhone 16 Pro' for impending launch. (Underlying Error: Unable to boot the Simulator. launchd failed to respond. (Underlying Error: Failed to start launchd_sim: could not bind to session, launchd_sim may have crashed or quit responding))) sometimes with [18:44:47]: ▸ 2025-05-08 18:44:47.019 xcodebuild[75752:6252304] [MT] IDELaunchReport: a616bd895a3ee240:a616bd895a3eec00:Install Actions Finished with error: Unable to boot the Simulator. [18:44:47]: ▸ Domain: NSPOSIXErrorDomain [18:44:47]: ▸ Code: 60 [18:44:47]: ▸ Failure Reason: launchd failed to respond. [18:44:47]: ▸ User Info: { [18:44:47]: ▸ Session = "com.apple.CoreSimulator.SimDevice.BD4A5DAB-3317-44D1-AFD1-C6EED090BB20"; [18:44:47]: ▸ } [18:44:47]: ▸ -- [18:44:47]: ▸ Failed to start launchd_sim: could not bind to session, launchd_sim may have crashed or quit responding [18:44:47]: ▸ Domain: com.apple.SimLaunchHostService.RequestError [18:44:47]: ▸ Code: 4 [18:44:47]: ▸ -- [18:44:47]: ▸ 2025-05-08 18:44:47.019 xcodebuild[75752:6252304] [MT] IDELaunchReport: a616bd895a3ee240:a616bd895a3eec00:Install Actions com.apple.dt.IDERunOperationWorkerFinished { [18:44:47]: ▸ "operation_duration_ms" = 55114; [18:44:47]: ▸ "operation_errorCode" = 60; [18:44:47]: ▸ "operation_errorDomain" = NSPOSIXErrorDomain; [18:44:47]: ▸ "operation_name" = "_IDEInstalliPhoneSimulatorWorker"; [18:44:47]: ▸ } sometimes crashing with Run test suite Tests2 encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying Error: Test crashed with signal term before starting test execution.))
0
2
526
May ’25
Network Instability in TestFlight Builds When Using Xcode 16+
We are experiencing networking issues in our iOS application when it is built with Xcode 16 or later. Our app includes a video conferencing feature that works reliably when built with Xcode 15 or earlier — we can sustain hour-long video sessions without interruption. However, when the app is built using Xcode 16 or higher, network connections drop after 2–3 minutes during a session. This triggers an auto-reconnect, which succeeds, but the connection drops again after another 2–3 minutes. This loop continues indefinitely. Key Details: The issue only occurs in TestFlight builds. When running the app via Xcode debugger, the issue does not occur. The issue is consistently reproducible in TestFlight builds created with Xcode 16 or later. TestFlight builds created with Xcode 15 do not exhibit this issue. All the videoconferencing runs on C and C++ code What We’ve Tried: Reviewed Xcode 16+ release notes but found no relevant changes or deprecations. Verified app configuration and entitlements. Confirmed that no app-side changes occurred between the working and broken builds. Request: We’re seeking guidance on what changes in Xcode 16+ could be affecting networking behavior in release/TestFlight builds. Any insight into relevant build settings, compiler changes, or runtime behavior differences would be greatly appreciated. Thank you in advance for your assistance.
0
0
79
May ’25
Questions about Deployment Targets in Xcode
The “Deployment Targets” for iOS was IOS12 or higher in Xcode15, but is now listed as IOS15 or higher in Xcode16. https://developer.apple.com/support/xcode/ How does this change affect developers and users? For example, if a developer specifies less than iOS15 in the “iOS Deployment Target” on Xcode, how will this affect them? Also, will users under iOS 15 be unable to run the apps?
0
0
100
May ’25
Cannot use instance member 'input_parameter' within property initializer; property initializers run before 'self' is available
I am passing UUID Key from View1 to View2. In View2, I need to Fetch entries using TabKey. userId is global variable working fine. Giving error TabKey. Please help. how to get rid of this error. If I keep this logic inside init method, Getting new error saying that "Cannot convert value of type 'FetchedResults' to expected argument type 'Binding' Here is the Code. @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: \Table2.date, ascending: false)], predicate: { guard let currentUserId = AppSession.shared.currentUserId else { return NSPredicate(value: false) // Or handle the nil case as needed } return NSPredicate(format: "userId == %@ AND itemKey == %@", currentUserId as CVarArg, TabKey as CVarArg ) }(), animation: .default ) private var itab: FetchedResults
0
0
63
Apr ’25
Have problem with automatic signing
hông thể cài đặt “TrungDemo” Domain: IXUserPresentableErrorDomain Code: 14 Recovery Suggestion: Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.kpOILI/extracted/TrungDemo.app : 0xe8008018 (The identity used to sign the executable is no longer valid.) Please ensure that the certificates used to sign your app have not expired. If this issue persists, please attach an IPA of your app when sending a report to Apple. User Info: { DVTErrorCreationDateKey = "2025-04-29 10:51:27 +0000"; IDERunOperationFailingWorker = IDEInstallCoreDeviceWorker; } Failed to install the app on the device. Domain: com.apple.dt.CoreDeviceError Code: 3002 User Info: { NSURL = "file:///Users/studiozego/Library/Developer/Xcode/DerivedData/TrungDemo-blspaulbkwypvhgaxxfjqbppuugg/Build/Products/Debug-iphoneos/TrungDemo.app"; } Không thể cài đặt “TrungDemo” Domain: IXUserPresentableErrorDomain Code: 14 Failure Reason: Không thể cài đặt ứng dụng này vì không thể xác minh tính toàn vẹn của ứng dụng. Recovery Suggestion: Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.kpOILI/extracted/TrungDemo.app : 0xe8008018 (The identity used to sign the executable is no longer valid.) Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.kpOILI/extracted/TrungDemo.app : 0xe8008018 (The identity used to sign the executable is no longer valid.) Domain: MIInstallerErrorDomain Code: 13 User Info: { FunctionName = "+[MICodeSigningVerifier _validateSignatureAndCopyInfoForURL:withOptions:error:]"; LegacyErrorString = ApplicationVerificationFailed; LibMISErrorNumber = "-402620392"; SourceFileLine = 80; } Event Metadata: com.apple.dt.IDERunOperationWorkerFinished : { "device_identifier" = "00008132-0001786E22B9001C"; "device_isCoreDevice" = 1; "device_model" = "iPad16,4"; "device_osBuild" = "18.4 (22E240)"; "device_platform" = "com.apple.platform.iphoneos"; "device_thinningType" = "iPad16,4-A"; "dvt_coredevice_version" = "443.19"; "dvt_coresimulator_version" = "1010.10"; "dvt_mobiledevice_version" = "1784.102.1"; "launchSession_schemeCommand" = Run; "launchSession_state" = 1; "launchSession_targetArch" = arm64; "operation_duration_ms" = 1320; "operation_errorCode" = 14; "operation_errorDomain" = IXUserPresentableErrorDomain; "operation_errorWorker" = IDEInstallCoreDeviceWorker; "operation_name" = IDERunOperationWorkerGroup; "param_debugger_attachToExtensions" = 0; "param_debugger_attachToXPC" = 1; "param_debugger_type" = 3; "param_destination_isProxy" = 0; "param_destination_platform" = "com.apple.platform.iphoneos"; "param_diag_113575882_enable" = 0; "param_diag_MainThreadChecker_stopOnIssue" = 0; "param_diag_MallocStackLogging_enableDuringAttach" = 0; "param_diag_MallocStackLogging_enableForXPC" = 1; "param_diag_allowLocationSimulation" = 1; "param_diag_checker_tpc_enable" = 1; "param_diag_gpu_frameCapture_enable" = 0; "param_diag_gpu_shaderValidation_enable" = 0; "param_diag_gpu_validation_enable" = 0; "param_diag_guardMalloc_enable" = 0; "param_diag_memoryGraphOnResourceException" = 0; "param_diag_mtc_enable" = 1; "param_diag_queueDebugging_enable" = 1; "param_diag_runtimeProfile_generate" = 0; "param_diag_sanitizer_asan_enable" = 0; "param_diag_sanitizer_tsan_enable" = 0; "param_diag_sanitizer_tsan_stopOnIssue" = 0; "param_diag_sanitizer_ubsan_enable" = 0; "param_diag_sanitizer_ubsan_stopOnIssue" = 0; "param_diag_showNonLocalizedStrings" = 0; "param_diag_viewDebugging_enabled" = 1; "param_diag_viewDebugging_insertDylibOnLaunch" = 1; "param_install_style" = 2; "param_launcher_UID" = 2; "param_launcher_allowDeviceSensorReplayData" = 0; "param_launcher_kind" = 0; "param_launcher_style" = 99; "param_launcher_substyle" = 0; "param_runnable_appExtensionHostRunMode" = 0; "param_runnable_productType" = "com.apple.product-type.application"; "param_structuredConsoleMode" = 1; "param_testing_launchedForTesting" = 0; "param_testing_suppressSimulatorApp" = 0; "param_testing_usingCLI" = 0; "sdk_canonicalName" = "iphoneos18.4"; "sdk_osVersion" = "18.4"; "sdk_variant" = iphoneos; } System Information macOS Version 15.4.1 (Build 24E263) Xcode 16.3 (23785) (Build 16E140) Timestamp: 2025-04-29T17:51:27+07:00
0
0
142
Apr ’25
openURL:options:completionHandler: Simulator Bug
Xcode 16.2. When calling openURL:options:completionHandler: when in the simulator for a link in the app store (for example: http://itunes.apple.com/us/app/slidewords/id503737864?mt=8) behavior is fine for simulated iPads, not for simulated iPhones. When the simulated device is an iPad, the call correctly opens the app store link. When the simulated device is an iPhone, an error message "Safari cannot open the page because the address is invalid." Note: the call works on an an actual iPhone (iPhone SE 3rd generation, unsure about other devices).
0
0
45
Apr ’25
AuthenticateAsClient(this.Host、this.certificates、System.Security.Authentication.SslProtocols.Tls12,false)
Apple's push cannot receive information, use the open-source library JdSoft. Apple.Apns.Notifications Because I am not familiar with it, I modified Tls12. Does anyone know how to modify this open-source library to achieve push functionality apnsStream.AuthenticateAsClient(this.Host, this.certificates, System.Security.Authentication.SslProtocols.Tls12, false)
0
0
58
Apr ’25
App Suspended during active voip call on Xcode 16
We have started facing an issue after updating Xcode from version 15.2 to 16, we have a voip application with webview and call kit, and we have the Background Modes capabilities: Voip, Audio, Background fetch, and Background processing. We had no problem on Xcode 15, but ever since updating Xcode 16 and sdk 18, when app goes into the background during an active call, the app is suspended and no events are triggered UNTIL the app is resumed to the foreground.
0
0
140
May ’25
Xcode - Command "Find Selected Symbol in Workspace" gives no result
Example: I have a state var curHighScore declared in ContentView. I select it, right click and select "Find Selected Symbol in Workspace" The result is : 1 resul in 1 file, i.e. the line of declaration of the var But obviously, the same var is used at line #102: How come this occurence is not found by the search command. Such happens every now and then. Is there something I am missing ? What is causing this ? Thanks for your help.
0
1
235
Feb ’25
iOS 18.4で NFC や FeliCa の読み取りがしずらい状況のようです。こちらは認知されていますでしょうか?どのバージョンで直る想定でしょうか?
■概要: 弊社で開発しているアプリ内には、モバイルSuicaを読み取る機能があるのですが、iOS18.4でSuicaの読み取りができない事象に遭遇しています。(ごくまれに読み取れるときがある) ■利用API CoreNFC ■聞きたいこと: こちらいつごろ修正されるか教えてください。 ■参考情報 他社様ですが類似だと思われる事象が発生しております。
0
0
129
Apr ’25
xcrun devicectl not work as expected in Apple TV
What I want? I expect to use xcrun devicectl device process launch --device <uuid> <bundle-identifier> --payload-url <URL> to launch my app and pass the specified URL as I usually do in iPhone. What I do? Let's say the app A which I'm developing. I try to use UIApplication.open(:options:completionHandler:) in another app to open the app A with registered schema. And whether app A is cold launch or background resumption, app A can go foreground with receiving URL. If I use xcrun devicectl as above described, app A can still be opened. However, app A can't receive URL which I pass through --payload-url option. That's different from in iOS. BTW: I as well try YouTube with UIApplication.open and xcrun devicectl, the former way work, the latter way not work.
0
0
190
Mar ’25
APNS NULL
this is our code foe fetching the apnstoken - and registering for the FCM and snding it to our servers. - we are consistently getting apns == null import 'dart:io'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:solaris/services/fetch_deviceId.dart'; Future initializeFCM() async { final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; // Request notification permissions for iOS final settings = await _firebaseMessaging.requestPermission(); print('Notifcation Permission Status: ${settings.authorizationStatus}'); String? apnsToken; int retries = 0; const int maxRetries = 60; const Duration retryDelay = Duration(seconds: 2); // Retry fetching the APNs token until it's available or max retries are reached while (apnsToken == null && retries < maxRetries) { print(retries); apnsToken = await _firebaseMessaging.getAPNSToken(); if (apnsToken == null) { await Future.delayed(retryDelay); retries++; } } if (apnsToken != null) { // APNs token is available, proceed to get FCM token String? fcmToken = await _firebaseMessaging.getToken(); if (fcmToken != null) { // Register the device and token with your backend await registerDeviceAndToken(fcmToken); } else { // Handle the case where FCM token is still null print('FCM token is null.'); } } else { // Handle the case where APNs token is not available after retries print('APNs token not available after retries.'); } } Future registerDeviceAndToken(String fcmToken) async { //fcmToken = fcmToken; print(fcmToken); final user = FirebaseAuth.instance.currentUser; if (user == null) { print('❌ User not logged in'); return; } final deviceId = await DeviceInfoService.getUniqueDeviceId(); //final fcmToken = await FirebaseMessaging.instance.getToken(); print('📱 Device ID from register_fcm: $deviceId'); print('📩 FCM Token from mew getapnd function: $fcmToken'); if (deviceId == null || fcmToken == null) { print('❌ Failed to get deviceId or fcmToken'); return; } final docRef = FirebaseFirestore.instance .collection('master_users') .doc(user.uid) .collection('deviceId') .doc(user.uid); // This document holds a map: { deviceId: fcmToken } print(docRef); try { // Get current data, fallback to empty map final snapshot = await docRef.get(); final data = snapshot.data() ?? <String, dynamic>{}; print(data); // Update or add current deviceId key data[deviceId] = fcmToken; // Save updated map back to Firestore await docRef.set(data); print(data); print('✅ Device ID and FCM token updated/stored under correct structure'); } catch (e) { print('❌ Firestore write error: $e'); } }
0
0
85
Apr ’25