2 years ago
#67565
Tudor
Module not found using Swift Package Manager building app target
I'm using Swift Package Manager to modularize a large mixed Objective-C and Swift iOS app. The app also uses CocoaPods for a few dependencies for which there is no Swift Package.
My project structure is as follows:
ios/
MyApp/
...
CorePackage/
Sources/
Core/ ...Swift stuff goes here
CoreObjC/ ... Obj-C stuff goes here
I have created the following Package.swift for my CorePackage. Note that I'm trying to use a Swift Language Swift Package in an Objective-C Language Swift Package:
let package = Package(
name: "CorePackage",
products: [
.library(name: "Core", targets: ["Core", "CoreObjC"]),
],
dependencies: [ ... ],
targets: [
.target(
name: "Core",
dependencies: [ ... ],
path: "Sources/Core"
),
.target(
name: "CoreObjC",
dependencies: [ "Core", ... ],
path: "Sources/CoreObjC",
publicHeadersPath: "include"
)
]
)
The following build command succeeds when run in the MyApp/CorePackage directory:
> xcodebuild -scheme "Core" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' build
I have added the "Core" package to my Frameworks, Libraries and Embedded Content target General Settings.
Now, when I try to build the app target from the ios directory:
> xcodebuild -scheme "MyApp" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -workspace MyApp.xcworkspace build
I get the following error:
/.../ios/MyApp/CorePackage/Sources/CoreObjC/include/HeaderA.h:13:9: error: module 'Core' not found
@import Core;
...
/.../ios/MyApp/HeaderB.h:11:9: note: while building module 'CoreObjC' imported from /.../ios/MyApp/HeaderB.h:11:
@import CoreObjC;
I have had no trouble when using packages with a single target, either Objective-C or Swift. Does anyone know what I'm missing here? So far I've lost a whole day trying to figure it out.
ios
swift
objective-c
xcode
swift-package-manager
0 Answers
Your Answer