Skip to content

Commit fb6ffaf

Browse files
committed
cmd/gomobile: macOS support
Adds macosx on amd64 and arm64 targets to the fat xcframework. This enables the generated xcframework to be used as a binary dependency in Swift Package Manager: https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages and used or tested using the SwiftPM command-line tools on macOS, e.g. 'swift test'
1 parent ddc7be5 commit fb6ffaf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/gomobile/env.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func allArchs(targetOS string) []string {
3939
func allTargets(targetOS string) []string {
4040
switch targetOS {
4141
case "ios":
42-
return []string{"simulator", "ios", "catalyst"}
42+
return []string{"simulator", "ios", "catalyst", "macosx"}
4343
default:
4444
panic(fmt.Sprintf("unexpected target OS: %s", targetOS))
4545
}
@@ -55,6 +55,8 @@ func allTargetArchs(targetOS string, target string) []string {
5555
return []string{"arm64"}
5656
case "catalyst":
5757
return []string{"arm64", "amd64"}
58+
case "macosx":
59+
return []string{"arm64", "amd64"}
5860
default:
5961
panic(fmt.Sprintf("unexpected ios target: %s", target))
6062
}
@@ -183,6 +185,9 @@ func envInit() (err error) {
183185
case "catalyst":
184186
clang, cflags, err = envClang("macosx")
185187
cflags += " -target x86_64-apple-ios13.0-macabi"
188+
case "macosx":
189+
clang, cflags, err = envClang("macosx")
190+
// cflags += " -target x86_64-apple-ios13.0-macabi"
186191
default:
187192
panic(fmt.Errorf("unknown ios target: %q", arch))
188193
}
@@ -205,7 +210,7 @@ func envInit() (err error) {
205210
"CGO_ENABLED=1",
206211
"ARCH="+arch,
207212
)
208-
darwinEnv[target + "_" + arch] = env
213+
darwinEnv[target+"_"+arch] = env
209214
}
210215
}
211216

0 commit comments

Comments
 (0)