Skip to content

Commit afbe6af

Browse files
authored
Add package visibility option to code generators (#355)
The `package` access modifier was introduced in Swift 5.9 ([proposal 0386](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0386-package-access-modifier.md)) to bridge the gap between `internal` and `public` in Swift packages. [Support for this modifier in generated code](apple/swift-protobuf#1472) was added to SwiftProtobuf in September 2023. This change adds the `Package` visibility option to the Connect generators. This is particularly useful when developing a Swift package, and you want to vend your generated models and mocks from a specific target to other targets of your package but not to dependent applications. --------- Signed-off-by: Eddie Seay <[email protected]>
1 parent db631a8 commit afbe6af

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
# Sets the Xcode version to use for the CI.
1010
# Available Versions: https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
1111
# Ref: https://www.jessesquires.com/blog/2020/01/06/selecting-an-xcode-version-on-github-ci/
12-
DEVELOPER_DIR: /Applications/Xcode_16.3.app/Contents/Developer
12+
DEVELOPER_DIR: /Applications/Xcode_16.4.app/Contents/Developer
1313
permissions:
1414
contents: read
1515
jobs:
@@ -35,7 +35,7 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v4
3737
- name: Build Connect iOS library
38-
run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.4' | xcbeautify
38+
run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.5' | xcbeautify
3939
build-library-macos:
4040
runs-on: macos-15
4141
steps:
@@ -47,7 +47,7 @@ jobs:
4747
steps:
4848
- uses: actions/checkout@v4
4949
- name: Build Connect tvOS library
50-
run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=tvOS Simulator,name=Apple TV,OS=18.4' | xcbeautify
50+
run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=tvOS Simulator,name=Apple TV,OS=18.5' | xcbeautify
5151
build-library-watchos:
5252
runs-on: macos-15
5353
steps:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ env:
88
# Sets the Xcode version to use for the CI.
99
# Available Versions: https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
1010
# Ref: https://www.jessesquires.com/blog/2020/01/06/selecting-an-xcode-version-on-github-ci/
11-
DEVELOPER_DIR: /Applications/Xcode_16.3.app/Contents/Developer
11+
DEVELOPER_DIR: /Applications/Xcode_16.4.app/Contents/Developer
1212
permissions:
1313
contents: write
1414
jobs:

Plugins/ConnectMocksPlugin/ConnectMockGenerator.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ final class ConnectMockGenerator: Generator {
3636
case .public:
3737
self.propertyVisibility = "public"
3838
self.typeVisibility = "open"
39+
case .package:
40+
self.propertyVisibility = "package"
41+
self.typeVisibility = "package"
3942
}
4043

4144
if self.options.generateCallbackMethods {

Plugins/ConnectPluginUtilities/GeneratorOptions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public struct GeneratorOptions {
6565
public enum Visibility: String {
6666
case `internal` = "Internal"
6767
case `public` = "Public"
68+
case `package` = "Package"
6869
}
6970

7071
static func empty() -> Self {

Plugins/ConnectSwiftPlugin/ConnectClientGenerator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ final class ConnectClientGenerator: Generator {
3333
self.visibility = "internal"
3434
case .public:
3535
self.visibility = "public"
36+
case .package:
37+
self.visibility = "package"
3638
}
3739

3840
self.printModuleImports()

0 commit comments

Comments
 (0)