Is it possible to port Apple .frameworks files to Linux? - swift

I am trying to build a swift project on Linux which depends on CoreBluetooth.framework. It builds fine on OSX, but on Linux it gives me the following error
~/ReWork/.../DeviceManager.swift:10:8: error no such module 'CoreBluetooth'
import CoreBluetooth
^
I used Xcode to hunt around, and found the actual .framework file on my mac, which looks to contain a bunch of headers. Is it at all possible to put this on my linux box and point swift to it?

No. CoreBluetooth is a component of macOS, and is not available on Linux.

Related

Xcode macOS Development Target version and actual compatibility

I wrote a screensaver in Swift.
Although I had set the macOS Deployment Target to macOS 10.13, it failed to run on an x86_64 Mid 2010 Mac Pro running macOS High Sierra 10.13.6.
Meanwhile, it runs fine on my arm64 2020 MBP M1 with macOS Big Sur 11.5.2, and on an x86_64 2019 MacBook Air with macOS Catalina 10.15.6.
The screensaver installs fine on all machines, but on the machine running High Sierra it says that the screensaver is not compatible.
The error message shown is as follows ("vibe" is the name of the screensaver that I made. So anyone else running across this same problem will see a similar message but with the name of their own screensaver in place of that of course):
You cannot use the vibe screen saver with this version of macOS.
Please contact the vendor to get a newer version of the screen saver.
I am wondering if there is a way to automatically figure out if there are any APIs or other features that my code is using which were not available in macOS 10.13. And also I am wondering if it is usual that you can build for a given macOS Deployment Target and then when you try to run the program on a machine that is within the range that should be supported, the program will not run after all. I had thought that there would be a build time error to build for a macOS Deployment Target if the built program will not run on it.
I am using Xcode 12.5.1 running on my MBP M1, macOS 11.5.2, and as mentioned I am building for macOS Deployment Target set to macOS 10.13. The screensaver runs fine on both Intel with macOS 10.15 and ARM with macOS 11.5. I am using Swift Language Version Swift 5.
Solution
Install "Swift 5 Runtime Support for Command Line Tools" from https://support.apple.com/kb/dl1998?locale=en_US on the macOS 10.13 machine I wanted to run the screensaver on.
Background, details and alternative solution
Thanks to the comment of #Alexander, where he suggested:
Have you tried poking around Console.app to see if anything intersting was logged?
I was able to figure it out.
In Console.app, in the default view that shows device messages for the computer, I applied a search filter for any occurence of the name of the screensaver and then in System Preferences > Desktop & Screen Saver, I selected my screensaver and clicked "Preview" hoping that this would result in something in the logs. And it did!
Relevant log message:
Error loading /Users/erikn/Library/Screen Savers/vibe.saver/Contents/MacOS/vibe: dlopen(/Users/erikn/Library/Screen Savers/vibe.saver/Contents/MacOS/vibe, 265): Library not loaded: #rpath/libswiftCore.dylib
Referenced from: /Users/erikn/Library/Screen Savers/vibe.saver/Contents/MacOS/vibe
Reason: image not found
With this in hand, I was then able to find a similar root cause and some suggested solutions at dyld: Library not loaded: #rpath/libswiftCore.dylib / Image not found
Which amount to setting "Always Embed Swift Standard Libraries" to YES, and possibly also adding #executable_path/Frameworks to Runpath Search Paths.
This may be one acceptable way of doing it.
However, not knowing the specifics of how this will interact on other systems and in the future I was a bit hesitant.
Fortunately, I then found https://developer.apple.com/forums/thread/687847 which while not directly relevant directed me to look for "Swift 5 Runtime Support for Command Line Tools", as this would provide the missing libswiftCore.dylib for macOS 10.13.

Swift programming without using mac

I am new to mobile application development and I have decided to use Swift for iOS development but I don't want to buy a Mac , can I install macOS on another computer and start developing?
Thanks
If you want to get started with Swift programming this is also possible on Windows. There is an open source Swift Compiler for Windows. This is basically useful for learning Swift and possibly for writing desktop applications, e.g. using wxSwift, a binding from the portable GUI library wxWidgets to Swift. If you want to program mobile applications with Swift you'll end up with MacOS, but it can possibly be setup as a virtual machine or installed on a regular PC hardware. See also: https://learnappmaking.com/develop-ios-apps-on-windows-pc/
Of course, it is also possible to program Swift on Ubuntu Linux as officially supported by the Swift project. However, Xcode is not available for Linux, so it is basically useful to learn the language

Can't execute "swift test" in non-XCode Swift project

I'm beginning in Swift development (server side, no iOS). I have created the minimal package with swift package init and then swift build.
So far, so good. Now, when I run swift test, I get this error:
cannot load underlying module for 'XCTest'
I'm not using XCode, but just Visual Studio Code. How can I solve it? I have seen some solutions using XCode but I didn't found anything for "standalone" projects
Even if you're not using Xcode's editor, you still need the tools that come with it. Make sure you keep everything up-to-date, as the language is still evolving.

Swift on Mac terminal

Formerly I used FreeBSD and NetBSD. Mostly I code C on Command Line Interface (CLI) with vim editor.
Now I am using macOS. As I get used to CLI, so when I code swift on macOS, I opt console.
I've learned that I can also code swift on Mac Terminal without installing Xcode. I can compile or interpret and run simple Swift code on Terminal.
So my questions, does swift on Mac Terminal have full features as Xcode or not? Are all Swift libraries included in Mac Terminal?
You will have to install Xcode even if you don't plan to use it, because it installs the Swift toolchain.
On Linux you can install standalone Swift (and of course you can only access Linux libraries, not macOS or iOS ones) but in macOS you have to install via Xcode (but you don't have to use Xcode itself to write code).
See https://swift.org/getting-started/ and https://swift.org/download/#releases
Install xcode command line tools. Then in terminal, follow steps:
Step 1: Open Terminal
Step 2: Type "swift"
Now you can write swift code here. But better to use playground.

Eclipse gives storing device error

I'm trying to use Eclipse for J2ME development. I need to import a device from the "Device Management" menu. Whenever i try to import a device it gives me error. The error is: Error storing devices-Could not compile stylesheet. I'm using Eclipse 3.3.
It was because I use Windows in Turkish. It is something to do with language packages, i think. I changed my default language in Windows to English and the problem solved.