Compiler

RSS for tag

Discuss the various compiler and toolchain technologies used in development.

Posts under Compiler tag

105 Posts
Sort by:
Post not yet marked as solved
1 Replies
272 Views
I have multiple Xcode versions installed on my system using the XcodesApp. Whenever I need to work with a specific Xcode version, I have to switch between them using the xcodes select command: xcodes select 14.3.1 # or 15.3, etc. After selecting the desired Xcode version, I use CMake to generate Ninja build files for my projects. However, having to switch Xcode versions manually every time is quite tedious and prevents me from concurrently building projects that require different Xcode versions. Is there an official or recommended way to configure CMake to use the appropriate Xcode toolchain (compilers, linkers, etc.) for each project without having to manually switch between Xcode versions? Ideally, I'd like to be able to specify the desired Xcode version when running CMake, and have it automatically use the corresponding toolchain for that version. I'm aware that one potential solution could be to create separate toolchain files for each Xcode version, specifying the paths to the compilers and other tools. However, I'm wondering if there's a more official or recommended approach from Apple or the CMake community. Any guidance or suggestions on how to achieve this would be greatly appreciated.
Posted
by
Post not yet marked as solved
1 Replies
273 Views
I want to conditionally add a delegate for only iOS (not VisionOS) This is where I assign a ViewController that is a delegate. The Framework below is not compatible with VisionOS. I get an error when I compile: "cannot assign ViewController to delegate FrameworkDelegate" #if os(iOS) //for iOS target use VC for delegate assignment self.framework.delegate = delVC #endif Here is where I have the ViewController header (ViewController.h) #if OS_TARGET_IOS #import "MyProject-Swift.h" //for iOS target use delegate @interface AttendanceViewController : UIViewController<FrameworkDelegate> #else //for VisioOS target, no delegate @interface AttendanceViewController : UIViewController #endif Even though I specify in both places that the framework is used for iOS, the compiler does not allow it to compile. Does objective-c complicate the matter? I like my library function in Swift!
Posted
by
Post not yet marked as solved
0 Replies
309 Views
Hello. I recently started digging into IOS development with flutter. I am using a MacBook Pro 2018 (intel) and one of my colleagues (with whom we are building an app) is using a very new Pro with M3 chip. We managed to setup, build and run our test app separately. So far so good. But once we started developing our own application, using Firebase and pushing to the same repo, we started having some issues - each time one of us delivers a podfile.lock file and/or Podfile, the other gets some build issues regarding Cocoapods. I started digging and as far as I understood there are differents in how CocoaPods is built depending of the chip - Intel or M. I also checked Cocoapods' documentation - it is suggested that pod files should be under source countrol. Well, okay, but how could we do that if we are using different laptops and that leads to constant build problems? I noticed that when I pull his changes, delete podfile.lock and run pod install, I am able to build the project. But this does not sound like a fix for this... I did not find any info anywhere, so all help would be highly appreciated! Thanks!
Posted
by
Post not yet marked as solved
3 Replies
395 Views
I'm trying to develop a mix-language (c++ and Swift) framework where calls are mainly from c++ -> Swift. However, I'm having problems with get Swift functions available in c++ when they take a c++ enum value as parameter. Assume the following c++ header: #pragma once enum class MyCppEnumClass { A, B, C }; enum class MyCppEnum { D, E, F }; and following Swift source file: public func swiftFunctionWithCppEnumClass(_ value: MyCppEnumClass) { print("Swift function with C++ enum: \(value)") } public func swiftFunctionWithCppEnum(_ value: MyCppEnum) { print("Swift function with C++ enum: \(value)") } The project compiles correctly this way, so the bridging of the enum types does work, making both the enum and enum class available in Swift. However, when inspecting the generated Swift header, I'm seeing this: namespace CxxInteropExperiments SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("CxxInteropExperiments") { // Unavailable in C++: Swift global function 'swiftFunctionWithCppEnum(_:)'. // Unavailable in C++: Swift global function 'swiftFunctionWithCppEnumClass(_:)'. } // namespace CxxInteropExperiments I can't find any information on swift.org (https://www.swift.org/documentation/cxx-interop/) that this would be unsupported. Currently the only solution I can find is to 'mirror' the enum with native Swift enum and implement a convert function in c++ like so: public enum MySwiftEnum { case A case B case C } public func swiftFunctionWithSwiftEnum(_ value: MySwiftEnum) { print("Swift function with Swift enum: \(value)") } #include <CxxInteropExperiments/CxxInteropExperiments-Swift.h> CxxInteropExperiments::MySwiftEnum convert(MyCppEnumClass e) { switch(e) { case MyCppEnumClass::A: return CxxInteropExperiments::MySwiftEnum::A(); case MyCppEnumClass::B: return CxxInteropExperiments::MySwiftEnum::B(); case MyCppEnumClass::C: return CxxInteropExperiments::MySwiftEnum::C(); } } void callSwiftFunctionWithEnum(MyCppEnumClass e) { CxxInteropExperiments::swiftFunctionWithSwiftEnum(convert(e)); } and not use c++ enum or enum classes in Swift function signatures that I want to be able to use in c++. Am I missing something obvious, or is passing c++ enum values directly to Swift functions just not possible? Any help is appreciated.
Posted
by
Post not yet marked as solved
1 Replies
348 Views
I am trying to run a python script which includes a wrapper for a c++ code. The script runs on a linux machine without any issues. When I compile the c++ part with make, it throws me this error: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__filesystem/path.h:446:1: fatal error: declaration of anonymous class must be a definition class _LIBCPP_EXPORTED_FROM_ABI path { ^ 1 error generated. Can anybody help me with fixing this? Thanks! I tried re-installing both the Command Line Tools and XCode but nothing seems to work. I do not have any anaconda/brew/ports installed.
Posted
by
Post not yet marked as solved
2 Replies
663 Views
I got this error when compiling a fortran code using the new version of CLToolkit 15.3 (with 15.1 I have no problems at all): In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/_stdio.h:68, from /usr/local/lib/gcc/aarch64-apple-darwin22.2.0/13.0.0/include-fixed/stdio.h:78, from /Users/meanapanedar2/programming/SIMPLE/src/jpg/stb_image.h:307, from /Users/meanapanedar2/programming/SIMPLE/src/jpg/stb_image_write.c:14: /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/sys/cdefs.h:554:30: error: missing ')' after "__has_attribute" 554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage) | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/sys/cdefs.h:554:31: error: ':' without preceding '?' 554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage) | ^ In file included from /usr/local/lib/gcc/aarch64-apple-darwin22.2.0/13.0.0/include-fixed/math.h:45, from /Users/meanapanedar2/programming/SIMPLE/src/ops/simple_kbinterpol_memo.c:2: /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/sys/cdefs.h:554:30: error: missing ')' after "__has_attribute" 554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage) | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/sys/cdefs.h:554:31: error: ':' without preceding '?' 554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage) | ^ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/ConditionalMacros.h:61, from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/MacTypes.h:41, from /Users/meanapanedar2/programming/SIMPLE/src/fileio/simple_posix.c:15: /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/TargetConditionals.h:140:50: error: missing binary operator before token "(" 140 | #if !defined(__has_extension) || !__has_extension(define_target_os_macros) | ^ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/sys/types.h:75, from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/MacTypes.h:48: /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/sys/cdefs.h:554:30: error: missing ')' after "__has_attribute" 554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage) | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/sys/cdefs.h:554:31: error: ':' without preceding '?' 554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage) | ^ [ 7%] Building Fortran object lib/CMakeFiles/SIMPLE3.0.0.dir/defs/simple_defs.f90.o [ 7%] Building Fortran object lib/CMakeFiles/SIMPLE3.0.0.dir/xml/fsys/fox_m_fsys_parse_input.F90.o make[2]: *** [lib/CMakeFiles/SIMPLE3.0.0.dir/ops/simple_kbinterpol_memo.c.o] Error 1 make[2]: *** Waiting for unfinished jobs.... [ 7%] Building Fortran object lib/CMakeFiles/SIMPLE3.0.0.dir/ops/json_parameters.f90.o [ 7%] Building Fortran object lib/CMakeFiles/SIMPLE3.0.0.dir/xml/fsys/fox_m_fsys_count_parse_input.F90.o [ 7%] Building Fortran object lib/CMakeFiles/SIMPLE3.0.0.dir/xml/fsys/fox_m_fsys_format.F90.o make[2]: *** [lib/CMakeFiles/SIMPLE3.0.0.dir/jpg/stb_image_write.c.o] Error 1 make[2]: *** [lib/CMakeFiles/SIMPLE3.0.0.dir/fileio/simple_posix.c.o] Error 1 make[1]: *** [lib/CMakeFiles/SIMPLE3.0.0.dir/all] Error 2 make: *** [all] Error 2
Posted
by
Post not yet marked as solved
1 Replies
328 Views
In the file InventoryManager when I return Inventory appears: Missing argument for parameter 'from' in call also in ContentView InventoryManager.swift import Foundation class InventoryManager { static let shared = InventoryManager() private let key = "inventory" func saveInventory(_ inventory: Inventory) { if let encoded = try? JSONEncoder().encode(inventory) { UserDefaults.standard.set(encoded, forKey: key) } } func loadInventory() -&gt; Inventory { if let data = UserDefaults.standard.data(forKey: key), let decoded = try? JSONDecoder().decode(Inventory.self, from: data) { return decoded } return Inventory() // &lt;-- HERE } } ContentView.swift import Foundation import SwiftUI struct ContentView: View { @State private var inventory: Inventory = Inventory() // &lt;-- HERE var body: some View { TabView { ... etc
Posted
by
Post not yet marked as solved
1 Replies
392 Views
I am developing a piece of software with OpenMPI and every time I recompile the program, I am prompted to click Allow/Deny the connections in N pop-ups (where N is the number of spawned processors by MPI). Is there any way to completely disable the pop-ups? When I allow or deny the access for one particular binary, the pop-ups do not show in successive runs. However, after recompiling a new one, the issue persists. Turning off the firewall does not help, neither does allowing/blocking incoming connections in the Firewall settings (Settings -> Firewall -> Options). I am open to any hacky solution or a workaround as this is really annoying and deteriorates my workflow.
Posted
by
Post marked as solved
5 Replies
515 Views
Hello guys this is my first time trying to publish an App on iOS. I am using Xcode version 13.0 beta I am getting this Semantic Issue error while archiving the build. if (@available(iOS 15.0, tvOS 15.0, *)) _displayLink.preferredFrameRateRange = CAFrameRateRangeMake(targetFPS, targetFPS, targetFPS); You can check the image.
Posted
by
Post not yet marked as solved
1 Replies
490 Views
I've been using a code that pass -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ during compilation. The code was compiling well for a while. I haven't been using that project for a while, but recently found out that my project start failing to build with errors: In file included from my_project/main_app.cpp:52: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/mach_time.h:32: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/mach_types.h:109: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/vm_region.h:47: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/machine/vm_param.h:33: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/i386/vm_param.h:97: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/vm_page_size.h:59:44: error: expected ';' after top level declarator extern vm_size_t vm_kernel_page_size __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0); My /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h file contains #ifdef __IPHONE_OS_VERSION_MIN_REQUIRED ... #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) ... #else #define __OSX_AVAILABLE_STARTING(_osx, _ios) #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) #endif but the last #else case is never hit because /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h contains: #ifndef __MAC_OS_X_VERSION_MIN_REQUIRED #if defined(__has_builtin) && __has_builtin(__is_target_os) #if __is_target_os(macos) #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_2 #endif #elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_2 #endif /* __has_builtin(__is_target_os) && __is_target_os(macos) */ #endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */ So in combination with my initial -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ option the #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ produce an empty define. So the question to apple developers: could you please update #elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ to #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)? Or even change #ifndef __MAC_OS_X_VERSION_MIN_REQUIRED to #if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)? Otherwise the #else case in Availability.h described above does not make any sense. Best regards, Petro
Posted
by
Post not yet marked as solved
1 Replies
407 Views
I have implemented the new cpp-swift interop mechanism using modulemap file. I have a use case to pass a swift string to the cpp function. I observed that the below code works and I am able to pass a swift String type directly to a cpp function which received it as const char *. This works only if its received as const char * in cpp(and not char *). However, this is not an interop documented behaviour for interoperating String types and wanted to know whether this is safe to use. If not, can someone suggest an alternative approach to pass a swift string to Cpp. // Swift code public static func StringToCharPointer () -&gt; Void { // calling cpp function and passing a swift String type as argument, which is received as const char * Student.Convert (sUItextdata) //sUItextdata is of type 'String' } //static Cpp function void Student::Convert (const char * pStr) { std::string s(pStr); std::cout &lt;&lt; "char * converted from swift String : " &lt;&lt; s &lt;&lt; std::endl; } Note : I am aware that there is a way to pass it to cpp and receive it as std:string, but I do not wish to use that.
Posted
by
Post not yet marked as solved
0 Replies
512 Views
Hello, I am a new user with an Apple MacBook Pro. I'm experiencing difficulties running my code through the GPU. What do I need to install on my computer to be able to use libraries for machine learning, Computer Vision, PyTorch and Tensor Flow? I already watch lot of tutorials on this subject, but still is looks very complicated and I need mentoring for this task. I would greatly appreciate it if I could receive a response and if someone could guide me on this matter.
Posted
by
Post not yet marked as solved
1 Replies
404 Views
I have a project implementing new interop mechanism and I m able to successfully invoke swift class method directly from swift. However, when I try to invoke the swift extension method it produces an error : No member named 'GetExtData' in 'InteropExtension::SwiftCode' Below is my cpp code: #include "CppSource.hpp" #include "InteropExtension-Swift.h" void CppSource::CppToSwiftCall() { // successfull call InteropExtension::SwiftCode::GetClassData(); //Below call is causing error. Why is swift extension method not invoked? InteropExtension::SwiftCode::GetExtData(); } Below is my swift code: import Foundation public class SwiftCode { public static func GetClassData () -&gt; String { return "classMethod" } } extension SwiftCode { public static func GetExtData () -&gt; String { return "ExtMethod" } } Can someone helpout on why is the extension methods not being invoked, and how can I invoke it?
Posted
by
Post not yet marked as solved
3 Replies
479 Views
I'm encountering an **error Segmentation fault: 11 ** during the archiving process. If the issue is happing with the my code. Then how can I diagnosing the problem. or figure out pin point in code base? I changed the compiler optimization level. It works for me when I use the Osize compiler optimization level. Previously, it was set to Ospeed. Want to know about the impact of the Osize compiler optimization level on the app.
Posted
by
Post not yet marked as solved
1 Replies
477 Views
I am now using the fortran compiler to compile the codes with the command of "make -f Makefile". In the previous time, the command: make -f Makefile works well, but after updating the MacOS system, the same command results in the following error: -macosx_version_min has been renamed to -macos_version_min ld: unknown options: -commons collect2: error:ld returns 1 Is there anyone know how to solve the above problem? Thanks a lot for your time and help.
Posted
by
Post not yet marked as solved
0 Replies
366 Views
We are having a setup , where we generates .app file from our iOS project using this command xcodebuild -scheme MyApp -project ./MyApp.xcodeproj -configuration Release\ (Development) -derivedDataPath build/derived_data -destination 'generic/platform=iOS' -archivePath build/MyApp.xcarchive archive which is work fine. but we have a new library that uses new swift Macros, that we can’t anymore use this command without errors. so we switched to -destination 'platform=iOS Simulator,name=iPhone' now it compile fine. but when adding the .app file to simulator , it just crash the app. is there a better way to generate such file that can work on simulator without try to enforce x86_64. cause it seems that macros are not supporting that.
Posted
by
Post marked as solved
2 Replies
325 Views
Does Swift has the syntax that lets me get the default value of a template type T, like below: struct VarLock&lt;T&gt; { private var v = default(T) // or T() }
Posted
by
Post marked as solved
1 Replies
358 Views
I know this is a frequently asked question, but... After reading many articles on the net, I am still not sure if I have a solid understanding of the logics behind the design. One of my puzzles around this question is - Is the Swift compiler clever enough so that I can solely rely on its warnings/errors?
Posted
by
Post not yet marked as solved
0 Replies
476 Views
Hi, I'm having problems with extremely build and compilation of software in the command line and I'm not sure why. I'm currently using macOS Sonoma 14.3 on my 2020 MacBook Air 1.1 GHz Quad-Core Intel Core i5. I also have the latest version of Xcode installed. Although I've been experiencing extreme delays in the command line for a while, the problem really became noticeable after I updated my OS to Sonoma. It meant that all the software I had installed via command line that I regularly use became outdated and now I cannot build it again. I've spoken in depth with the authors of the software and they have tried on a system identical to mine and have a build time of 30 minutes, but my machine takes over 3 hours on the same software. I've uninstalled and reinstalled command line tools several times but nothing seems to work. Also when I build I use the command make -j7 to use 7/8 cores so the problem isn't that I'm making full use of my CPU either. I've spoken to Apple support who recommended I try in Safe Mode and using a different user to rule out background software that opens on start up and decreases performance, as well as to rule out the setup on my main user. I'm just not sure what to do anymore as I've been trying for days and to no avail. Does anyone have any suggestions? P.S. It may be irrelevant, but since Sonoma I've also been experiencing a lot of issues with clang and also SDK pathways.
Posted
by