How to make ios app which uses SPM to build and create Xcframework automatically through scripts on every checkin to github.
This is the existing project with Pods and we migrated to SPM. So we have added package file at Project's root folder. Rest of the steps we need to automate to build and create xcframework in pipeline for every merge that is happening in GitHub Master.
Opening the xcode project, adding package manually and creating framework works fine when done manually. But same thing is failing in scripts.
These are the scripts I tried to automate the build and framework creation,
xcodebuild -resolvePackageDependencies -project xcodePrjName.xcodeproj -target SPMTarget
Framework Creation Script:
xcodebuild archive \
-scheme SPMTarget \
-archivePath ~/Desktop/Frameworks/SPMFramework-iphoneos.xcarchive \
-sdk iphoneos \
SKIP_INSTALL=NO
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild archive \
-scheme SPMTarget \
-archivePath ~/Desktop/Frameworks/SPMFramework-iphonesimulator.xcarchive \
-sdk iphonesimulator \
SKIP_INSTALL=NO
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild -create-xcframework \
-framework ~/Desktop/Frameworks/SPMFramework.framework\
-framework ~/Desktop/Frameworks/SPMFramework.framework \
-output ~/Desktop/Frameworks/new/SPMFramework.xcframework
But these commands fail, because it says the package product is not available for SPMTarget.
Here is my Package,
let package = Package(
name: "iOS_Core_Library1",
defaultLocalization: "en",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "iOS_Core_Library1",
targets: ["iOS_Core_Library"]),
],
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire", exact: "5.6.4"),
.package(url: "https://github.com/cesarferreira/SwiftEventBus.git", exact: "5.1.0"),
.package(url: "https://github.com/kean/Nuke.git", exact: "7.6.3"),
.package(url: "https://github.com/vpeschenkov/SecureDefaults.git", exact: "1.1.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: "iOS_Core_Library",
dependencies: [
"Alamofire",
"SwiftEventBus",
"Nuke",
"SecureDefaults"
],
path: "iOS_Core_Library",
exclude: ["Info.plist"]),
]
)