Skip to content

Commit 677d71b

Browse files
author
Andreas Neusuess
committed
separate macro declaration from implementation of bundle expansion
1 parent 024f20c commit 677d71b

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

Sources/FoundationInternationalization/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
add_library(FoundationInternationalization
1616
BinaryFloatingPoint.swift
17+
CurrentBundle.swift
1718
Date+ICU.swift
1819
Duration+Utils.swift
1920
RangeExpression.swift
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#if FOUNDATION_FRAMEWORK
14+
/// Returns the bundle most likely to contain resources for the calling code.
15+
///
16+
/// Code in an app, app extension, framework, etc. will return the bundle associated with that target.
17+
/// Code in a Swift Package target will return the resource bundle associated with that target.
18+
@available(macOS 10.0, iOS 2.0, tvOS 9.0, watchOS 2.0, *)
19+
@freestanding(expression)
20+
public macro bundle() -> Bundle = #externalMacro(module: "FoundationMacros", type: "BundleMacro")
21+
#endif
22+

Sources/FoundationMacros/BundleMacro.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212

1313
import SwiftSyntax
1414
import SwiftSyntaxMacros
15-
import Foundation
16-
17-
#if FOUNDATION_FRAMEWORK
18-
/// Returns the bundle most likely to contain resources for the calling code.
19-
///
20-
/// Code in an app, app extension, framework, etc. will return the bundle associated with that target.
21-
/// Code in a Swift Package target will return the resource bundle associated with that target.
22-
@available(macOS 10.0, iOS 2.0, tvOS 9.0, watchOS 2.0, *)
23-
@freestanding(expression)
24-
public macro bundle() -> Bundle = #externalMacro(module: "FoundationMacros", type: "BundleMacro")
25-
#endif
26-
2715

2816
public struct BundleMacro: SwiftSyntaxMacros.ExpressionMacro, Sendable {
2917
public static func expansion(of node: some FreestandingMacroExpansionSyntax, in context: some MacroExpansionContext) throws -> ExprSyntax {

Tests/FoundationMacrosTests/BundleTests.swift renamed to Tests/FoundationMacrosTests/BundleMacroTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import XCTest
1414
import FoundationMacros
1515

16-
final class BundleTests: XCTestCase {
16+
final class BundleMacroTests: XCTestCase {
1717

1818
func testSimple() {
1919
AssertMacroExpansion(

0 commit comments

Comments
 (0)