Compiler

RSS for tag

Discuss the various compiler and toolchain technologies used in development.

Posts under Compiler tag

100 Posts
Sort by:
Post not yet marked as solved
0 Replies
48 Views
I have an app that uses Swift 4.2. I am going to update the Swift Compiler Language to Swift 5. But I have some confusion after my test. I was able to run async/await code when using Xcode 15 with the version set to Swift 4.2, and it was okay. But async/await code was developed in Swift5.5. Why it is okay? Is it related to the Xocde Swift version? And if I use Swift Compiler version 4.2 to run async/await code,what problems might there be ?
Posted
by
Post not yet marked as solved
2 Replies
92 Views
I am having a problem with named captures when build with a Regex Builder. The following code is a simplistic example of the problem that works using an "ordinary" Regex. but when the same regular regex is created with a Regex Builder, it works when using group numbers, but it raises the following typing problem when using capture names (last lines) Cannot infer type of closure parameter 'm' without a type annotation // named captures and use with a Regex string to twiggle every alternate chars let pat = /(?P<a>.)(?P<b>.)/ "abcdef".replacing(pat,with:{m in "\(m.b)\(m.a)"}) // the same Regex but using a Regex Builder let a = Reference(Substring.self) let b = Reference(Substring.self) let patRB = Regex { Capture(as: a) {.any} Capture(as: b) {.any} } // OK when using capture group numbers "abcdef".replacing(patRB,with:{m in "\(m.2)\(m.1)"}) // compile error when using group names "abcdef".replacing(patRB,with:{m in "\(m.b)\(m.a)"}) The following shows the output strings in a Playground Any hints on what is wrong or on the correct way to add typing information to the closure. Thanks
Posted
by
Post not yet marked as solved
1 Replies
122 Views
I am trying to create a generic structure in my project and I am facing an issue where I get the error "Type 'any B' cannot conform to 'A'", where protocol B is derived from protocol A. I don't understand why such a structure is problematic and I would really appreciate any insight or alternative solution for this issue I am having. Issue: I have a general base protocol-class pair like the following. protocol A { } class AClass<T: A> { } To give an example of my use case, protocol A can be PresenterLogic where AClass is BaseInteractor. I have a second protocol-class pair which I want to specialize according to its use case. protocol B: A { } class BClass: AClass<B> { } // Here, I get "Type 'any B' cannot conform to 'A'" For example, protocol B being MyPresenterLogic and class BClass being MyInteractor. Specific Use-Case: To give a more specific use case, I am trying to build a VIP structure such as the following. // Base VIP (Ex: Interactor) protocol PresenterLogic { } class Interactor<PL: PresenterLogic>, BusinessLogic { var presenter: PL? } // VIP for Specific Screen (Ex: Interactor) protocol MyPresenterLogic: PresenterLogic { } class MyInteractor: Interactor<MyPresenterLogic> { // I don't want to declare a second `myPresenter: MyPresenterLogic` here } I don't want to declare another presenter instance in MyInteractor, (such as myPresenter: MyPresenterLogic. I want to be able to use the same presenter instance to be inferred to have the sub-protocol type. That is why I want to use generic classes, but I am stuck. I am searching if this is supported. Any insight is appreciated. Thank you.
Posted
by
Post not yet marked as solved
2 Replies
151 Views
I build an XCFramework in xcode 15.3 and install the framework in my example application. Everything is fine when I run the example app in xcode 15.3, but if I run the example app in xcode 15.2 I get this error: Undefined symbol: _swift_FORCE_LOAD$_swiftXPC Linker command failed with exit code 1 (use -v to see invocation) I made tests with different versions of XCode and differents versions of XCFramework compilation and only versions compiled in XCode 15.3 has problems Resume: App Xcode 15.3 -> Framework 15.3 -> :white_check_mark: App xcode 15.2 -> Framework 15.3 -> :x: App xcode 15.1 -> Framework 15.3 -> :x: App Xcode 15.3 -> Framework 15.2 -> :white_check_mark: App xcode 15.2 -> Framework 15.2 -> :white_check_mark: App xcode 15.1 -> Framework 15.2 -> :white_check_mark: App Xcode 15.3 -> Framework 15.1 -> :white_check_mark: App xcode 15.2 -> Framework 15.1 -> :white_check_mark: App xcode 15.1 -> Framework 15.1 -> :white_check_mark: Could it be a bug on xcode 15.3?
Post not yet marked as solved
1 Replies
158 Views
After updating our build server to Xcode 15.3, the frameworks (e.g. CCIeNewsNetworking) we build and release seems to reference SwiftUI. Our deployment target is iOS11. Customers have complained when running on iOS12: dyld: Library not loaded: /System/Library/Frameworks/SwiftUI.framework/SwiftUI Referenced from: /private/var/containers/Bundle/Application/81538A25-464A-46E0-BC4D-6E1C002C82F0/Test.app/Frameworks/CCIeNewsNetworking.framework/CCIeNewsNetworking Reason: image not found and I can see that "import SwiftUI" now appears in arm64-apple-ios.private.swiftinterface: diff CCIeNewsNetworking.xcframework-7.3*/ios-arm64/CCIeNewsNetworking.framework/Modules/CCIeNewsNetworking.swiftmodule/arm64-apple-ios.private.swiftinterface 2,4c2,3 < // swift-compiler-version: Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100) < // swift-module-flags: -target arm64-apple-ios11.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -module-name CCIeNewsNetworking < // swift-module-flags-ignorable: -enable-bare-slash-regex --- > // swift-compiler-version: Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) > // swift-module-flags: -target arm64-apple-ios11.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -enable-bare-slash-regex -module-name CCIeNewsNetworking 7a7 > import DeveloperToolsSupport 9a10 > import SwiftUI 12a14 > import _SwiftConcurrencyShims 217c219 < @objc public func removeOperation(issueIdentifer: Swift.String, fileName: Swift.String) --- > @objc public func removeOperation(issueIdentifier: Swift.String, fileName: Swift.String) I don't recall having changed anything in the project settings, so where does "import SwiftUI" come from, and how can I avoid it ?
Posted
by
Post not yet marked as solved
2 Replies
252 Views
I encountered a compilation issue when trying to use my SDK built in Xcode 15.3 with Xcode 15.2 for our app. According to Apple, Swift provides ABI Stability from Xcode 12.2 onwards, so we didn't face such issues before. Attached is the compilation error message for your reference. SDK is built with 'Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)', while this compiler is 'Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)')
Posted
by
Post marked as solved
4 Replies
212 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
Post not yet marked as solved
0 Replies
177 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
Post not yet marked as solved
3 Replies
264 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
Post not yet marked as solved
1 Replies
197 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
Post not yet marked as solved
3 Replies
222 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
Post not yet marked as solved
1 Replies
192 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
by
Post marked as solved
5 Replies
341 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
Post not yet marked as solved
1 Replies
197 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
Post not yet marked as solved
4 Replies
347 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
Post not yet marked as solved
1 Replies
213 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
229 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
249 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
330 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