Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Compiler

RSS for tag

Discuss the various compiler and toolchain technologies used in development.

Posts under Compiler tag

67 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

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!
0
0
13
7h
Xcode-beta project ORSOFINAL: SwiftShims & C99 PCH errors after migration from Xcode stable
Hi all, I’m running into a persistent build issue with my Swift project ORSOFINAL after migrating from Xcode stable to Xcode-beta.app (June 2025 version). ⸻ 💥 Errors displayed: 1. C99 was enabled in PCH file but is currently disabled 2. module file .../ModuleCache.noindex/SwiftShims-AXUM98L131W4...pcm cannot be loaded due to a configuration mismatch with the current compilation 3. missing required module 'SwiftShims' ⸻ 🛠 What I’ve already tried: • xcode-select -s /Applications/Xcode-beta.app/Contents/Developer • Deleted ~/Library/Developer/Xcode/DerivedData, ModuleCache.noindex, Archives, and Products • Ran sudo xcodebuild -runFirstLaunch • Clean Build Folder in Xcode-beta • Verified Command Line Tools setting points to Xcode-beta ⸻ ❓Looking for guidance on: • Whether this is a known bug in Xcode-beta • If SwiftShims/PCM conflicts are expected between versions • Best practices to safely migrate from Xcode stable to beta for Swift-based projects Any advice is much appreciated. Thanks, Mathéo
1
0
35
1w
❗️Xcode-beta: “missing required module ‘SwiftShims’” and C99 PCH conflict
Hi all, I’m running into a persistent build issue with my Swift project ORSOFINAL after migrating from Xcode stable to Xcode-beta.app 26 (June 2025 version). ⸻ 💥 Errors displayed: 1. C99 was enabled in PCH file but is currently disabled 2. module file .../ModuleCache.noindex/SwiftShims-AXUM98L131W4...pcm cannot be loaded due to a configuration mismatch with the current compilation 3. missing required module 'SwiftShims' ⸻ 🛠 What I’ve already tried: • xcode-select -s /Applications/Xcode-beta.app/Contents/Developer • Deleted ~/Library/Developer/Xcode/DerivedData, ModuleCache.noindex, Archives, and Products • Ran sudo xcodebuild -runFirstLaunch • Clean Build Folder in Xcode-beta • Verified Command Line Tools setting points to Xcode-beta ⸻ ❓Looking for guidance on: • Whether this is a known bug in Xcode-beta • If SwiftShims/PCM conflicts are expected between versions • Best practices to safely migrate from Xcode stable to beta for Swift-based projects Any advice is much appreciated. Thanks, Mathéo
1
0
39
1w
Extract App Intents Metadata build error and SwiftConstValues files not being generated
Hello, We are reaching out to the official forum as an option to help us solve an issue we’re encountering with our app. The problem lies in the implementation of the AppIntents framework in our codebase, which, at the moment, is impossible to complete due to compilation errors occurring in specific targets of our app. We are currently using Xcode 16.0. First of all, we want to clarify that the integration of the AppIntents library poses no issues in our development targets (pre-production environments), since no additional code obfuscation steps are performed there. However, in the release targets used for production builds (those intended to be released to users), we encounter the following compilation error: These errors indicate that the “.swiftconstvalues” files are missing for all of the files in our application. We also want to highlight that we are using a code obfuscation tool called Arxan, provided by Digital.ai. This tool is integrated via specific Build Settings configurations, various files added to the project, and an additional Build Phase script. We have conducted the following tests: Disabling Arxan in release targets: The app compiles successfully and those files are generated (suspicious, I know). Adding a library with AppIntents references and an AppIntent in our app: Both scenarios produce the same compilation error. Creating a demo project with AppIntents and Arxan (basic implementation): The project compiles correctly and those files are in place. Contacting Digital.ai support: They suggested several changes to the Build Settings, but none of them resolved the issue. Additionally, we’ve attempted to gather information from the compiler to understand how these “.swiftconstvalues” files are generated. Unfortunately, we haven’t found any official documentation, so we would like to ask a few questions: Is it possible to interfere with the creation of these files in any way? For example, via scripts or other custom build steps? Is there any way to force the generation of these files through a build parameter or flag? Is it possible to bypass the “Extract App Intents Metadata” step during compilation? If so, what would be the implications of doing this when using a library that includes references to AppIntents? I know that involving a code obfuscation tool raises suspicions about it being the problem, we just want to know a little more about this compilation step to have some more context before reaching them again. Feel free to ask any questions or details, any reply is appreciated. Thanks
2
0
70
1w
Error in bnns.h - Missing ')'
Greetings! I have an app that builds ad runs just fine in XCode 11 on Catalina on an old Intel MBP. I've recently purchased an M3 Max machine and want to bring this app forward. Just going from XCode 11 to XCode 12 on the old machine, not even trying yet to up to XCode 14 or 15 on the new machine, I get two build errors that I have no idea how to resolve, both in bnns.h. I have not deliberately included this framework, and text search in my project and dependencies finds no incidence of "bnns" at all. These occur in the function prototypes for BNNSApplyMultiheadAttention and BNNSApplyMultiheadAttentionBackward. These prototypes look okay to me, and again I didn't deliberately invoke them in the first place. Does anybody have any idea how I can get past this roadblock? p.s. this is what the first prototype looks like; no unbalanced parens here (spacing edited for readability): int BNNSApplyMultiheadAttention(BNNSFilter F, size_t batch_size, void const* query, size_t query_stride, void const* key, size_t key_stride, BNNSNDArrayDescriptor const* _Nullable key_mask, size_t key_mask_stride, void const* value, size_t value_stride, void *output, size_t output_stride, BNNSNDArrayDescriptor const* _Nullable add_to_attention, size_t * _Nullable backprop_cache_size, void * _Nullable backprop_cache, size_t * _Nullable workspace_size, void * _Nullable workspace)
3
0
57
2w
Xcode does not see code changes in local Swift packages (autocomplete wrong, errors shown, but still compiles)
Hey, I've been having a lot of problems with Xcode 16 not seeing changes made to code in local Swift packages (the packages are inside the root directory of the project). Whenever I make any change like renaming a variable or type, or adding new methods or whatever, autocomplete doesn't see those changes and when I type in that new type/variable manually it gives me an error. However, building the project still works fine, even with the errors never going away. The only way for it to notice the code changes is to clean the project and build it again which takes a long time. At first, I thought this was connected to the new "Explicitly built modules" feature in Xcode 16, but I turned it off and it still happens. Any ideas what I can try? I'm on the latest Xcode version, but this problem has been happening since Xcode 16 originally came out. Thanks! Dennis
0
0
79
3w
Compiler stuck::considering giving up on SwiftUI
Apologies if this comes off as a bit of a rant, and TLDR: Compiler hangs or gives an unhelpful error with any level of complexity in SwiftUI - which makes me want to back to IB Porting a project over to iPhone. Made great progress the first week. However, lately I have been encountering compiler bugs where either the build never finishes, or the build take a really long time and ends with just the error : The compiler is unable to type-check this expression in reasonable time Sometimes I can get it to go away by playing divide and conquer and finding some small error, but other times with my nested scrollview it just seems unhappy with any level of complexity (and I don't think my views are all that complex compared to lots of other apps out there) I've read several posts on these forums for things to try and do to fix it but the bottom line is its impacting my ability to produce a working solution in a reasonable amount of time. So considering going back to Interface Builder though it means starting over with some of the code. If there was another independent way to syntax check my swiftUI code other than line by line myself I'd welcome something like that. The compiler going away and never coming back is very discouraging -- what if I have to make some kind of emergency fix in the future with limited time? Open for any suggestions. Xcode : 16.2
3
0
63
May ’25
Compiler - method linking issue.
Issue: During app execution, the intended method is not being called; instead, the method preceding (written above the intended method) is being executed. For Example: //In my case the ViewController class is at 3rd level of inheritance. class ViewController: UIViewController { func methodA() { print("methodA") } func methodB() { print("methodB") } } let vc = ViewController() vc.methodB() Output: //"methodA" Expected: //"methodB" Observations: Recent code changes have revealed that enabling the below Swift-6 flag leads to this linking issue. When this flag is commented out, the problem disappears. .enableUpcomingFeature("InternalImportsByDefault") Additionally, moving the intended method into an extension of the same class resolves the issue when the flag is enabled. Conclusion: To resolve the issue: Comment out the Swift-6 flag. Alternatively, move the method into an extension of the same class, which addresses the issue for this specific case. I had similar issue in other class where it crashes with message "method not found", but actually the method is there. When moving the method into an extension of same class resolve this issue. Any help is much appreciated. Thanking you..
2
0
55
May ’25
BUG IN CLIENT OF LIBMALLOC: memory corruption of free block
We've noticed a pretty common crash that's occurring in our app that appears to only be affecting iOS 18 users. The code in question is below: func getThing() async throws -&gt; ThingData { guard shouldRefresh, let data = self.thingData else { let remoteThingData = try await store.getThingData() self.thingData = remoteThingData return remoteThingData // Crash happens here } return data } The crash happens on a background thread and the actual crash is: Crashed: com.apple.root.user-initiated-qos.cooperative EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000004a67149c0 We haven't been able to reproduce the error ourselves but in the past 90 days all of the crashes (several thousand) have been only on iOS 18. We also found this thread that appears similar from 2 years ago but unsure if it's related because in our case the guard can only be calculated at runtime so there shouldn't be any optimizations happening.
1
1
497
Apr ’25
Code no longer builds "unsupported option for target"
A short while ago, I added: set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0 CACHE STRING "Minimum operating system version for deployment") to my top level CMake file. The code would not compile. So I removed the line and deleted the CMake cache and tried to rebuild. And for my pains I got this: c++: error: unsupported option '-mavx' for target 'arm64-apple-darwin24.4.0' c++: error: unsupported option '-mavx2' for target 'arm64-apple-darwin24.4.0' c++: error: unsupported option '-mfma' for target 'arm64-apple-darwin24.4.0' c++: error: unsupported option '-mssse3' for target 'arm64-apple-darwin24.4.0' This code was all compiled just fine up until this change, but now it just won't do so. Help!!! David
1
0
53
Apr ’25
Errors compiling C++ code for x86_64
I have a project (that uses pre-compiled headers) that uses different compiler options for SOME files. For those files I have this is in my CMakelists.txt: if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") set_source_files_properties(${AVX_Files} PROPERTIES COMPILE_OPTIONS "-mavx;-mavx2;-mfma;-mssse3;-msse4.2") set_source_files_properties(avx_simd_check.cpp PROPERTIES COMPILE_OPTIONS "-mxsave") endif() When I build for ARM, it all works :) When I try to build for X86_64, I get the following error for avx_simd_check.cpp: error: current translation unit is compiled with the target feature '+xsave' but the AST file was not 1 error generated. and for all the other files in question: error: current translation unit is compiled with the target feature '+avx' but the AST file was not error: current translation unit is compiled with the target feature '+avx2' but the AST file was not error: current translation unit is compiled with the target feature '+fma' but the AST file was not error: current translation unit is compiled with the target feature '+sse4.2' but the AST file was not error: current translation unit is compiled with the target feature '+ssse3' but the AST file was not 5 errors generated. How can I solve this please? David
3
0
39
Apr ’25
Unable to build c++ ios 18.4 headers with xcode 16.3
I have c++ enabled in my project and they build fine in Xcode 16.2. But now iOS SDK c++ files do not compile since “std::char_traits” support has been dropped from compiler during 16.3 update. This is the error I get: /Developer/SDKs/iPhoneOS18.4.sdk/usr/include/c++/v1/ios:543:64 Implicit instantiation of undefined template 'std::char_traits' At least these are broken, maybe more: ios.h basic_ostream.h string.h string_view.h This is rather annoying that Apple's own header files do not compile. Can't fix it by myself. Also other workarounds than downgrading to 16.2 are welcome. Feedback assistant: FB17183862
1
1
282
Apr ’25
Apple SDKs should provide libunwind_ext.h on macOS
(Copy pasted from FB17261080 that I submitted) Hi: Apple's SDK (libSystem.B.tbd) provides definition for multiple symbols(__unw_add_dynamic_fde / __unw_add_find_dynamic_unwind_sections ), but doesn't provide corresponding headers, available in LLVM upstream as libunwind_ext.h We need such headers to write Exception-Enabled JIT Framework for macOS
1
0
123
May ’25
Previews stopped working in Xcode 16.3 with baffling error message
Upgrading to Xcode 16.3, all previews across my AppKit project stopped working. The error message I'm getting is especially baffling. It says the project could not be built with incremental compilation because SWIFT_COMPILATION_MODE is set to "incremental": I tried clearing DerivedData with no effect. When I click the diagnostics button the information given is not very revealing, at least not to me. If I open the project in Xcode 16.2 everything works perfectly again. I switched over to Previews for all new code but this error situation is quite demotivating. Does anyone have any suggestions?
1
2
153
Apr ’25
Command line compilation problem, standard includes not found
This example fails to compile on Sequoia 15.4 with Xcode 16.3 and the command line tools installed; jacquesmenu@macstudio:C++Tests &gt; cat pcount_test.cpp // clang++ -std=c++17 -o IntWrapperTest IntWrapperTest.cpp #include // std::string #include // std::cout #include // std::ostringstream int main1 (int argc, char* argv[]) { std::string theString = "Prière d'éviter"; std::cout &lt;&lt; theString &lt;&lt; ", size(): " &lt;&lt; theString.size () &lt;&lt; std::endl; std::stringstream oss; oss &lt;&lt; theString &lt;&lt; std::endl; std::cout &lt;&lt; oss.str () &lt;&lt; ", pcount(): " &lt;&lt; oss.pcount () &lt;&lt; std::endl; } //_______________________________________________________________________________ // position in output stream #include // std::ofstream int main () { std::ofstream outfile; outfile.open ("test.txt"); outfile.write ("This is an apple",16); long pos = outfile.tellp(); outfile.seekp (pos-7); outfile.write (" sam",4); outfile.close(); return 0; } jacquesmenu@macstudio:C++Tests &gt; clang++ pcount_test.cpp pcount_test.cpp:3:10: fatal error: 'string' file not found 3 | #include // std::string | ^~~~~~~~ 1 error generated. The same occurs with iostrem if it is the first include mentioned. Compiling in Xcode itself does not this problem, though. This include is to be found here: jacquesmenu@macstudio:C++Tests &gt; xcode-select -p /Applications/Xcode.app/Contents/Developer jacquesmenu@macstudio:C++Tests &gt; ls -sal /Applications/Xcode.app/Contents/Developer/**/string | grep MacOSX 72 -rw-r--r-- 10 root wheel 203802 Mar 8 06:17 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string
3
0
55
Apr ’25
Xcode 16 Build & Archive Error - SPM
Since upgrading from Xcode 15 to 16, we have been experiencing a build error during compilation. Building on Xcode 15 still works with no issues. The error happens only on the first build after a clean. Subsequent builds succeed. This is an issue because our CI process archives the project from a clean slate, and this causes it to fail every time. I will attempt to describe the issue and include information I believe is relevant in this document. The error occurs on this import line within an Objective-C file during the Scan Dependencies step of compiling. This line imports our custom Objective-C to Swift bridging header file - "Swift2Objc.h". Our custom Objective-C to Swift bridging header file is simply wrapping the project’s auto-generated Objective-C to Swift bridging header file - "KWISwift.h". The error is specific to the import of the OfflineServices Swift Package. Specifically, the OfflineServices-Swift.h file - the Swift Package’s auto-generated Objective-C to Swift bridging file. Module JRE not found - the exact error (Also included as text on the bottom of the post) JRE is a third-party library provided to us as an xcframework. It is placed directly into our Swift Package as a binary target. The xcframework itself is composed of .a file and a Headers folder which includes header files and a module.modulemap. The module.modulemap file looks like this.
0
0
103
Mar ’25
Significant Performance Regression in Apple Clang 16 for Assembly File Processing
I've observed a significant performance regression in Apple Clang 16 (Xcode 16.0/16.2) compared to Clang 15 (Xcode 15.2) when processing flutter aot compilation. Further research shows that clang -cc1as process became extremely slow. The compilation time has increased by approximately 4x. Environment Machine: Apple M2 (8C8T) Memory: 16GB macOS Version: 14.7.2 Target: Flutter AOT compilation (snapshot_assembly.o) Performance Comparison Xcode Version iOS SDK Duration 15.2 17.2 1:08.90 15.2 18.2 1:03.98 16.2 17.2 4:11.07 16.2 18.2 4:08.43 16.0 18.2 4:29.32 Reproduction Steps The issue can be reproduced with the following command which is generated by flutter aot_assembly_release process: time ${xcode_app_path}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \ -arch arm64 \ -miphoneos-version-min=12.0 \ -v \ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.2.sdk \ -c ${project_path}/.dart_tool/flutter_build/f9ebf46f040933de7c8d103c84d38156/arm64/snapshot_assembly.S \ -o ${project_path}/.dart_tool/flutter_build/f9ebf46f040933de7c8d103c84d38156/arm64/snapshot_assembly.o Additional Information This issue specifically affects large assembly files generated by Flutter's AOT compilation The performance regression appears to be consistent across different iOS SDK versions The same assembly file compiles significantly faster with Xcode 15.2 Same performance regression observed on M4 Mac mini, suggesting this is not hardware-specific Size of object: size -m ${project_path}/.dart_tool/flutter_build/f9ebf46f040933de7c8d103c84d38156/arm64/snapshot_assembly.o Segment : 64577616 Section (__TEXT, __text): 26603344 Section (__DATA, __bss): 48 (zerofill) Section (__TEXT, __const): 21292928 Section (__DWARF, __debug_abbrev): 61 Section (__DWARF, __debug_info): 8934534 Section (__DWARF, __debug_line): 4464443 Section (__LD, __compact_unwind): 3282208 total 64577566 total 64577616 Questions Is this a known issue with Apple Clang 16? Are there any workarounds or compiler flags we can use to improve the performance? Is this behavior expected or should it be considered a regression? Any insights or suggestions would be greatly appreciated.
4
0
154
Apr ’25
XCode suddenly spending minutes running CLangStatCache
I've been using XCode for development in C++ for several years. Suddenly, today it started having the following problem: Any time I try to compile my code, (even if I just finished successfully compiling it), it spends several minutes running CLangStatCache. This is according to the result of "Perform Action... Build with Timing Summary". Furthermore, if I first delete the ".../DerivedData/SDKStatCaches.noindex" folder, the problem goes away and it compiles immediately. However, it creates a new folder with a 32 Mb file in it, and then has the same problem the next time unless I delete that folder again. I do not want to have to delete this file every time I compile my code. Is there some way to turn this off? What happened that is different today from any other day in the last several years? I did just download and install the latest System software update, including XCode... Did that break something?
1
0
36
Mar ’25
Add static c library to xcode/swift
Hi, I want to build an ios app that uses static c libraries. For reference, i did the following as a test: Compiled a simple c date and time program with clang -c -arch arm64 -sysroot <iPhoneOSSDK_path> date.c -o date_arm64.o Created the static lib ar rcs libdatetime_arm64.a date_arm64.o Added the lib in my Xcode project. Added the (.a) file in Build Rules -> Link Binary With Libraries Included the (.a) and (.h) file path in Build Settings -> Search Paths -> Header and Library Search Path Created a Bridging-Header.h file where I added #import "date.h" In my App.swift file, I called the function for getting the date and time let dateTimeStr = String(cString: get_current_datetime()) print("Current Date and Time: \(dateTimeStr)") After doing all the steps above, I am met with the error - Cannot find 'get_current_datetime' in scope Is there any other method to use static c libraries in xcode?
1
1
274
Mar ’25