For some reason when I try to run swift build
on my Package.swift
file:import PackageDescription
let package = Package(
name: "mobile-HDISegurado-ios",
dependencies: [
.package(url: "https://github.com/watson-developer-cloud/swift-sdk", from: "0.30.0"),
],
targets: [
.target(
name: "mobile-HDISegurado-ios",
dependencies: ["WatsonDeveloperCloud"],
path: "mobile-HDISegurado-ios",
exclude: [
"Config",
"Public",
"Resources",
]
)
] )
I've got the following error:
error: target at '.../mobile-HDISegurado-ios' contains mixed language source files; feature not supported
More details:
Are you building iOS project using SPM? Currently SPM doesn't have iOS support. Although, there is a 3rd party tool that fills that gap: https://swiftxcode.github.io/
If you're building for other else then you can't have Swift file and other C family language file mixed. I had the same problem because there was one Objective-C file inside my target path. All I did was to include the file name inside the exclude
array.
So, make sure to ignore Objective-C classes if you have one inside " mobile-HDISegurado-ios
" by passing the file name inside the exclude
parameter.
Also if you added Swift files in Objective-C project or workspace, but later removed all Swift files, Xcode still keeps some entries under Build Settings. Check for Swift related options there like line below:
If you remove those options, Xcode will not give error anymore, you can safely install your Package without any hassle.
Tested with:
Best.
SPM now supports mixed language source files, but you may have to separate them into multiple targets.
From the relevant docs :
Targets can contain Swift, Objective-C/C++, or C/C++ code, but an individual target can't mix Swift with C-family languages. For example, a Swift package can have two targets, one that contains Objective-C, Objective-C++, and C code, and a second one that contains Swift code.
In practice, you should move your ObjC/C/C++ files into one directory, move your Swift files into another directory, and then modify your Package.swift thus:
products: [
.library(
name: "MyLibrary",
targets: ["MyLibrary"]),
],
.target(name: "MyLibraryObjC",
path: "Sources/MyLibraryObjC"
),
.target(name: "MyLibrarySwift",
path: "Sources/MyLibrarySwift"
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.