Swift package has bitcode disabled - ios

I created a really simple Swift package, that contain only a few Objective-C source files, but when I try to build another project that it, it fail compiling because:
ld: bitcode bundle could not be generated because 'MySwiftPackage.o' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build file 'MySwiftPackage.o' for architecture arm64
I also tried to force Bitcode to be enable by adding settings:
cSettings: [.define("OTHER_CFLAGS", to: "-fembed-bitcode")] and .define("ENABLE_BITCODE", to: "YES") with no luck.
How can I identify what is causing the bitcode to be disabled ?
Here is my package.swift:
let package = Package(
name: "MySwiftPackage",
platforms: [.iOS(.v11)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "MySwiftPackage",
targets: ["MySwiftPackage"]),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "MySwiftPackage",
publicHeadersPath: "Public",
cSettings: [
.headerSearchPath("Internal")
])
]
)

Related

SPM showing duplicate target name fatalError

I'm facing a problem with my lib using SPM.
I've developed it using a target into the project to test and works fine.
After finish I've added the lib using SPM into a final project using the branch develop and I was able to integrate lib and project.
When I saw that is all right, I made a tag from my lib and import into project using Up To Next Major (tag)
And using this way I'm getting this error:
I've checked all the code, compare Package.swift with other projects, change the name, change de folder and nothing.
Here my Package.swift
import PackageDescription
let package = Package(
name: "GloboUI",
platforms: [
.iOS(.v12)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "GloboUI", targets: ["GloboUI"]),
],
dependencies: [
.package(url: "https://github.com/rechsteiner/Parchment", exact: "3.1.0"),
.package(url: "https://github.com/onevcat/Kingfisher.git", from: "7.0.0"),
.package(url: "https://github.com/airbnb/lottie-ios.git", from: "4.0.0"),
.package(url: "https://github.com/googleads/swift-package-manager-google-mobile-ads.git", from: "9.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "GloboUI",
dependencies: [
.product(name: "GoogleMobileAds", package: "swift-package-manager-google-mobile-ads"),
.product(name: "Parchment", package: "Parchment"),
.product(name: "Kingfisher", package: "Kingfisher"),
.product(name: "Lottie", package: "lottie-ios")
],
path: "Sources/GloboUI"
)
]
)
I tried remove and change this path in target, change the target names...a lot of try
Here my folder structure of the lib
I've tried remove package.resolved form the main project, clean derivate data, cache, everything.
But I'm not know what is happening.
Anyone has a clue about this issue?
Regards

Swift Package containing cpp, objc and swift to XCFramework

For one of the projects I've inherited I need to do the transition to ASM so as to be able to run the app on M1/2 MacBook simulators. The last framework that I need to update
is Garmin's FitSDK that comes as a Swift Package
let package = Package(
name: "FIT",
platforms: [
#here I've modified it to be also deployed on iOS12
.iOS(.v12),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "FIT",
targets: ["SwiftFIT","ObjcFIT"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "cppfit",
dependencies: [],
resources: [
.copy("include")],
cSettings: [
.headerSearchPath("./include/")]),
.target(
name: "ObjcFIT",
dependencies: ["cppfit"],
cSettings: [
.headerSearchPath("../cppfit/include")]),
.target(
name: "SwiftFIT",
dependencies: ["ObjcFIT"]),
.testTarget(
name: "FITTests",
dependencies: ["SwiftFIT"]),
],
cxxLanguageStandard: .gnucxx11
)
In order to creation of the XCFramework to support ios-arm64_x86_64-simulator I'm trying to use Srdan's script from Swift Forums but I have 2 issues:
The generated modulemap if I use it
module FitSDK { export * }
I get a
Include of non-modular header inside framework module 'Project': [...]
at
#import <FitSDK/FitSDK.h>
If I update the modulemap to the old one
framework module FitSDK {
umbrella header "FitSDK.h"
export *
module * { export * }
}
now it won't find to import the header "FitSDK.h.
If I manually try to copy the headers from the old .framework which was only for arm64 (iOS Device) I get some symbols not found for arm64
Undefined symbols for architecture arm64:
"_FitCRC_Calc16", referenced from:
-[FITFileEncoder writeFileHeaderToFile:] in FITFileEncoder-121bb2ba48ce985896496c5403a05f7e.o
"_FitCRC_Get16", referenced from:
-[FITFileEncoder writeData:dataSize:file:] in FITFileEncoder-121bb2ba48ce985896496c5403a05f7e.o
"_Fit_InitMesg", referenced from:
-[FITFileEncoder writeFileIdMessageToFile:] in FITFileEncoder-121bb2ba48ce985896496c5403a05f7e.o
"_fit_mesg_defs", referenced from:
-[FITFileEncoder writeFileIdMessageToFile:] in FITFileEncoder-121bb2ba48ce985896496c5403a05f7e.o
ld: symbol(s) not found for architecture arm64
I realise and (not just) a bit lost but I have no clue on how to get this working.

Getting "No such module" error when trying to create an xcframework with dependencies

I tried different ways with different configurations and cannot make it run. Here is what I tried while creating the xcframework:
Add 1 framework dependency as pod
Add 1 framework dependency as Swift package (MKRingProgressView) and created also a swift package marking the dependency in the package dependency as follows:
name: "FirstFramework",
platforms: [
.iOS(.v15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "FirstFramework",
targets: ["FirstFramework"]),
],
dependencies: [
.package(url:
"https://github.com/maxkonovalov/MKRingProgressView.git",
from: "2.3.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.binaryTarget(
name: "FirstFramework",
path: "./Sources/FirstFramework.xcframework")
]
Set build libraries for distribution to YES
I am always getting the error "No such module MKRingProgressView" when adding my framework to a Test project, so its not recognising the dependency of my framework.
Any ideas?

How can I include/bundle other Swift Package dependencies in a Swift Package that only contains binaryTargets (XCFrameworks)?

I am creating Swift Packages from various Objective-C Frameworks (via use of XCFrameworks).
I successfully created the SPs, but have run into an issue when it comes to the other SP dependencies it relies on.
If I only add the WrapperPackage to my DemoApp, the compiler fails due to missing the SubDependencyPackage frameworks.
If I add the SubDependencyPackage via SPM to the DemoApp, it compiles just fine.
Is it possible / How can I...
properly bundle the "sub-dependencies" (SubDependencyPackage) into the Swift Package (WrapperPackage) so that in the DemoApp I only need to add WrapperPackage via SPM and all dependencies are resolved?
Workflow
DemoApp adds WrapperPackage as a SPM dependency.
WrapperPackage contains 2 XCFrameworks.
The 2 XCFrameworks were generated from 2 Objective-C Frameworks.
The Objective-C Frameworks have "sub-dependencies" of a separate Swift Package (SubDependencyPackage).
DemoApp
|
--WrapperPackage (XCFrameworks)
|
--SubDependencyPackage (XCFramework Dependencies)
WrapperPackage.swift
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "WrapperPackage",
platforms: [.iOS(.v13)],
products: [
.library(name: "ObjectiveCFramework1", targets: ["ObjectiveCFramework1"]),
.library(name: "ObjectiveCFramework2", targets: ["ObjectiveCFramework2"]),
],
dependencies: [
.package(name: "SubDependencyPackage.git", url: "git#github.com:user/SubDependencyPackage.git", .branch("main")),
],
targets: [
.binaryTarget(name: "ObjectiveCFramework1", path: "XCFrameworks/ObjectiveCFramework1.xcframework"),
.binaryTarget(name: "ObjectiveCFramework2", path: "XCFrameworks/ObjectiveCFramework2.xcframework"),
]
)

Swift SPM Package minimum iOS version not propagating

I am creating a simple Library Swift Package:
import PackageDescription
let package = Package(
name: "dpo-sdk-spm",
platforms: [
.iOS(.v10),
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "dpo-sdk-spm",
targets: ["dpo-sdk-spm"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.2.0"))
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "dpo-sdk-spm",
dependencies: ["Alamofire"]),
.testTarget(
name: "dpo-sdk-spmTests",
dependencies: ["dpo-sdk-spm"]),
]
)
I specifically did not create a project file, as working with that in source control is a pain - and its not required to develop a library that will be consumed in a iOS App, that will have the necessary build settings etc. My Library was created using swift package init --type library and here is the structure:
I specified under the platforms node iOS V10, then pushed the package to my git repo. I added my git account to Xcode, created a App project, added my package via Xcode 11's built in SPM and had no issues, however trying to build I got:
Showing All Messages The package product 'Alamofire' requires minimum platform version 10.0 for the iOS platform, but this target supports 8.0
I did specify the platform and version in my Package.swift, why is the build pipeline ignoring this variable?

Resources