Build, 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

How can you communicate that a .xcframework is a dependency OF the swift package inside Swift package definition?
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?
0
0
50
Jun ’25
How to capture audio from the stream that's playing on the speakers?
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, &param, 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, &param, 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, &param, &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, &param ); 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, &param ); 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!}
1
0
75
Jun ’25
Binaries nested in frameworks - possible or not with iOS?
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.
1
0
67
Jun ’25
Authentication in UI tests
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.
0
0
46
Jun ’25
cannot find DeveloperDiskImage.dmg on iphone 18.5
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
3
0
72
Jun ’25
How can you have a framework which uses a 3rd party dependency and an app that uses the framework and also the same dependency?
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?
0
0
45
Jun ’25
Is it possible to embed dependencies within a .xcframework?
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?)
1
0
56
Jun ’25
CommandLineTools SDK error: conflicting types for 'MPG_PAYLOAD
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.
2
1
72
3w
Auto-Link Behavior Problem
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!
1
0
34
Jun ’25
Xcode #Playground fails
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.
2
0
90
Jun ’25
App Shortcuts - No Flexible Matching Assets
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!
0
0
66
Jun ’25
Unstable behavior of xcodebuild -showdestinations
Hi, I am having an issue with xcodebuild -showdestinations command. Steps to reproduce: Create a new iOS application project in Xcode or use an existing one. Navigate to this project in a terminal. Run xcodebuild -project 'your-project-name.xcodeproj' -scheme 'your-scheme' -showdestinations What I expect: All destinations available in the Xcode UI should be listed. What I get: It depends. For new projects, I consistently get only generic platform destinations and my connected physical device. When I run the same command on an older project, I sometimes see all the expected destinations. It seems to be a roughly 50/50 chance between the two outcomes. Is there a way to get consistent results from xcodebuild -showdestinations? What can I do to ensure all destinations are listed reliably? Here is a more detailed log and a screenshot: ❯ xcodebuild -workspace 'WorkoutDiary.xcworkspace' -scheme 'WorkoutDiary' -showdestinations Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace WorkoutDiary.xcworkspace -scheme WorkoutDiary -showdestinations User defaults from command line: IDEPackageSupportUseBuiltinSCM = YES 2025-06-17 19:13:50.261 xcodebuild[34753:6177985] DVTDeviceOperation: Encountered a build number "" that is incompatible with DVTBuildVersion. 2025-06-17 19:13:50.342 xcodebuild[34753:6177959] [MT] DVTDeviceOperation: Encountered a build number "" that is incompatible with DVTBuildVersion. Resolve Package Graph Resolved source packages: <REDACTED> Available destinations for the "WorkoutDiary" scheme: { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:<REDACTED>, name:My Mac } { platform:iOS, arch:arm64, id:<REDACTED>, name:<REDACTED> } { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device } { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device } ❯ xcodebuild -workspace 'WorkoutDiary.xcworkspace' -scheme 'WorkoutDiary' -showdestinations Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace WorkoutDiary.xcworkspace -scheme WorkoutDiary -showdestinations User defaults from command line: IDEPackageSupportUseBuiltinSCM = YES 2025-06-17 19:13:52.393 xcodebuild[34757:6178035] DVTDeviceOperation: Encountered a build number "" that is incompatible with DVTBuildVersion. 2025-06-17 19:13:52.472 xcodebuild[34757:6178020] [MT] DVTDeviceOperation: Encountered a build number "" that is incompatible with DVTBuildVersion. Resolve Package Graph Resolved source packages: <REDACTED> Available destinations for the "WorkoutDiary" scheme: { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:<REDACTED>, name:My Mac } { platform:iOS, arch:arm64, id:<REDACTED>, name:<REDACTED> } { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device } { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device } { platform:iOS Simulator, id:DBFB9613-0261-4544-908A-335570F3C35F, OS:18.3.1, name:iPhone 11 } { platform:iOS Simulator, id:A48C309C-231A-4197-A295-900F89C94D86, OS:18.3.1, name:iPhone 16 Pro Max }
2
0
150
Jun ’25
New AVCam sample code hanging in XCode 26 debugger
I am wondering if new AVCam sample code was tested before release. It hangs on startup on iPhone 14 pro running iOS 26 beta with the following logs on console: <<<< FigAudioSession(AV) >>>> audioSessionAVAudioSession_CopyMXSessionProperty signalled err=-19224 (kFigAudioSessionError_UnsupportedOperation) (getMXSessionProperty unsupported) at FigAudioSession_AVAudioSession.m:606 <<<< FigAudioSession(AV) >>>> audioSessionAVAudioSession_CopyMXSessionProperty signalled err=-19224 (kFigAudioSessionError_UnsupportedOperation) (getMXSessionProperty unsupported) at FigAudioSession_AVAudioSession.m:606 App is being debugged, do not track this hang Hang detected: 8.04s (debugger attached, not reporting)```
1
0
61
Jun ’25
Price in a Xcode synced StoreKit configuration file is not updated when I change it on App Store Connect and always shows the starting price
Hello, I've noticed the prices of my products in my Xcode synced StoreKit configuration are not updated when I change the price in App Store Connect. I tried to manually sync the file, to remove and add it again to my project but old initial prices are still used. In the screenshot below, the price is currently $2.99 but the file still uses the initial price of $1.99. It makes testing a little bit painful because I'm never sure which product is being shown. Is this a bug? Is there a way to get the live production App Store prices be used instead of the starting prices? I filed a feedback for this: FB17798486 Regards, Axel
0
1
48
Jun ’25
Using alternate app icons with Icon Composer
I've been messing around with converting my app icons to use Icon Composer. My app has multiple app icons, but I've noticed that I cant seem to set .icon files using the alternate app icon api. I believe this is due to the requirement that alternate app icons live in the Assets Catalogue but .icon files go anywhere in your project. Is there any plan to support this? Or am i missing something? I was able to successfully set a .icon file for the primary app icon.
3
3
97
1w