Compiler

RSS for tag

Discuss the various compiler and toolchain technologies used in development.

Posts under Compiler tag

106 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

SwiftUI: Command SwiftCompile failed with a nonzero exit code
I have a SwiftUI app that I've been working on in XCode 16.1. The project builds and runs in the simulators, on my mac and on my iPhone/iPad without any issues. I'm also able to build my unit test project and run them without any errors. The project has zero warnings in it. When I go to the Edit Schemes options and change the Run scheme to be a Release build with the Debug Executable unchecked I get a compiler error: Command SwiftCompile failed with a nonzero exit code I've attempted this Release Run with the following target devices in XCode: My iPhone 15 Pro Max (iOS 18.2 Beta 3) MacBook Air (M1) (15.2 Beta) iPhone 16 Simulator (iOS 18.1) Any iOS Simulator Device (arm64, x86_64) All 3 of these target have the same issue. Normally I would just debug the error from the logs but when I look at the build output I can't see any information in the log to tell me what happened. It looks like the source files are sent into the SwiftCompiler and the compiler fails without bubbling up the issue. I've provided the full error log export as a Gist HERE due to it's size. Is there anything in the log I'm missing? Is there a way for me to turn on more verbose logging during compilation of a Release Build? I created a brand new Multiplatform App in XCode and I added all of my source files to it. No project configuration settings were changed. I could build it successfully with the debug configuration. I then changed it to the Release configuration and experienced the same error. I can create another fresh project and make the same release configuration with none of my source files in it and get a successful build. I t seems there is something wrong with my source files and the release configuration but the compiler doesn't indicate what. I'm lost at this point as I can't figure out how to get a release build and can't seem to find any indication as to why.
1
0
49
1h
compilation error in CoreFoundation - visionos
when trying to build wireshark I'm getting the following, any idea how to solve it? [ 13%] Building C object wsutil/CMakeFiles/wsutil.dir/os_version_info.c.o In file included from wireshark/wsutil/os_version_info.c:23: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:54: /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:676:195: error: expected ',' 676 | void *CFAllocatorAllocateTyped(CFAllocatorRef allocator, CFIndex size, CFAllocatorTypeID descriptor, CFOptionFlags hint) API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0), visionos(2.0)); | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:679:211: error: expected ',' 679 | void *CFAllocatorReallocateTyped(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFAllocatorTypeID descriptor, CFOptionFlags hint) API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0), visionos(2.0)); | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:682:165: error: expected ',' 682 | void *CFAllocatorAllocateBytes(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0), visionos(2.0)); | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:685:181: error: expected ',' 685 | void *CFAllocatorReallocateBytes(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint) API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0), visionos(2.0)); | ^ In file included from wireshark/wsutil/os_version_info.c:23: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:73: /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNumberFormatter.h:144:147: error: expected ',' 144 | CF_EXPORT const CFNumberFormatterKey kCFNumberFormatterMinGroupingDigits API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0), visionos(2.0)); // CFNumber | ^ 5 errors generated. make[2]: *** [wsutil/CMakeFiles/wsutil.dir/os_version_info.c.o] Error 1 make[1]: *** [wsutil/CMakeFiles/wsutil.dir/all] Error 2 make: *** [all] Error 2
1
0
100
6d
Token is not a valid binary operator in a preprocessor subexpression
I have a relatively unique project layered with file types (top to bottom) SwiftUI, Swift, Objective C, and C. The purpose of this layering is that I have a C language firmware application framework for development of firmware on custom electronic boards. Specifically, I use the standard C preprocessor in specific ways to make data driven structures, not code. There are header files shared between the firmware project and the Xcode iPhone app to set things like the BLE protocol and communication command/reply protocols, etc. The app is forced to adhere to that defined by the firmware, rather than rely a design to get it right. The Objective C code is mainly to utilize the Bluetooth stack provided by iOS. I specifically use this approach to allow C files to be compiled. Normally, everything has worked perfectly, but a serious and obtuse problem just surfaced a couple days ago. My important project was created long ago. More recently, I started a new project using most of the same technology, but its project is newer. Ironically, it continues to work perfectly, but ironically the older project stopped working. (Talking about the Xcode iOS side.) Essentially, the Objective C handling of the C preprocessor is not fully adhering to the standard C preprocessing in one project. It's very confusing because there is no code change. It seems Xcode was updated, but looks like the project was not updated, accordingly? I'm guessing there is some setting that forces Objective C to adhere to the standard C preprocessor rules. I did see a gnu compiler version that did not get updated compared to the newer project, but updating that in the Build Settings did not fix the problem. The error is in the title: Token is not a valid binary operator in a preprocessor subexpression. The offending macro appears in a header file, included in several implementation files. Compiling a single implementation files isolates the issue somewhat. An implementation with no Objective C objects compiles just fine. If there are Objective C objects then I get the errors. Both cases include the same header. It seems like the Objective C compiler, being invoked, uses a different C preprocessor parser, rather than the standard. I guess I should mention the bridging header file where these headers exist, as well. The offending header with the problem macro appears as an error in the bridging header if a full build is initiated. Is there an option somewhere, that forces the Objective C compiler to honor the standard C processor? Note, one project seems to. #define BLE_SERVICE_BLANK( enumTag, uuid, serviceType ) #define BLE_CHARACTERISTIC_BLANK( enumTag, uuid, properties, readPerm, writePerm, value) #define BLE_SERVICE_ENUM_COUNTER( enumTag, uuid, serviceType) +1 #define BLE_CHARACTERISTIC_ENUM_COUNTER( enumTag, uuid, properties, readPerm, writePerm, value) +1 #if 0 BLE_SERVICE_LIST(BLE_SERVICE_ENUM_COUNTER, BLE_CHARACTERISTIC_BLANK) > 0 #define USING_BLE_SERVICE ... #if 0 BLE_SERVICE_LIST(BLE_SERVICE_BLANK, BLE_CHARACTERISTIC_ENUM_COUNTER) > 0 #define USING_BLE_CHARACTERISTIC ... token is not a valid binary operator in a preprocessor subexpression refers to the comparison. BLE_SERVICE_LIST() does a +1 for each item in the list. There is no further expansion. One counts services. The other counts characteristics. The errors are associated with the comparisons.
6
0
226
2w
XCode 16 clang++ compiler generates unexpected results for conditional checks at -O2 and -O3 optimization levels
Around a month back, developers of the OpenJDK project, when using XCode 16 to build the JDK started noticing odd failures when executing code which was compiled using the clang++ compiler shipped in that XCode 16 release (details in https://bugs.openjdk.org/browse/JDK-8340341). Specifically, a trivial for loop in a c++ code of the form: int limit = ... // method local variable for (i=0; i<limit; i++) { ... } ends up iterating more times than the specified limit. The "i<limit" returns true even when it should have returned false. In fact, debug log messages within the for loop of the form: fprintf(stderr, "parsing %d of %d, %d < % d == %s", i, limit, i, limit, (i<limit) ? "true" : "false"); would show output of the form: parsing 0 of 2, 0 < 2 == true parsing 1 of 2, 1 < 2 == true parsing 2 of 2, 2 < 2 == true Notice, how it entered the for loop even when 2 < 2 should have prevented it from entering it. Furthermore, notice the message says 2 < 2 == true (which clearly isn't right). This happens when that code is compiled with optimization level -O2 or -O3. The issue doesn't happen with -O1. I had reported this as an issue to Apple through feedback assistance, more than a month back. The feedback id is FB15162411. There hasn't been any response to it nor any indication that the issue has been noticed and can be reproduced (the steps to reproduce have been provided in that issue). In the meantime, more and more users are now running into this failure in JDK when using XCode 16. We haven't put any workaround in place (the only workaround we know of is using -O1 for the compilation of this file) because it isn't clear what exactly is causing this issue (other than the fact that it shows up with specific optimization levels). It's also unknown if this bug has wider impact. Would it be possible to check if FB15162411 is being looked into and any technical details on what's causing this? That would help us decide if it's OK to put in place a temporary workaround in the OpenJDK build and how long to maintain that workaround. For reference, this was reproduced on: clang++ --version Apple clang version 16.0.0 (clang-1600.0.26.3) Target: arm64-apple-darwin23.6.0 Thread model: posix InstalledDir: /xcode-16/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
12
0
492
4w
Build options in Xcode
I have a few questions on build options. Deployment post processing - is this for Mac apps? Or is it a setting for Xcode ? Does "Symbols hidden by default" set to yes enable symbolicated crash dumps? Can "Product name" and "Product module name" be different from bundleID component? Generate_Info_Plist is set to no. Will the Application Category value be reflected if there is no Info_plist file generated? I notice in my tests that the category is always wrong and defaults to team name. Privacy - GameKit Friend List Usage Description should this be yes or no if I am using Apple suggested privacy preserving scoped identifier gamePlayerID? Install Group/Permissions/Owner are these referring to setting in Dev environment or are these Mac App Only settings? ( I was not sure if iOS like Unix, has system users exposed at this high level anyway ) How do I export copy of existing build settings to a xconfig file? There was talk of a tool not sure if it is still available. For my TestFlight build for stress testing , what options would you recommend to help debug and trace easily ? Note I have tested the build with various Address Sanitizer, Memory Sanitizer, Guard malloc etc. options enabled to prep but haven't turned any of those on for the test build. Should I be enabling some? ( Some do not work together ) Alternately, if there is a document or video that addresses all of the above please let me know! Thanks in advance!!
2
0
190
4w
Xcode 16's clang : failure to recognise function type for static member function template in class template
Hello, It appears that clang version provided by Xcode 16 brings this compilation error seen in previous LLVM version : https://github.com/llvm/llvm-project/issues/91362 Fixed in : https://github.com/llvm/llvm-project/pull/90760 #include <type_traits> template <typename T> struct class_tmpl { template <bool B> static int call_e() { return 0; } template <bool B> static int call_ne() noexcept { return 0; } template <bool B> static int call() noexcept(std::is_nothrow_copy_assignable<T>::value) { return 0; } }; int main(int argc, char *argv[]) { using function_ptr = int (*)(); function_ptr f1 = &class_tmpl<int>::call_e<false>; function_ptr f2 = &class_tmpl<int>::call_ne<false>; function_ptr f3 = &class_tmpl<int>::call<false>; return 0; } $ clang -std=c++17 main.cpp main.cpp:15:24: error: address of overloaded function 'call' does not match required type 'int ()' 15 | function_ptr f3 = &class_tmpl<int>::call<false>; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:7:34: note: candidate template ignored: substitution failure [with B = false] 7 | template <bool B> static int call() noexcept(std::is_nothrow_copy_assignable<T>::value) { return 0; } | ^ 1 error generated. Compiler informations : clang --version Apple clang version 16.0.0 (clang-1600.0.26.3) Target: arm64-apple-darwin24.0.0
2
0
4.2k
Oct ’24
The compiler is unable to type-check this expression in reasonable time
This is one of the worst errors you can encounter while developing with Xcode. It looks like it's related to a problem inside the compiler itself: when there are lot of lines of code, it becomes unable to identify them all and start asking you to break down the code in smaller pieces. Sometimes you can, sometimes not. First of all, in your code there is FOR SURE an error, so in case of the second option, begin commenting entires sections of your code: this can lead to two options: You commented a section that contains the error: Xcode give you the preview and you check the commented section to find the error You commented enough code to let the compiler do its job, and you'll have the normal error reported in your code: again, fix it! Once errors have been fixed, normally you can uncomment what you excluded and all will go up and ok again. The most common errors that can lead to this behavior (but it's just a hint) are those involving parameters got or passed to other SwiftUI objects: parameters label (mistyped, missing, exceeding) parameters values (not $/& present, $/& present but not required) parameters types (you passed a wrong type) Well, I hope that this post could be useful to others that, like I did, are struggling a lot to understand the exact nature of this peculiar error. Code well and Prosper!
0
1
192
Oct ’24
Xcodecloud Xcodebuild Failed With Exit Code 70
I'm running on xcode 16, the project archives just fine on the local machine. However, with xcodecloud. It's running into exist code 70 on the following command xcodebuild -exportArchive -archivePath ..... #output Showing All Errors Only Build Archive Export archive for ad-hoc distribution Command exited with non-zero exit-code: 70 Command exited with non-zero exit-code: 70 Export archive for development distribution Command exited with non-zero exit-code: 70 Command exited with non-zero exit-code: 70 Export archive for app-store distribution Command exited with non-zero exit-code: 70 Command exited with non-zero exit-code: 70
5
1
467
Oct ’24
Undefined symbols for architecture x86_64:
I am developing a simple camera JNI interface program in Objc. I managed to compile. But I get the following link error. I use the following command. Is there anything I can add to solve this problem? Note that I use Intel MacMini. g++ -framework Foundation -framework AVFoundation CameraMacOS.m Undefined symbols for architecture x86_64: "_CMVideoFormatDescriptionGetDimensions", referenced from: _openCamera in CameraMacOS-517c44.o _listWebcamNamesAndSizes in CameraMacOS-517c44.o "_CVPixelBufferGetBaseAddress", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferGetBytesPerRow", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferGetHeight", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferGetWidth", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferLockBaseAddress", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferUnlockBaseAddress", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
2
0
307
Oct ’24
FCP Workflow extension does not build with clang unknown argument -e_ProExtensionMain in Xcode 16
With Xcode 16 I cant make the Final Cut Extension Workflow work. I am quite sure I was able to add the Workflow Extension target a couple of months ago in Xcode 15 and did successfully build it, but in Xcode 16 it wont build and it fails with this error: clang: error: unknown argument: '-e_ProExtensionMain' I have installed multiple times Workflow Extensions SDK 1.0.2 and even disabled Library validation like its described in the release notes but I dont think thats the problem here. Seems like clang doesn't have the arguments for it, I guess the SDK should add these but seems like something got messed up - the template shows up fine in Xcode. I reinstalled Xcode and command line tools but that didnt help. Checking clang it really doesnt have the argument. But where does the SDK add this? Xcode seems to be using internal clang and /usr/bin/clang doesn't have it either. Any tips what could be the problem here? I was not really able to locate the SDK to remove it before trying to install again - any ideas? Steps to reproduce Create new project Add FCP workflow extension target Build -> it fails Same behaviour with 16.1 Beta. I am running Sonoma 14.7. Thanks in advance for any ideas!
4
0
304
3w
Incremental build changes in Xcode 16?
Hi there! Was there a change in Xcode regarding incremental builds / updating an active Simulator with a new build? We use xcodebuild to manage our internal build framework and out of the sudden, incremental builds are not launched anymore and the Simulator is stuck waiting for the new build to be launched. This was not happening for the last 10+ years. If there is an xcodebuild flag and/or guide of this new behavior, it would help a lot. Thanks everyone!
0
0
238
Sep ’24
Xcode 16 Error AppShortcut phrases may have at most one parameter
I suppose this is a bug in compiler. Xcode 16.0 (16A242d) - AppStore release version When building a project from Xcode 15 in Xcode 16, an error occurs: appintentsmetadataprocessor[12633:13677489] error: At least one halting error produced during export. No AppIntents metadata have been exported and this target is not usable with AppIntents until errors are resolved. AppShortcut phrases may have at most one parameter, but found phrase, "Set Dark Mode ${darkMode} for Widget ${widget}" with more than one parameter: darkMode, widget Apparently this is an Xcode bug because I have a production app with this AppShortcut and it works fine in Apple Shortcuts. Everything is made according to the official WWDC video about AppShortcuts https://developer.apple.com/videos/play/wwdc2022/10170
0
1
308
Sep ’24
How to fix "Could not launch: xxxx Executable does not exist" error"
Hi i am currently using XCode 15 to build a Swift command line application. But when I try to build & debug my project, it throws an error saying that it could not launch the executable. It does build but as the error suggests, the Build dir does not have a executable in it. I have messed around with DerivedData & Build location settings for quite a bit with no luck. Currently both of them are at default settings as I cleared XCode caches from ~/Library/Caches & created a new project. I tried compiling the basic Hello World but that seems to "build" but with no executable. I have attached the report for the Could not launch error Error report Am i missing something with respect to build location / configuration? Thanks for any assistance.
2
0
2.6k
Sep ’24
Why is my #available ignored by the compiler? (Xcode 15.4)
Hi, I have a workspace with a couple of modules, and now I'm making a Swift package. It's great. However, i have this SwiftUI View extension you can see at the end of this post. My Swift package needs to have the target set to IOS16, so i have added #available where I need, like I've done in the past. When i had this extension in my Widget extension target, it worked fine. However, i am now trying to move that into my new Swift package, with the Swift package declaration you can also find below. When moved, i get an error from the compiler: Type 'ContainerBackgroundPlacement' has no member 'widget' It seems that my #available is ignored? I'm at a loss as to why this happens, so if anyone has any ideas i'm all ears. Otherwise guess i'll have to move it back to the Widget extension target :( My extension code: extension View { func widgetBackground(_ color: Color) -> some View { if #available(iOSApplicationExtension 17.0, *), #available(iOS 17.0, *) { return containerBackground(color, for: .widget) } else { return background(color) } } .....more stuff } Swift Package (i renamed and cropped some stuff for simplicity): import PackageDescription let package = Package( name: "MyPackage", platforms: [ .iOS(.v16) ], products: [ .library( name: "MyPackage", targets: ["MyPackage"] ) ], targets: [ .target( name: "MyPackage" ), .testTarget( name: "MyPackageTests", dependencies: ["MyPackage"] ) ] )
0
0
295
Sep ’24
modulemap for a framework that uses another framework's interface in its interface
I have an app that uses FrameworkA and FrameworkB. FrameworkA is simple, i.e., no dependencies. FrameworkB includes FrameworkA, which is normal. But it also uses pieces of FrameworkA's public interface in its own public interface. Yes, I find that a bit odd... (I didn't make those frameworks... just trying to sort out things...) Now I am trying to enable Xcode's module verifier for FrameworkB and the problem begins... FrameworkB can no longer have #import &lt;FrameworkA/FramworkASomethingSomething.h&gt; in its public headers. The modulemap file for FrameworkB currently looks like framework module FrameworkB { umbrella header "FrameworkB.h" export * module * { export * } } Is it possible still use FrameworkA's public interface in FrameworkB's public interface? And if yes, how is that sorted out in the modulemap? So far I have tried framework module FrameworkB { umbrella header "FrameworkB.h" export * module * { export * } link framework "FrameworkA" module FrameworkA [system] { umbrella header "FrameworkA.h" export * } } But it gives the error Umbrella header 'FrameworkA.h' not found Thanks!
0
0
264
Sep ’24
xcode not showing output
Hi I was using Xcode for c++ (for competitive programming purposes, not sure if this is the standard choice but using it anyway) I included a &lt;bits/stdc++.h&gt; to the include file for XCode.app and they didn't show any error. But then when I ran my code, it showed "Build Succeeded" although no output was visible.
1
0
371
Sep ’24
Compile error while compiling with MacOSX.SDK
When I was compiling with MacOSX.SDK, these error occurred /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/hfs/hfs_format.h:796:20: error: unknown type name 'uuid_string_t'; did you mean 'io_string_t'? char reserved[JIB_RESERVED_SIZE]; ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/hfs/hfs_format.h:787:61: note: expanded from macro 'JIB_RESERVED_SIZE' #define JIB_RESERVED_SIZE ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48) ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/device/device_types.h:89:33: note: 'io_string_t' declared here typedef char io_string_t[512]; I searched on the Internet and found the similar problem, it seems that there is something wrong with uuid.h. Actually, I do have this head file in my project directory. Anybody encountered with the same problem ? How to solve this problem?
2
0
386
Aug ’24
Could not build module 'UIKit' - XCode 16 Beta 3
I have an old project that combines Objective-C with Swift and it is compiling just fine in XCode 15 but is not compiling on XCode 16 Beta 3. There are multiple errors such as: "could not build module 'UIKit'" "could not build module 'CoreMedia'" "could not build module 'CoreLocation'" Among the errors there is this one about failing to emit precompiled header in the Bridging header file of the project. I've tried re-installing XCode 16 Beta 3, re-installing the simulator, restarting the computer and I've also created a sample project that also combines swift and Ojb-c and that one compiles just fine. Any clues? Thanks!
10
3
2.0k
Sep ’24