The issue is with an app that I am building based on this library that I have created as an SPM package GitHub - rchatham/LangTools.swift: Some abstractions around LLM apis.. In my app I have the main modules of the app broken out using a local Package.swift and then adding the resulting package to my app so that I can build the modules using swift build
from the terminal.
What I cannot figure out is after some bad practice where I force-pushed to the LangTools.swift library after amending code to a tagged commit and trying to update the local packages I am able to build the app using XCode and xcodebuild from the command line HOWEVER swift build
fails saying error: no such module 'OpenAI'
.
I am adding the relevant portions of the Package.swift files for both repos, any help in diagnosing would be greatly appreciated! I have tried clearing the caches and pushing a new tag to the latest commit on the library, the latter did help resolve some issues caused by my previous force-push within XCode but not for swift build
.
LangTools.swift - Package.swift
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "LangTools",
platforms: [
.macOS(.v13),
.iOS(.v16),
.watchOS(.v8)
],
products: [
.library(
name: "LangTools",
targets: ["LangTools"]),
.library(
name: "OpenAI",
targets: ["OpenAI"]),
.library(
name: "Anthropic",
targets: ["Anthropic"]),
.library(
name: "XAI",
targets: ["XAI"]),
],
targets: [
.target(
name: "LangTools"),
.target(
name: "OpenAI",
dependencies: [.target(name: "LangTools")]),
.target(
name: "Anthropic",
dependencies: [.target(name: "LangTools")]),
.target(
name: "XAI",
dependencies: [
.target(name: "LangTools"),
.target(name: "OpenAI"),
]),
.testTarget(
name: "LangToolsTests",
dependencies: ["LangTools", "OpenAI"],
resources: [
.process("Resources/")
]),
.testTarget(
name: "OpenAITests",
dependencies: ["OpenAI"],
resources: [
.process("Resources/")
]),
.testTarget(
name: "AnthropicTests",
dependencies: ["Anthropic"],
resources: [
.process("Resources/")
]),
.testTarget(
name: "XAITests",
dependencies: ["XAI", "OpenAI", "LangToolsTests"],
resources: [
.process("Resources/")
]),
]
)
App - Package.swift
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "App",
platforms: [
.macOS(.v14),
.iOS(.v17),
.watchOS(.v8)
],
products: [
.library(
name: "Chat",
targets: ["Chat"]),
],
dependencies: [
.package(url: "https://github.com/rchatham/LangTools.swift.git", from: "0.0.1"),
],
targets: [
.target(
name: "Chat",
dependencies: [
.product(name: "LangTools", package: "langtools.swift", condition: .when(platforms: [.iOS])),
.product(name: "OpenAI", package: "langtools.swift", condition: .when(platforms: [.iOS])),
.product(name: "Anthropic", package: "langtools.swift", condition: .when(platforms: [.iOS])),
.product(name: "XAI", package: "langtools.swift", condition: .when(platforms: [.iOS])),
],
path: "Modules/Chat"),
]
)