How do I make std::string look like a char array? The expression viewer for std::strings is horrible.
Xcode
RSS for tagBuild, test, and submit your app using Xcode, Apple's integrated development environment.
Posts under Xcode tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Building my multiplatform target, works great for iOS, visionOS, MacOS.
tvOS builds fine, if I do not include any of the items in the .xcassets file.
I have attempted to add a second .xcassets file for just tvOS, but Xcode will not detect the second .xcassets if created manually, and will just "spin" when adding via the add file menu option.
If I add tvOS to the target membership for any of the .xcassets items (Xcode applies that target membership for ALL items in the .xcassets) we then we get the distill failed error.
The issue will sporadically be solved by removing the visionOS app icon from the .xcassets file and building that way, but it is not a perfect solution, as it does not work every time.
If there is a more targeted "membership options" that doesn't apply .xcassets wide, that would probably be the simplest solution.
I have my project running perfectly fine on Xcode 16. However, in Xcode 26 it doesn't build due to an error that I do not understand. I have three files that pertain to this error:
// FriendListResponse.swift
import Foundation
struct FriendListResponse: Decodable {
var friendships: [Friendship]
var collections: [FriendCollection]
}
// Friendship.swift
import Foundation
struct Friendship: Decodable {
var createdAt: String
var friendId: Int
var friendUserId: Int // user ID of the friend
var friendUsername: String
var id: Int
var tagNames: [String]
}
// FriendCollection.swift
struct FriendCollection: Decodable {
var id: Int
var permalink: String
var tagNames: [String]
var title: String
}
On the first file, FriendListResponse.swift, I am the simple error message "circular reference." I do not understand how these self-contained structs could create a circular reference. Although I have other data types in my project, none of them are even referenced in these files except for Friendship and FriendCollection.
The FriendListResponse is a struct that is created from JSON values that are fetched from an API. This is the function that fetches the JSON:
public static func listFriends(username: String) async throws -> [Friendship] {
let data = try await sendGETRequest(
url: "people/\(username)/friends/list.json"
)
print(String(data: data, encoding: .utf8)!)
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
let wrapper = try decoder.decode(FriendListResponse.self, from: data)
return wrapper.friendships
}
// Note: the function sendGETRequest is just
// a function that I have created that takes a set
// of parameters and returns a data object
// using the HTTP GET protocol. I don't think
// that it is related to this issue. However, if you
// think that it is, I can share the code for that.
This error has also happened in a few other cases within contained networks of my data structure.
I do not know why this error is only appearing once I launch Xcode 26 beta with my project files. I would think that this error also would appear in Xcode 16.4.
Any help would be greatly appreciated in my process to compile my project on Xcode 26!
I need to automate updating to latest iOS betas as part of my ci script, but I can't get it to install iOS 26.0 beta for the life of me, using xcodes or xcodebuild.
I can see the version listed using xcodes runtimes --include-betas, and I tried sudo xcodes runtimes install "iOS 26.0-beta1", but I would get the error
Downloading Runtime iOS 26.0-beta1: 0%
Error: ProcessExecutionError()\
I also tried xcodebuild -downloadPlatform iOS -buildVersion 23A5260l, where I found the specific build id on apples dev images website. But I would get the error
iOS 23A5260l is not available for download.
Specific version download failed, trying downloadPlatform ios latest...
And similar error for trying xcodebuild -downloadPlatform iOS -buildVersion 26.0 or other version ids I found online. But this command would work for any other versions and betas listed on the website.
I was able to install iOS 26.0 through xcodebuild -downloadPlatform iOS, which automatically installed it for me, but this is unideal for my situation, as I want to control which betas to install instead of just the latest one (like iOS 18.6 beta that just came out).
Is anyone else also struggling with these errors?
xcodes version 1.6.2 Xcode version 26.0 Beta (installed and selected through xcode)
Hi Apple Developer Community. I have a problem with opening my Xcode File in Xcode 16. It says, that a specific File is missing and I don't know how to resolve this. Can someone help me?
Thanks for the help :)
Using Xcode 26.0 beta (17A5241e)
Wanted to try out raw identifiers for Swift Testing tests, and while they work, syntax colorization is dreadful. Much less readable then just using a custom name with @Test.
Feedback: FB18260756
Example with a raw identifier of some example test name:
I am sort of trying to do the opposite of what others are doing. I have a target called CopyFramework that creates a CopyFramework.framework within my main xcproj file.
I set up this target because a specific framework (we can call it Tools.xcframework) is distributed as a binary. That framework file lives within the code.
Tools.xcframework is structured like so
Tools.xcframework (Coding/testBuild/DynamicToolFrameworks/Tools.xcframework)
info.plist
ios-arm64/
Tools.xcframework/
Tools (executable file)
Tools.bundle
Headers/
Info.plist
Modules/
Tools.swiftmodule/
arm64-apple-ios.abi.json
arm64-apple-ios.private.swiftinterface
arm64-apple-ios.swiftdoc
arm64-apple-ios.swiftinterface
module.modulemap
module.private.modulemap
PrivateHeaders/
ios-arm64_x86_64-simulator/
When the CopyFramework target is run xcode does a few steps which copy the correct version of this framework to derived data.
Process Tools.xcframework (iOS)
Coding/testBuild/DynamicToolFrameworks/Tools.xcframework
/Library/Developer/Xcode/DerivedData/testBuild-sha/Build/Products/Debug-iphoneos/Tools.framework ios
cd /Users/calebkierum/Coding/testBuild
builtin-process-xcframework --xcframework Coding/testBuild/DynamicToolFrameworks/Tools.xcframework --platform ios --target-path Library/Developer/Xcode/DerivedData/testBuild-sha/Build/Products/Debug-iphoneos
Meaning essentially that the Tools.xcframework for the proper platform is taken from Tools.xcframework/ios-arm64 and copied to Library/Developer/Xcode/DerivedData/testBuild-sha/Build/Products/Debug-iphoneos/Tools.xcframework
I am writing a Swift Package that needs to be able to reference the correct Tools.xcframework. I have set it up like so:
let package = Package(
name: "CoreObjC",
platforms: [.iOS(.v17), .macCatalyst(.v17)],
products: [
.library(name: "CoreObjC", targets: ["CoreObjC"]),
],
dependencies: [
// Does something to here ???
//.package(path: "../testBuild")
],
targets: [
.target(
name: "CoreObjC",
dependencies: [
// Here I would like to be referencing the CopyFramework.framework target within my buildTest.xcproj file
.product(name: "CopyFramework", package: /*??? its not in a swift package its a part of an xcproj file*/)
],
path: "CoreObjC",
publicHeadersPath: "Headers",
linkerSettings: [
.linkedFramework("Tools", .when(platforms: [.iOS])),
.linkedLibrary("c++")
]
),
],
cxxLanguageStandard: CXXLanguageStandard.gnucxx14
)
Now obviously this does not work. I do not know how to communicate to the Package.swift file that the binary dependency is a framework target within my xcproj file. If I do run the target CopyFramework followed by building CoreObjC it works though (so long as you comment out the bits trying to reference CopyFramework). Running the CopyFramework target processes the Tools.xcframework and copies the proper xcframework sub folder to Derived data and the Swift Package build system seems to be able to see it.
Is there a way I can get rid of this manual step? Make it so that when I build the CoreObjC target (swift package) that either CopyFramework is run or some other process is run to get the proper xcframework out of Coding/testBuild/DynamicToolFrameworks/Tools.xcframework and into DerivedData?
Is it even theoretically possible to have a Swift Package reference a target in a normal xcproj file?
This week I update from Xcode 16.0 to Xcode 16.4.
Today I realized, that the Menu item "New Group without Folder" does no more appear, when I press the option key.
I tried to find an answer with DuckDuch Go and Chat GPT, but without success.
Can anyone help me, how to fix that issue?
Thanks a lot.
Good day, ladies and gents.
I have an application that reads audio from the microphone. I'd like it to also be able to read from the Mac's audio output stream. (A bonus would be if it could detect when the Mac is playing music.)
I'd eventually be able to figure it out reading docs, but if someone can give a hint, I'd be very grateful, and would owe you the libation of your choice.
Here's the code used to set up the AudioUnit:
-(NSString*) configureAU
{
AudioComponent component = NULL;
AudioComponentDescription description;
OSStatus err = noErr;
UInt32 param;
AURenderCallbackStruct callback;
if( audioUnit ) { AudioComponentInstanceDispose( audioUnit ); audioUnit = NULL; } // was CloseComponent
// Open the AudioOutputUnit
description.componentType = kAudioUnitType_Output;
description.componentSubType = kAudioUnitSubType_HALOutput;
description.componentManufacturer = kAudioUnitManufacturer_Apple;
description.componentFlags = 0;
description.componentFlagsMask = 0;
if( component = AudioComponentFindNext( NULL, &description ) )
{
err = AudioComponentInstanceNew( component, &audioUnit );
if( err != noErr ) { audioUnit = NULL; return [ NSString stringWithFormat: @"Couldn't open AudioUnit component (ID=%d)", err] ; }
}
// Configure the AudioOutputUnit:
// You must enable the Audio Unit (AUHAL) for input and output for the same device.
// When using AudioUnitSetProperty the 4th parameter in the method refers to an AudioUnitElement.
// When using an AudioOutputUnit for input the element will be '1' and the output element will be '0'.
param = 1; // Enable input on the AUHAL
err = AudioUnitSetProperty( audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, ¶m, sizeof(UInt32) ); chkerr("Couldn't set first EnableIO prop (enable inpjt) (ID=%d)");
param = 0; // Disable output on the AUHAL
err = AudioUnitSetProperty( audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, ¶m, sizeof(UInt32) ); chkerr("Couldn't set second EnableIO property on the audio unit (disable ootpjt) (ID=%d)");
param = sizeof(AudioDeviceID); // Select the default input device
AudioObjectPropertyAddress OutputAddr = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
err = AudioObjectGetPropertyData( kAudioObjectSystemObject, &OutputAddr, 0, NULL, ¶m, &inputDeviceID );
chkerr("Couldn't get default input device (ID=%d)");
// Set the current device to the default input unit
err = AudioUnitSetProperty( audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &inputDeviceID, sizeof(AudioDeviceID) );
chkerr("Failed to hook up input device to our AudioUnit (ID=%d)");
callback.inputProc = AudioInputProc; // Setup render callback, to be called when the AUHAL has input data
callback.inputProcRefCon = self;
err = AudioUnitSetProperty( audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &callback, sizeof(AURenderCallbackStruct) );
chkerr("Could not install render callback on our AudioUnit (ID=%d)");
param = sizeof(AudioStreamBasicDescription); // get hardware device format
err = AudioUnitGetProperty( audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &deviceFormat, ¶m );
chkerr("Could not install render callback on our AudioUnit (ID=%d)");
audioChannels = MAX( deviceFormat.mChannelsPerFrame, 2 ); // Twiddle the format to our liking
actualOutputFormat.mChannelsPerFrame = audioChannels;
actualOutputFormat.mSampleRate = deviceFormat.mSampleRate;
actualOutputFormat.mFormatID = kAudioFormatLinearPCM;
actualOutputFormat.mFormatFlags = kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked | kAudioFormatFlagIsNonInterleaved;
if( actualOutputFormat.mFormatID == kAudioFormatLinearPCM && audioChannels == 1 )
actualOutputFormat.mFormatFlags &= ~kLinearPCMFormatFlagIsNonInterleaved;
#if __BIG_ENDIAN__
actualOutputFormat.mFormatFlags |= kAudioFormatFlagIsBigEndian;
#endif
actualOutputFormat.mBitsPerChannel = sizeof(Float32) * 8;
actualOutputFormat.mBytesPerFrame = actualOutputFormat.mBitsPerChannel / 8;
actualOutputFormat.mFramesPerPacket = 1;
actualOutputFormat.mBytesPerPacket = actualOutputFormat.mBytesPerFrame;
// Set the AudioOutputUnit output data format
err = AudioUnitSetProperty( audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &actualOutputFormat, sizeof(AudioStreamBasicDescription));
chkerr("Could not change the stream format of the output device (ID=%d)");
param = sizeof(UInt32); // Get the number of frames in the IO buffer(s)
err = AudioUnitGetProperty( audioUnit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, &audioSamples, ¶m );
chkerr("Could not determine audio sample size (ID=%d)");
err = AudioUnitInitialize( audioUnit ); // Initialize the AU
chkerr("Could not initialize the AudioUnit (ID=%d)");
// Allocate our audio buffers
audioBuffer = [self allocateAudioBufferListWithNumChannels: actualOutputFormat.mChannelsPerFrame size: audioSamples * actualOutputFormat.mBytesPerFrame];
if( audioBuffer == NULL ) { [ self cleanUp ]; return [NSString stringWithFormat: @"Could not allocate buffers for recording (ID=%d)", err]; }
return nil;
}
(...again, it would be nice to know if audio output is active and thereby choose the clean output stream over the noisy mic, but that would be a different chunk of code, and my main question may just be a quick edit to this chunk.)
Thanks for your attention! ==Dave
[p.s. if i get more than one useful answer, can i "Accept" more than one, to spread the credit around?]
{pps: of course, the code lines up prettier in a monospaced font!}
I'd like to determine, definitively, if nesting of "binaries" within other "binaries" is possible with iOS.
I put binaries in quotes because I've read documentation/forum posts stating things like nested frameworks isn't supported in iOS. A framework is a binary isn't it, or contains one. So does a statement such as that apply specifically and only to nested frameworks, or does it also apple to other scenarios - such as a SPM binary integrated into a framework?
Here's the specific scenario I'm seeking clarity on - suppose an SDK providing an API/functionality is built as an .xcframework and that SDK contains dependencies on two other components (Firebase, AlmoFire, RealmSwift, CocoaLumberjack, whatever etc.).
Lets say the SDK has two dependencies X and Y and it integrates them via SPM.
Q1: If there is an app A which integrates the SDK, and A doesn't use X and Y itself, then can X and Y be embedded within the SDK and thus opague to A? Is this possible in iOS?
Q2: If A integrates the SDK as above, but additionally, it itself uses X and Y independently of the SDK, then is this situation possible in iOS?
Presumably in Q1 the SDK needs to embed X and Y into the framework?
While presumably in Q2 it should not - because the app will be and hence that would lead to duplicate symbols and potential undefined behaviour (and therefore X and Y's SPM package spec needs to specify dynamic?)
I've been trying to get a clear picture of this for literally weeks and weeks, without reaching a clear conclusion.
So some definitive answer would be very much appreciated.
Hello! I am writing UI tests for an app with OAuth authentication and want to avoid the login screen. I want each developer to store the password and username locally on their machines. The bash script will get the token. I need to access that token from my test target somehow. The idea was to write them to a temporary file that git ignores and access this file from the bundle. But I can't add the file from the build script to the target and make it accessible from the code.
Delete me
I'm building and running from Xcode 26 to macOS 15.5. On launch, app crashes on start dynamic runtime linking with failure to find _LocationEssentials framework.
Hi,
I've an old mac book with old Xcode and my iphone is new 16 pro with 18.5. I've connected my iphone to my brother new mac book to copy his Xcode files from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/18.5 (22F76)"
that I'll be able to debug my application on my old Mac book. I succeeded to download Symbols folder and Info.plist. however there are missing
DeveloperDiskImage.dmg and
DeveloperDiskImage.dmg.signature
files.
Couldn't find them on my brothers machine.
Someone can help me understand why I cannot find them or provide the needed files for me to able to debug using my iphone?
Best regards and thanks in advance,
Chen
Is this setup possible / have a solution:
There is a .xcframework F, which uses a 3rd party library, lets call it L.
There is an app which uses the xcframework
The app also uses L
Both the app and F use SPM to integrate L
F is using L for its own internal purposes. F is providing some functionality to the app. How it implements that ideally should be a black box from the app's perspective.
The app also happens to use L for its own purposes.
I can't get this set up working, always get warnings about duplicate symbols when running the App.
This will presumably be due to the fact there are separate copies of L in both F and A.
So how can that be eliminated?
Can F not statically like to L and use the App's version of L at runtime? If so how can Xcode be configured so that F can actually compile?
Or vice versa - can the App not statically link in its own copy of L and use that in the framework? If so, similar questions, how to configure Xcode to set this up?
I can't believe this is an obscure use case, yet after days of searching and reading documentation I can't find any solution.
Note that I was able to get this going when the app and the framework used Cocoapods to integrate L, but I just can't do similarly if the use of Cocoapods is replaced with SMP.
When using cocoapods, within the frameworks Xcode section, the pods framework is set to Do Not Embed. This is probably the vital difference between the working Cocoapods implementation and the not working SPM solution. However, when using SPM Xcode doesn't present any option to either embed nor not embed the dependency. Why not? Can it somehow be set to not embed?
I'm creating a .xcframework in order to deliver an api/functionality to a customer for inclusion into an app.
I'm doing it as a .xcframework as I want it to be a binary so that the source code isn't accessable.
The xcframework has dependencies on modules which are installed via SPM (there are a few, an example is PhoneNumberKit)
When I build the xcframework and then add it to a test program and invoke its api then there's a run time error saying "PhoneNumberKit/resource_bundle_accessor.swift:44: Fatal error: unable to find bundle named PhoneNumberKit_PhoneNumberKit"
How can I build the xcframework so that its dependencies are included within it?
(Stepping back a bit, is an xcframework an appropriate approach for this?)
building gcc14-libgcc14 using Macports + Apple clang
returns following error
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/message.h:78,
from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/arm/thread_status.h:40,
from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/machine/thread_status.h:35,
from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach-o/loader.h:52,
from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach-o/dyld.h:30,
from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc14/libgcc14/work/gcc-14.2.0/libgcc/config/darwin-crt-tm.c:29:
/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/port.h:510:1: error: conflicting types for 'MPG_PAYLOAD'; have 'uint64_t(uint8_t, uint32_t, uint32_t)' {aka 'long long unsigned int(unsigned char, unsigned int, unsigned int)'}
510 | MPG_PAYLOAD(uint8_t flag, uint32_t a, uint32_t b)
| ^~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/port.h:498:1: note: previous definition of 'MPG_PAYLOAD' with type 'uint64_t(uint8_t, uint32_t)' {aka 'long long unsigned int(unsigned char, unsigned int)'}
498 | MPG_PAYLOAD(uint8_t flag, uint32_t a)
| ^~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/port.h:523:1: error: conflicting types for 'MPG_PAYLOAD'; have 'uint64_t(uint8_t, uint32_t, uint16_t, uint16_t)' {aka 'long long unsigned int(unsigned char, unsigned int, short unsigned int, short unsigned int)'}
523 | MPG_PAYLOAD(uint8_t flag, uint32_t a, uint16_t b, uint16_t c)
| ^~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/port.h:498:1: note: previous definition of 'MPG_PAYLOAD' with type 'uint64_t(uint8_t, uint32_t)' {aka 'long long unsigned int(unsigned char, unsigned int)'}
498 | MPG_PAYLOAD(uint8_t flag, uint32_t a)
libgcxx compiles fine
if forcing compile using clang20/clang19 there is no error.
Hi,
I encountered an issue in my code where I directly used #import <CoreHaptics/CoreHaptics.h> without adding it to the "Link Binary With Libraries" section under Build Phases. My deployment target is iOS 12, and the code was running fine before; however, after upgrading Xcode, the app crashes immediately on an iOS 12 device with the following error message: DYLD, Library not loaded: /System/Library/Frameworks/CoreHaptics.framework/CoreHaptics | xx | Reason: image not found.
Did Xcode modify the default auto-linking configuration? When did this behavior change in which version of Xcode? Do I need to specify CoreHaptics.framework as Optional in "Link Binary With Libraries"?
Thanks for reply soon!
I'm watching the session video "What's new in Xcode 26" and when I try out the new #Playground macro (in the context of a local package in my project) I see only this activity indicator for about 10-15 minutes:
Eventually I do see this error:
Despite the error, my local package does not import SwiftUI and has no dependencies other than Foundation.
I checked the Xcode 26 release notes and I don't see this issue mentioned.
A clean build of my project takes 55 seconds. Is it expected behavior that #Playground would require 10+ minutes to spin up?
Is there anything I can to do make the new #Playground macro work correctly?
Thank you.
My app uses App Intents to create App Shortcuts.
When I build and run my app in Xcode, the App Shortcuts Preview tool (under Product menu) shows the following message:
No Flexible Matching Assets
This target is for a platform which is not supported by Flexible Matching or does not have Flexible Matching enabled.
All of my project's targets are iPhone only with a minimum deployment of 18.0. In the build settings for this project, Enable App Shortcuts Flexible Matching is set to Yes. (build settings reference)
Any guidance on how to troubleshoot this? Thank you!
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
Xcode
Siri and Voice
Shortcuts
App Intents