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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

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
842
Dec ’24
error: unknown type name 'CFAttributedStringRef'
OS ERROR] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTTypesetter.h:104:27: error: cannot combine with previous 'type-name' declaration specifier [OHOS ERROR] CFAttributedStringRef string ) CT_AVAILABLE(macos(10.5), ios(3.2), watchos(2.0), tvos(9.0)); [OHOS ERROR] ^ [OHOS ERROR] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTTypesetter.h:132:27: error: unknown type name 'string'; did you mean 'std::string'? [OHOS ERROR] CFAttributedStringRef string, [OHOS ERROR] ^ [OHOS ERROR] ../../prebuilts/clang/ohos/darwin-arm64/llvm/bin/../include/c++/v1/iosfwd:249:65: note: 'std::string' declared here [OHOS ERROR] typedef basic_string<char, char_traits, allocator > string; [OHOS ERROR] ^ [OHOS ERROR] In file included from ../../ide/tools/previewer/util/unix/ClipboardObjc.mm:18: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:15: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSAccessibilityColor.h:9: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSColor.h:46: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSApplication.h:10: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSResponder.h:10: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:10: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:39: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.h:26: [OHOS ERROR] In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTFramesetter.h:21: [OHOS ERROR] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTTypesetter.h:132:5: error: unknown type name 'CFAttributedStringRef'; did you mean 'NSAttributedStringKey'? [OHOS ERROR] CFAttributedStringRef string, [OHOS ERROR] ^ [OHOS ERROR] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:22:20: note: 'NSAttributedStringKey' declared here [OHOS ERROR] typedef NSString * NSAttributedStringKey NS_TYPED_EXTENSIBLE_ENUM; [OHOS ERROR] ^ [OHOS ERROR] In file included from ../../ide/tools/previewer/util/unix/ClipboardObjc.mm:18:
0
1
366
Sep ’24
Crash report from user unexpectedly looks like beta app
According to this page: https://developer.apple.com/documentation/xcode/interpreting-the-json-format-of-a-crash-report the storeInfo element of a JSON crash log may contain a deviceIdentifierForVendor element, but quote "This field is only present for TestFlight builds of an app". A user has just sent me a crash report which contains this key, but this isn't a testflight build. The suspicion is of course that the app is "cracked" in some way, but having interacted with the user for some time I think this is unlikely. He has had various issues with the app, affecting multiple devices; I have been wondering if there is something wrong with his Apple account. The docs also say that this "replaces the CrashReporter Key field", yet this crash report contains both. So my question for other developers: if you have any .ips crash logs, obtained from non-testflight users of your apps, please could you grep them for deviceIdentifierForVendor and let me know what you find. If any Apple people have any clues about how this could innocently end up in a crash report, please let me know. Maybe it's a documentation bug?
0
0
368
Dec ’24
How to: Add File... w/o moving nor copying that file
I have a number of utility functions/extensions in a .swift file at a central location. In Xcode 15, I used to be able to Add File... and uncheck the box that said COPY. The project would then have a REFERENCE to the file. I could make changes to the shared file and all projects that referenced that file would see the latest version. I don't see how to do that in Xcode 16. Add File... opens a dialog and the only options (in a drop-down) are Copy and Move -- neither of which I want to do. How do you make a reference in Xcode 16?
0
1
308
Sep ’24
Unable to export App via Jenkins pipeline
Hi Team, Exporting the archive through the Jenkins pipeline (executing commands on a Mac EC2 instance as a Jenkins agent) isn't working, while exporting directly from the Mac terminal successfully generates the IPA file. What might be the cause? When we execute it on directly Mac terminal, it asks Keychain password first time & after that it automatically generates IPA file. Note : We are using below working command to open keychain access. security unlock-keychain -p "my_password" /Users/ec2-user/Library/Keychains/login.keychain-db Export command : xcodebuild -exportArchive -archivePath $PWD/build/Archive/MyApp.xcarchive -exportPath $PWD/build/IPA -exportOptionsPlist ../../Dev_exportOptions.plist -allowProvisioningUpdates Current details: Node version : node-v18.17.0-darwin-arm64 Npm version : 9.6.7 Ionic version : 5.2.6 Xcode version : 15.4 Macos : Sonoma 14.6.1
0
0
502
Sep ’24
MacOS SDK fails to compile
I am trying to compile a program that uses the MacOS SDK and it fails to compile. I haven't found any information online. I have tried to compile with both the MacOS 14 and 15 SDKs and they both fail. I get errors such as In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:39: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.h:26: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTFramesetter.h:21: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTTypesetter.h:20: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTLine.h:138:5: error: unknown type name 'CFAttributedStringRef'; did you mean 'CFMutableStringRef'? CFAttributedStringRef attrString ) CT_AVAILABLE(macos(10.5), ios(3.2), watchos(2.0), tvos(9.0)); Here is the full output: https://pastebin.com/raw/XvMn6S2w
0
1
329
Sep ’24
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
417
Dec ’24
UI automation with iphone mirroring
My use case is to run UI automation on ios device in lab. To do that I have a iOS device connected to Mac. and My goal is to Run periodic UI automation on device Control iOS device via Mac To control the device, I enabled iphone mirroring (support added in MacOS 15 and ios 18.0 onwards) but for this device has to be locked. When I keep the iOS device locked, the APP UI contents are not available to Xcode. How to solve this? If I disable the mirroring, Xcode is able to read App content, but I can't control the device via Mac.
0
1
263
Oct ’24
ML model performance on iPhone test is always 0
Hi, Im using Xcode to test ML model performance. When I create a performance report on my Mac, I can get the performance report with prediction, load and Compilation time in ms. But when I tried to test the performance on iPhone16pro, although the test came to an end normally, but the prediction/load/compilation time are always 0, and there were no Compute Unit Mapping below. Thanks for your help.
0
0
294
Oct ’24
Xcode Doesn't recognises the git worktree version of the swift package
I'm building an iOS app using Xcode, and I frequently modify code within a package. To do this, I drag and drop a locally cloned version of the package into my project as a local package. However, when working across multiple branches of my app, I need different versions of the package as well. To achieve this, I use Git worktrees to create branch-specific copies of the package. Unfortunately, when I drag and drop these worktree copies into Xcode, the IDE doesn't seem to recognize them. Could you kindly guide me on resolving this?
0
0
243
Dec ’24
Unknown file type error in Xcode
Hello! I have been successfully building out my Xcode project in the past few months to my iPhone 15. I recently got a new iPhone 16 pro and have been having a hell of a time trying to figure out how to build to my new phone. Here's the error I am getting: Unknown file type in '/Users/username/Desktop/filename/Libraries/libiPhone-lib.a' please help! Any suggestions would be greatly appreciated. NOTE: I am using a M1 laptop with Sequoia OS
0
0
685
Oct ’24
Error 3002 running share sheet extension on local device
I'm debugging a change to my share sheet extension, which I published to the App Store several months ago. But I can't run it on my iPhone, attached to my MacBook. I know that I did this when I originally published it but some time has passed. The error that I get is "Failed to install the app on the device. Domain: com.apple.dt.CoreDeviceError Code: 3002 Failure Reason: The provided item to be installed is not of a type that CoreDevice recognizes." Does anyone know what would cause that? tia
0
1
521
Nov ’24
How to remove SMP as dependency stage for my Target in xcodebuild archive command
I have a xcworkspace with 2 targets: targetA and targetB. TargetA is dependent of the library that requires xCode 15.3. TargetB is a framework that I want to continue supporting on xCode 14.1 and is not dependent of any library at all. The problem occurs when I archive my TargetB via xcodebuild archive command on xCode 14.1. It doesn't build it due to Package.resolved error and requires me to use xCode 15.3 command line tools (for the dependency of TargetA). Is there a way to explicitly tell to xcodebuild archive command to ignore SPM for my TargetB?
0
0
154
Oct ’24
How to start and automatically update/end a local live activity?
I'm implementing a timer feature and facing the issue that the live activity I'm starting just continues showing after the timer is complete. The body of the live activity widget is more or less: ActivityConfiguration(for: WhendyWidgetAttributes.self) { context in VStack { Text( context.state.timerEndDate, style: .timer ) // if Date.now < timerEndTime { Text("Done") } self.expandedView(state: context.state) } } … Ideally I could get the activity to show something else when it is done but I don't know how to get it to re-evaluate it's body once the end time is reached. I create the activity with let activity = try ActivityKit.Activity.request( attributes: attributes, content: .init( state: .init(timerEndDate: timerEndDate), staleDate: timerEndDate ), pushType: nil ) Can I schedule the activity to do a refresh it's body (and reevaluating Date.now) once the timerEndDate is reached? Considered Approaches trying staleDate However, the activity never shows that it has become stale. Would it be expected that it shows the stale-ness? scheduling dismissal I also thought about starting and immediately stopping the activity with a delayed dismissal, but unfortunately it seems this is limited to a 4 hour window, and I'd like longer timers too. remote updates I understand I could use remote notifications to update the live activity, but I'd really like to keep things local as all the functionality is locally plannable. Background Tasks I understand these don't run reliably or at a predictable time. A Timer in the app that updates the content I think this would only update the activity while the app is in foreground.
0
0
506
Nov ’24
When AppEnum or AppEntity is introduced into the iOS18 Widget file, xcode compilation will report an error: Error collecting extracted types: The file “SmartPlusWidgetControl.swift” couldn’t be opened because the text encoding of its contents can’t b
When AppEnum or AppEntity is introduced into the iOS18 Widget file, xcode compilation will report an error: Error collecting extracted types: The file “SmartPlusWidgetControl.swift” couldn’t be opened because the text encoding of its contents can’t be determined.
0
0
199
Sep ’24
Xcode "Build For Testing" always returning x86_64 architecture for code coverage purposes
When using Xcode's "Build for Testing", I have noticed the resulting MyApp.xctestrun file has an array of CodeCoverageBuildableInfos. This array has all of our built targets. They all have an Architectures array property. For all of our targets this is set to x86_64 when we build for Any iOS Simulator. This is irrespective of what we have "ARCHS" and "ONLY_ACTIVE_ARCH" set to (in our case we only want arm64). We do have a number of local swift packages defined, each with their own test targets. We are using a test plan for these tests. This is causing issues when processing the resulting xcresult file since it is complaining that it can't find objects for the correct architecture when calculating code coverage. No object file for requested architecture No coverage data found. (Underlying Error: No object file for requested architecture)
0
0
533
Oct ’24