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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

[SwiftUI Preview] App crashes when previewing on physical device but runs normally
Hello everyone, I've encountered an issue with SwiftUI Preview and would appreciate your help. Problem Description In a mixed Objective-C and Swift project, I'm experiencing the following situation with SwiftUI Preview: Crashes when previewing on a physical device The same code runs normally when launched directly through Xcode Project uses CocoaPods for dependency management with static frameworks Project Environment: Project Type: Mixed (Objective-C + Swift) Dependency Management: CocoaPods Dependency Type: Static frameworks Device: Physical device preview Steps to Reproduce: Write Preview code in SwiftUI file Select physical device as Preview device Click Preview button Application crashes
3
0
586
Dec ’24
Xcode 16 Organizer Failed to Download Report's Stack Trace
I am currently investigating an issue with my app's slow launch time in Xcode 16. However, when I open the Launches pane in the Xcode Organizer, I can only see the report list, but I encounter an error message like the one below in the stack trace. This issue also occurs in the Disk Writes, Energy, and Hangs panes, but not in the Crashes pane. Can someone advise me on what steps I should take? Any help would be greatly appreciated.
1
0
486
Dec ’24
Xcode 16: SwiftUI plain Button & UIButton not working
It looks like Xcode 16 has changed this behavior so I'm not sure if this is a bug or not. When a SwiftUI Button wraps a UIButton, the button doesn't work on iOS 18.0+ import SwiftUI struct ContentView: View { var body: some View { VStack { Button(action: { print("Not called on iOS 18") }) { WrapperButton() .frame(width: 200, height: 50) } } } } struct WrapperButton: UIViewRepresentable { func makeUIView(context: Context) -> some UIView { let button = UIButton(type: .system) button.setTitle("OK", for: .normal) return button } func updateUIView(_ uiView: UIViewType, context: Context) {} } This occurs with the app build with Xcode 16 and running on iOS 18 but it was worked with Xcode 15 builds and running on iOS 18
1
0
568
Dec ’24
Advertising supported apps
Apple is pushing to use AdAttributionKit, but when I look at various ad networks, their sample code isn't using it. I'd like to find a simple example using a banner add and a third party ad network like admob. Also, I'm not clear on what post backs really do, or if I need them at all. If anyone can point me to clear documentation that is up to date, that would be great!
0
0
370
Dec ’24
"404 duplicate symbols"
Hi folks: I see previous chatter re this linker error message here on the forums and out in the wild, but I haven't been able to figure out where or how to track down the details necessary to resolve. For background, I've had iOS apps in the AppStore since 2021. They're fine, but, I want to update them for newer iOS releases, and use Catalyst to create MacOS versions. After updating to Xcode 15.2 but without changing the code, these apps no longer compile. "404 duplicate symbols" linker error. Update the Cocoapods and frameworks: same. Very difficult to find details in Xcode - it would be great if the error message took one to exact sources, but clicking the error does nothing. Added the -v flag with no change. From Internet chatter this behavior seems to be new in 15.x. I would imagine some of you have overcome this before now. How do I resolve it and get back to work? Thanks so much, --Mark
1
0
207
Dec ’24
How to show MyApp Icon to Document Folder shared by UIFileSharingEnabled in "On my iPhone"
How to show MyApp Icon to Document Folder shared by UIFileSharingEnabled in "On my iPhone" I would like to show my app (Falcon) on Chrome, Udemy, etc. This app is currently under development. Please let me know if there are any requirements to show it. I would be happy if iCloud also solves this problem at the same time because the icon is not displayed. For example, can it be displayed even if it is not released in the AppStore? This is my Info.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string>Falcon Package</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>lamina1331.Falcon</string> </array> </dict> </array> <key>NSUbiquitousContainers</key> <dict> <key>iCloud.lamina1331.Falcon</key> <dict> <key>NSUbiquitousContainerIsDocumentScopePublic</key> <true/> <key>NSUbiquitousContainerName</key> <string>Falcon</string> <key>NSUbiquitousContainerSupportedFolderLevels</key> <string>Any</string> </dict> </dict> <key>UIFileSharingEnabled</key> <true/> <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.data</string> </array> <key>UTTypeDescription</key> <string>Falcon Package</string> <key>UTTypeIconFiles</key> <array> <string>DocumentIcon</string> </array> <key>UTTypeIdentifier</key> <string>lamina1331.Falcon</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>flcpkg</string> </array> </dict> </dict> </array> <key>UTImportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.data</string> </array> <key>UTTypeDescription</key> <string>Falcon Package</string> <key>UTTypeIconFiles</key> <array> <string>DocumentIcon</string> </array> <key>UTTypeIdentifier</key> <string>lamina1331.Falcon</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>flcpkg</string> </array> </dict> </dict> </array> </dict> </plist>
2
0
746
Dec ’24
In the crash logs organizer is it possible to see how often a crash is occurring?
I can certainly see how many devices hit it but its a but is there enough data here to know if this was a fluke vs "every time x" thing that may be more annoying? Given at this point my app is only rolled out to a few users the number of devices isn't as useful for telling me which crashes to prioritize. In this screenshot I can tell two devices hit it. But did they only hit it once? Daily?
0
0
195
Dec ’24
TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION
Hello, we have received a crash report from AppStore connect / Xcode, TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION on an iPhone 12 Pro running iOS 18.1 (unfortunately, we don't know the user and how did they get the crash) The log mentions NSPhotoLibraryAddUsageDescription, but we are not using photo library in any shape or form, do we still need to include this key in Into.plist? And what do we put there? Thanks! Full log will not fit here, but here is a about half of it, with parts that mention crash (Thread 7), PhotoLibraryServicesCore, PHPerformChangesRequest determineAuthorizationStatusForChanges (Thread 4) and Binary Images, including /System/Library/Frameworks/Photos.framework/Photos /System/Library/PrivateFrameworks/PhotoLibraryServicesCore.framework/PhotoLibraryServicesCore (not sure why are they there) Incident Identifier: 5AFB7CCF-ECEC-40E1-AF71-02799924BC8C Distributor ID: com.apple.AppStore Hardware Model: iPhone13,3 Process: Polynomials [8291] Path: /private/var/containers/Bundle/Application/168A2A15-821B-414A-84B6-43C5184E5B59/Polynomials.app/Polynomials Identifier: com.graphmath.PolynomialsSbS Version: 5.1 (16) AppStoreTools: 16C5031b AppVariant: 1:iPhone13,3:18 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: com.graphmath.PolynomialsSbS [2383] Date/Time: 2024-12-10 05:23:26.6944 +0200 Launch Time: 2024-12-10 05:16:45.7989 +0200 OS Version: iPhone OS 18.1 (22B5069a) Release Type: Beta Baseband Version: 5.10.01 Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: TCC 0 This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data. Triggered by Thread: 7 ... Thread 3: ... 9 UIKitCore 0x000000018dac114c closure #2 in InProcessAnimationManager.startAdvancing(_:) + 156 (InProcessAnimationManager.swift:900) 10 UIKitCore 0x000000018d5cd118 thunk for @escaping @callee_guaranteed @Sendable () -> () + 36 (:0) 11 Foundation 0x00000001898296c8 NSThread__start + 724 (NSThread.m:991) 12 libsystem_pthread.dylib 0x000000021304937c _pthread_start + 136 (pthread.c:931) 13 libsystem_pthread.dylib 0x0000000213044494 thread_start + 8 Thread 4 name: Thread 4: 0 libsystem_kernel.dylib 0x00000001daf24604 semaphore_wait_trap + 8 1 libdispatch.dylib 0x000000019288466c _dispatch_sema4_wait + 28 (lock.c:139) 2 libdispatch.dylib 0x0000000192884d20 _dispatch_semaphore_wait_slow + 132 (semaphore.c:132) 3 PhotoLibraryServicesCore 0x00000001a37cde70 -[PLPrivacy _checkAuthStatusForPhotosAccessScope:preflightStatus:promptIfUnknown:resultHandler:] + 532 (PLPrivacy.m:554) 4 PhotoLibraryServicesCore 0x00000001a37cd9e0 __87-[PLPrivacy _isPhotosAccessAllowedWithScope:promptIfUnknown:synchronous:resultHandler:]_block_invoke + 240 (PLPrivacy.m:587) 5 libdispatch.dylib 0x00000001928840d0 _dispatch_client_callout + 20 (object.m:576) 6 libdispatch.dylib 0x0000000192893750 _dispatch_lane_barrier_sync_invoke_and_complete + 56 (queue.c:1104) 7 PhotoLibraryServicesCore 0x00000001a37c2c44 -[PLPrivacy _isPhotosAccessAllowedWithScope:promptIfUnknown:synchronous:resultHandler:] + 156 (PLPrivacy.m:582) 8 PhotoLibraryServicesCore 0x00000001a385af74 -[PLPrivacy checkPhotosAccessAllowedWithScope:] + 136 (PLPrivacy.m:608) 9 Photos 0x00000001a2b99854 -[PHPerformChangesRequest determineAuthorizationStatusForChanges] + 52 (PHPerformChangesRequest.m:417) 10 Photos 0x00000001a2c59a78 __102-[PHPhotoLibrary _performCancellableChanges:withInstrumentation:onExecutionContext:completionHandler:]_block_invoke + 80 (PHPhotoLibrary.m:2044) ... Thread 7 Crashed: 0 libsystem_kernel.dylib 0x00000001daf36ec4 __abort_with_payload + 8 1 libsystem_kernel.dylib 0x00000001daf56bec abort_with_payload_wrapper_internal + 104 (terminate_with_reason.c:102) 2 libsystem_kernel.dylib 0x00000001daf56c20 abort_with_payload + 16 (terminate_with_reason.c:124) 3 TCC 0x00000001ada4eb10 TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION + 172 (TCC.c:579) 4 TCC 0x00000001ada4a210 ___tcc_server_send_request_authorization_block_invoke_3 + 124 (tcc_server.c:322) 5 TCC 0x00000001ada4e230 __tccd_send_message_block_invoke + 624 (TCC.c:0) 6 libxpc.dylib 0x00000002130adc40 _xpc_connection_reply_callout + 116 (serializer.c:119) 7 libxpc.dylib 0x00000002130a0390 _xpc_connection_call_reply_async + 80 (connection.c:894) 8 libdispatch.dylib 0x0000000192884150 _dispatch_client_callout3 + 20 (object.m:602) 9 libdispatch.dylib 0x00000001928a1b2c _dispatch_mach_msg_async_reply_invoke + 340 (mach.c:3102) 10 libdispatch.dylib 0x0000000192896f98 _dispatch_root_queue_drain_deferred_item + 336 (queue.c:7291) 11 libdispatch.dylib 0x00000001928967cc _dispatch_kevent_worker_thread + 500 (queue.c:6764) 12 libsystem_pthread.dylib 0x0000000213047cb4 _pthread_wqthread + 344 (pthread.c:2702) 13 libsystem_pthread.dylib 0x0000000213044488 start_wqthread + 8 Binary Images: ... 0x1a2b1e000 - 0x1a2e98fff Photos arm64e <286e53b489dc3526809cde731d193edd> /System/Library/Frameworks/Photos.framework/Photos 0x1a37bf000 - 0x1a38d8fff PhotoLibraryServicesCore arm64e <2ef5261171363f638de0424b4a0ad257> /System/Library/PrivateFrameworks/PhotoLibraryServicesCore.framework/PhotoLibraryServicesCore 0x1ada46000 - 0x1ada5dff0 TCC arm64e <8d07479816c73b24a7cc13b7e3f6f361> /System/Library/PrivateFrameworks/TCC.framework/TCC 0x1d6b63000 - 0x1d6b6bfff GraphicsServices arm64e /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices ...
2
0
992
Dec ’24
WeatherKit in commandline app
I am trying to add WeatherKit support to a commandline app to fetch historical data. I've configured an app ID with the WeatherKit entitlement, but WeatherKit does not appear in the Capabilities list to add. When I try to access weather data, it fails with Code=4097 "connection to service named com.apple.weatherkit.authservice" suggesting it's not authorized. How do I add the WeatherKit entitlement to a commandline Swift app?
0
0
423
Dec ’24
EXC_BAD_ACCESS crash in some Swift Testing test on a macro
Hi, I'm trying to test a view model that conforms to ObservableObject with swift testing. My test looks like @Test("When a filter is selected the 'save search' button is enabled") func testWhenAFilterIsSelectedTheSaveButtonIsEnabled() { let viewModel = GxClassSearchFormViewModel( filterSelection: .init(), currentSavedSearch: nil ) // when viewModel.filterSelection.clubs.select(hasle) // then #expect(viewModel.savedSearchState == .active) #expect(viewModel.isSavedSearchButtonDisabled) } Interestingly, this test crashes on the iOS 16.2 Simulator. I'm using Version 16.2 (16C5032a) It crashes at the macro level like: And I don't understand what's wrong really. Maybe a concurrency issue? not sure. Xcode stops the execution and the debug navigator shows and incredibly long stack trace. I add images from the top and bottom of it as it's too long to add it all Has anyone experience a similar issue? It has happened to me in other tests too, sometimes when using #required
1
0
621
Dec ’24
Code coverage problem with symbolic linked source files
Let's say I have a local package Foo, Bar and Baz. Foo has Bar and Baz as dependency and has test target,FooTests. Below is the Package.swift manifest that describes package Foo. import PackageDescription let packages: [Package.Dependency] = [ .package(path: "../Bar"), .package(path: "../Baz"), ] let products: [Target.Dependency] = [ .product(name: "Bar", package: "Bar"), .product(name: "Baz", package: "Baz"), ] let package = Package( name: "Foo", platforms: [ .iOS(.v16), ], products: [ .library( name: "Foo", targets: ["Foo"] ), ], dependencies: packages, targets: [ .target( name: "Foo", dependencies: products, path: "Sources" ), .testTarget( name: "FooTests", dependencies: [.target(name: "Foo")], path: "Tests", swiftSettings: swiftSettings ), ] ) Bar and Baz is also local packages. Due to the limitations of the project, Baz has sources with symbolic links instead of exact directories, and these sources are what FooTests will test. If I run FooTests, test succeed with proper logs indicating that all test methods are run correctly, but test coverage says that Baz's coverage is 0% and there is no executable lines unlike the Bar which is not what be tested. Is there any way to fix this problem?
0
0
316
Dec ’24
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
Reality Composer Pro: Transform scale in cube material cannot accept decimal value
Hi guys, I have set size of cube is 20 cm. Then i want to transform scale with values x: 0.048, y: 1, z: 0.0.48, But strangely it reset all value to x: 1, y: 1, and z:1. Then i want to try with another decimal such as x: 1.2, y: 2, z: 1.2 the panel will automatically reset it into x: 1, y: 1, z: 1. My question is how to set transform scale that can accept decimal number ?
1
0
388
Dec ’24
Xcode 15 breakpoints not stopping on symbolicated code
I've recently installed Xcode Version 15.0 (15A240d) and when I set a breakpoint it doesn't stop on the line of code where the breakpoint is set. Rather, it opens another window with the hex code. If I press F6 it doesn't highlight the next line of code, but I can see that it moved because the variables are changing. Is this a known bug? I have tried all the usual stuff like deleting derived data and restarting everything. I have even deleted com.apple.dt.Xcode directory in ~/Library/Caches. to set things back to the defaults. The only thing I haven't done yet is reinstall Xcode. Unfortunately, this is very bad timing as I need to get my app finished for the iOS17 and WatchOS 10 release.
9
5
7.4k
Dec ’24
XCode 16.1 - React Native app will not compile
So I have a pretty old React Native app that I maintain. Think 6-7 years old and still using libraries from that time. One of the libraries I use is: react-native-job-queue and I cannot seem to get past this error no matter what switches I give the compiler: Command SwiftVerifyEmittedModuleInterface failed with a nonzero exit code I get this for another React Native library as well. No code has changed, nothing in the project has changed. It was just the XCode / iOS / MacOS upgrade that broke this. I've tried the following OTHER SWIFT FLAGS: -disable-interface-file-verification -no-verify-emitter-module-interface and others I'm probably forgetting. My .xcconfig has these: OTHER_SWIFT_FLAGS = $(inherited) -Xfrontend -disable-implicit-swift-modules -no-verify-emitter-module-interface SWIFT_VERIFY_EMITTED_MODULE_INTERFACE = NO SWIFT_EMIT_MODULE_INTERFACE_VERIFY=NO None of these actually stop the verifier so the compile fails every time. Any help is appreciated!!
1
1
732
Dec ’24
Error: Info.plist/Multiple commands produce
Background and Issue Details Currently, I am working on an Xcode project, and even after correctly setting up the Info.plist file, I am encountering build errors. Despite verifying all configurations related to Info.plist, the following errors persist during the build process: Error Messages 1、Multiple commands produce '/path/to/DerivedData/Info.plist' ・The error suggests that there might be a conflict or duplication of Info.plist in the Copy Bundle Resources phase, but only one Info.plist exists in the project. 2、duplicate output file ・A warning indicating that there is a conflict with the output file path for the Info.plist file during the build process. Steps Taken to Resolve the Issue 1、Verified Info.plist Files in the Project ・Checked the project directory for any duplicate Info.plist files using the following command: find . -name "*.plist" Only one Info.plist file exists in the project. ・Used the grep command to inspect the project.pbxproj file for INFOPLIST_FILE references: grep -r "INFOPLIST_FILE" ./MyProject.xcodeproj/project.pbxproj The INFOPLIST_FILE settings point to the correct Info.plist file. 2、Checked Copy Bundle Resources ・Verified the Copy Bundle Resources build phase and ensured that only one Info.plist file is listed. Deleting it results in the Target Membership checkbox being unchecked, and the error persists. 3、Cleared Cache ・Deleted DerivedData and Xcode cache directories to ensure no stale data is causing the issue: rm -rf ~/Library/Developer/Xcode/DerivedData rm -rf ~/Library/Caches/com.apple.dt.Xcode 4、Created a New Project ・Created a new project and set up a fresh Info.plist file with minimal content, but the same error occurred. Current Project Settings ・The contents of the Info.plist file are as follows: 5、Xcode Version ・The version of Xcode I'm using is 15.2 ・OS is Ventua13.7.1 Questions ・What could cause the Multiple commands produce and duplicate output file errors in this scenario? ・Are there any other settings or configurations I should investigate beyond the Info.plist file and build phases? ・Have there been similar cases reported by other developers, and what were the solutions? ・Could you provide a step-by-step guide to test the functionality of Info.plist in a minimal project while avoiding duplication errors? ・Is there an official or alternative workflow to create a project where Info.plist duplication errors are preemptively avoided? ・Additionally, what are the best practices for linking Info.plist in Build Settings and avoiding conflicts during the build process? Thank you.
2
0
608
Dec ’24