Compiler

RSS for tag

Discuss the various compiler and toolchain technologies used in development.

Posts under Compiler tag

113 Posts
Sort by:
Post marked as solved
4 Replies
352 Views
I have this code in a network extension: private func pathForToken(token: audit_token_t) -> String? { var tokenCopy = token let bufferSize = UInt32(4096) let bytes = UnsafeMutablePointer<UInt8>.allocate(capacity: Int(bufferSize)) let length = proc_pidpath_audittoken(&tokenCopy, bytes, bufferSize) if length != 0 { return String(cString: bytes).lowercased() } return nil } bytes appears to be leaked -- the call stack is pathForToken(token:) to specialized static UnsafeMutablePointer.allocate(capacity:) Do I need to do something to ensure bytes is released, since it doesn't seem to be happening on its own?
Posted
by kithrup.
Last updated
.
Post not yet marked as solved
0 Replies
296 Views
macOS Sonoma 14.4 Xcode 15.3 Hi, I'm experimenting with C++/Swift interop and am following the official documentation, especially the section "Using Swift APIs of Imported Framework Target". I'm able to call Swift code from C++ when both Swift and C++ source files belong to the same app bundle or framework target, by importing the -Swift.h header. However, I'm not able to import the Swift code from a framework using a different C++ target. This is my test project setup: testApp is my app bundle and subprocesses is my framework, containing the auto-generated and unchanged subprocesses.h and some example swift code with a single public function. The subprocesses framework is added as a dependency to testApp and the framework has the C++ interoperability enabled. But when I try to import the auto-generated -Swift.h in main.cpp, it doesn't show up. What do I need to do so that I can call Swift framework code in a different C++ target? I think I've done everything according to the documentation. Thanks! Addendum I've also experimented with Apple's Xcode example projects. The "Mixing Languages in an Xcode project" (Link) works as expected. I was able to add a command line app target, and when I add the Fibonacci framework as a dependency, I'm able to use #include <Fibonacci/Fibonacci-Swift.h> and access the Swift API. However, the second of Apple's examples, "Calling APIs Across Language Boundaries" (Link) fails to compile out of the box (No member named 'createForest' in 'ForestBuilder::MagicForest').
Posted
by wriker.
Last updated
.
Post not yet marked as solved
3 Replies
391 Views
I am developing an app which should run on Ipad, Iphone and Mac. From the app the user shall be able to press a button and copy a result (pure text) into the clipboard so it can be pasted into other apps on the same device (command + V). This works fairly well on my Ipad (or Iphone) where I use this (IOS) code: import SwiftUI import UniformTypeIdentifiers ..... UIPasteboard.general.setValue(output, forPasteboardType: UTType.plainText.identifier) .... The problem is that when I run this on "My Mac (Designed for iPad) - it does not copy the text when run on Mac as compatible iPad app. I take note that to access the clipboard on MacOS you would need another (MacOS) code like this. import Cocoa ... let pasteboard = NSPasteboard.general() pasteboard.declareTypes([NSPasteboardTypeString], owner: nil) pasteboard.setString(output, forType: NSPasteboardTypeString) .... The problem is that Cocoa can only be imported into native MacOS app - and while I recognise this could be handled with a lot of pre-processor statements separating native IOS and native MacOS code - it would highly complicate my code - and I would almost need to write the app twice just switching all the UI's to NS's. #if os(iOS) UIPasteboard.general.setValue(output, forPasteboardType: UTType.plainText.identifier) #elseif os(macOS) let pasteboard = NSPasteboard.general() pasteboard.declareTypes([NSPasteboardTypeString], owner: nil) pasteboard.setString(output, forType: NSPasteboardTypeString) #endif Even for the clipboard example it would start to complicate things. Then add to this that have have several references to other UI-classes which would be NS-classes on a MacOS. Can this be handled in a smarter way now we actually can run SwiftUI and IOS apps on a Mac???? I know one way could be to copy my output into a text-field from which the user could "Command + C" - but it is really not what I want. I hope there is something clean and smart for this - so we can assume that IOS apps can actually run on Mac with full compatibility. Thanks in advance
Posted
by Westerlin.
Last updated
.
Post not yet marked as solved
3 Replies
358 Views
My Mac will not run Xcode 15.3 which uses Swift 5.10. It will run Xcode 15.2 which uses Swift 5.9.2. The problem I am seeing is that Apple provides the language guide for Swift 5.10 but not the guide for Swift 5.9. Is this a real problem or am I over reacting, if not, where can I get and how do I install the reference guide for Swift 5.9 that will show up in Xcode
Posted
by lledsmar.
Last updated
.
Post not yet marked as solved
1 Replies
323 Views
Hello there, I'm struggling with the following issue since Xcode 15 arrived and haven't been able to solve it. I have a go library c-archive library which I'm using in a iOS app and build were OK until Sonoma updated came last year. I updated all my go libraries and go runtime to latest version and still facing issues: my make script as follows: ios-arm64: CGO_ENABLED=1 GOOS=ios GOARCH=arm64 SDK=iphoneos SDK_PATH=xcrun --sdk iphoneos --show-sdk-path CARCH="arm64" CC=$(PWD)/clangwrap.sh CGO_CFLAGS="-fembed-bitcode" go build -v -buildmode=c-archive -ldflags="-s -w" -gcflags=all="-l -B" -tags ios -o $(IOS_OUT)/btfs.a . If there is anything else you need I can share more details. Thanks!
Posted Last updated
.
Post not yet marked as solved
1 Replies
311 Views
What would be your recommendations for an online course for learning to use XCODE and planning a swift app ? After a law degree I've spent 40 years learning systems engineering. Mostly networking, some programming so I have the basics, but there are some absolute mysteries. My first app was a basic program for the //e a contact database we could save on tape before diks were avai.able. Now I'm stymied with some cryptic messages about not being able to create schema and I simple downloaded the new code and told it to create a new ios app.
Posted
by capwalker.
Last updated
.
Post marked as solved
5 Replies
574 Views
Hello, since the latest update of Xcode (Version 15.3 (15E204a)) and Simulator I have the following error message when trying to run my App: "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions." My App was running with Simulator and on my iPad without any problems with exactly the same code! A similar version is already running on TestFlight with nearly the same code. What can I do to make my App run again?
Posted
by Vestus.
Last updated
.
Post not yet marked as solved
1 Replies
282 Views
Hi. I'm trying to compile simple swift source file with stripping types metadata and names from it. I use these frontend flags: swiftc -O -Xfrontend -disable-reflection-names -Xfrontend -disable-reflection-metadata -Xfrontend -reflection-metadata-for-debugger-only -Xfrontend -disable-generic-metadata-prespecialization -gnone test.swift After compiling this test source file I still facing metadata and names in binary after dissembling it with Hopper. What I'm doing wrong? Please help.
Posted
by cbelkin.
Last updated
.
Post not yet marked as solved
4 Replies
476 Views
After upgrading to Xcode 15.3 (15E204a) trivial C++ code of mine no longer compiles: const string text = textComponent->GetText(); auto isEmpty = text.empty() || std::all_of(text.begin(), text.end(), std::isspace); now yields compiler error "No matching function for call to 'all_of'" while working as expected on Version 15.2 (15C500b) and older. Is there a regression in the latest Xcode update C++ support..? Thanks, Jay
Posted
by JayMcBee.
Last updated
.
Post not yet marked as solved
1 Replies
308 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 Last updated
.
Post not yet marked as solved
3 Replies
437 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 GeertB.
Last updated
.
Post not yet marked as solved
1 Replies
309 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 Last updated
.
Post not yet marked as solved
0 Replies
363 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 Last updated
.
Post not yet marked as solved
2 Replies
392 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 Last updated
.
Post not yet marked as solved
2 Replies
762 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 rmeanapa.
Last updated
.
Post not yet marked as solved
1 Replies
357 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 Last updated
.
Post not yet marked as solved
1 Replies
419 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 pajdox.
Last updated
.
Post marked as solved
5 Replies
556 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 Last updated
.