Open abegehr opened 9 months ago
Vapor docker file for reference: https://github.com/vapor/template/blob/main/Dockerfile
hi i checked this issue mayube the reason could be related to the inability to find 'CFBooleanGetTypeID' and 'CFGetTypeID' in scope. These are Core Foundation functions in Swift, and the error indicates that the compiler cannot find them during the build process. check these SDK Version and Target Platform: Ensure that you are targeting an SDK version that includes the necessary Core Foundation frameworks. Sometimes, issues like this can arise if the SDK version is not compatible with the functions being used.
Importing CoreFoundation:
Make sure you have imported the CoreFoundation framework in your Swift files where these functions are used. You can add the following import statement at the top of the file:
try this
import CoreFoundation
Check Dependencies:
Verify that your project dependencies are correctly set up and that the versions of the libraries you are using are compatible with each other. It's possible that there is a version mismatch causing these symbols to be unavailable.
Compiler Flags: Ensure that your Swift compiler flags are set up correctly. The build command in your log shows some additional flags like '--static-swift-stdlib' and '-Xlinker -ljemalloc'. Make sure these flags are appropriate for your project.
Swift Version: Ensure that you are using a Swift version that is compatible with the libraries and dependencies you are using. Sometimes, certain functions may have been deprecated or changed in newer Swift versions.
Library Updates: If you are using third-party libraries, check if there are any updates available. The issue might be resolved in a newer version of the library.
if yu have any problem ask
Thanks for your answer, @kamleshboi69! I've tried simply importing CoreFoundation but that doesn't solve it yet. I've found this thread on the Swift forums that I'm researching now: https://forums.swift.org/t/static-linking-on-linux-in-swift-5-3-1/41989
I've tried running without the compiler flags, however no luck. It fails with the same fatal error.
I'm on the latest swift-version 5.9, which is also indicated on json-apple's Package.swift: // swift-tools-version: 5.9
Here is a cut out of my Package.swift
, showing the dependencies:
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "4.92.1"),
.package(url: "https://github.com/vapor/queues-redis-driver.git", from: "1.1.1"),
.package(url: "https://github.com/orlandos-nl/IkigaJSON.git", from: "2.2.1"),
.package(url: "https://github.com/shareup/json-apple.git", from: "1.4.0"),
],
=> all are updated to the latest version.
By the way, is this the proper way of adding json-apple to an executable target?
.executableTarget(
name: "App",
dependencies: [
.product(name: "Vapor", package: "vapor"),
.product(name: "QueuesRedisDriver", package: "queues-redis-driver"),
.product(name: "IkigaJSON", package: "IkigaJSON"),
.product(name: "JSON", package: "json-apple"),
]
),
I'm finding the definition of CFBooleanGetTypeId and CFGetTypeId in swift-corelibs-foundation: https://github.com/apple/swift-corelibs-foundation/blob/main/Sources/Foundation/NSNumber.swift However it fails when run on Linux. @kamleshboi69, do you have a sample of json-apple successfully compiling for Linux?
Through this thread: https://forums.swift.org/t/foundation-on-linux-cfbooleangettypeid-cfgettypeid/2736/14 I found this issue: https://github.com/apple/swift-corelibs-foundation/issues/4573 Which states: "2. The existing ways on Darwin that you might perform this coercion do not work on Glibc/Linux because they rely on CoreFoundation types/functions which do not exist (e.g., kCFBooleanTrue, kCFBooleanFalse, CFBooleanGetTypeID, CFGetTypeID, etc...)" EDIT: However, the issue has been fixed and as I linked to above the symbols exist in swift-corelibs-foundation.
I've setup a simple repro repo here: https://github.com/abegehr/json-apple-vapor
vapor new json-apple-vapor -n
docker build .
in the repo root directory.Fails with the same error:
1.922 [16/890] Compiling JSON Dictionary+JSON.swift
1.922 /build/.build/checkouts/json-apple/Sources/JSON/Dictionary+JSON.swift:73:9: error: cannot find 'CFBooleanGetTypeID' in scope
1.922 CFBooleanGetTypeID() == CFGetTypeID(self)
1.922 ^~~~~~~~~~~~~~~~~~
1.922 /build/.build/checkouts/json-apple/Sources/JSON/Dictionary+JSON.swift:73:33: error: cannot find 'CFGetTypeID' in scope
1.922 CFBooleanGetTypeID() == CFGetTypeID(self)
1.922 ^~~~~~~~~~~
1.922 /build/.build/checkouts/json-apple/Sources/JSON/JSON.swift:644:9: error: cannot find 'CFBooleanGetTypeID' in scope
1.922 CFBooleanGetTypeID() == CFGetTypeID(self)
1.922 ^~~~~~~~~~~~~~~~~~
1.922 /build/.build/checkouts/json-apple/Sources/JSON/JSON.swift:644:33: error: cannot find 'CFGetTypeID' in scope
1.922 CFBooleanGetTypeID() == CFGetTypeID(self)
1.922 ^~~~~~~~~~~
1.925 error: fatalError
I got the simple repro to work:
docker build ./
: https://github.com/abegehr/json-apple-vapor/commit/7716bee7b6ec167a9dc09469cc11c6fb038586be
However, I'm not sure why, since Foundation.swiftinterface imports CoreFoundation.swiftinterface.
The package looks great and is easy to use! However running on Linux as part of the vanilla Dockerfile for Vapor fails:
The referenced symbol is in swift-corelibs-foundation: https://github.com/apple/swift-corelibs-foundation/blob/dbca8c7ddcfd19f7f6f6e1b60fd3ee3f748e263c/CoreFoundation/Base.subproj/CFRuntime.c#L732