Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SwiftPM build #73

Merged
merged 1 commit into from
Sep 15, 2024
Merged

Conversation

kabiroberai
Copy link
Contributor

With Xcode 16 / Swift 6.0, it's possible to build iOS libraries using SwiftPM / swift-build:

$ swift build --triple arm64-apple-ios --sdk "$(xcrun -sdk iphoneos -show-sdk-path)"

However, there's a small discrepancy (arguably an underspecification) between the XCBuild and SwiftPM build systems: XCBuild appears to process xcassets files automatically whereas SwiftPM requires explicitly declaring them as resources. This causes the build to fail.

$ swift build --triple arm64-apple-ios --sdk "$(xcrun -sdk iphoneos -show-sdk-path)"
warning: 'pow': found 1 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
    [...]/Pow/Sources/Pow/Assets.xcassets
Building for debugging...
[...]/Pow/Sources/Pow/Effects/SmokeEffect.swift:61:63: error: type 'Bundle?' has no member 'module'

This PR makes a one line fix that allows Pow to build with XCBuild as well as SwiftPM.

--- a/Package.swift
+++ b/Package.swift
@@ -30,6 +30,7 @@ let package = Package(
         .target(
             name: "Pow",
             dependencies: enablePreviews ? [.product(name: "SnapshotPreferences", package: "SnapshotPreviews-iOS", condition: .when(platforms: [.iOS]))] : [],
+            resources: [.process("Assets.xcassets")],
             swiftSettings: enablePreviews ? [.define("EMG_PREVIEWS")] : nil),
         .testTarget(
             name: "PowTests",

@mergesort mergesort merged commit 4f47e33 into EmergeTools:main Sep 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants