Skip to content

Commit 5fa3c32

Browse files
authored
Fix bitcode generation for Swift frameworks (#6366)
1 parent 8ceb3b3 commit 5fa3c32

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

ZipBuilder/Sources/ZipBuilder/FrameworkBuilder.swift

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,6 @@ enum Architecture: String, CaseIterable {
2323
case device = "iphoneos"
2424
case simulator = "iphonesimulator"
2525
case catalyst = "macosx"
26-
27-
/// Extra C flags that should be included as part of the build process for each target platform.
28-
func otherCFlags() -> [String] {
29-
switch self {
30-
case .device:
31-
// For device, we want to enable bitcode.
32-
return ["-fembed-bitcode"]
33-
default:
34-
// No extra arguments are required for simulator builds.
35-
return []
36-
}
37-
}
38-
39-
/// Arguments that should be included as part of the build process for each target platform.
40-
func extraArguments() -> [String] {
41-
let base = ["-sdk", rawValue]
42-
switch self {
43-
case .catalyst:
44-
return ["SKIP_INSTALL=NO",
45-
"BUILD_LIBRARIES_FOR_DISTRIBUTION=YES",
46-
"SUPPORTS_UIKITFORMAC=YES"]
47-
case .simulator, .device:
48-
// No extra arguments are required for simulator or device builds.
49-
return base
50-
}
51-
}
5226
}
5327

5428
case arm64
@@ -242,8 +216,7 @@ struct FrameworkBuilder {
242216
let platformFolder = isMacCatalyst ? "maccatalyst" : platform.rawValue
243217
let workspacePath = projectDir.appendingPathComponent("FrameworkMaker.xcworkspace").path
244218
let distributionFlag = carthageBuild ? "-DFIREBASE_BUILD_CARTHAGE" : "-DFIREBASE_BUILD_ZIP_FILE"
245-
let platformSpecificFlags = platform.otherCFlags().joined(separator: " ")
246-
let cFlags = "OTHER_CFLAGS=$(value) \(distributionFlag) \(platformSpecificFlags)"
219+
let cFlags = "OTHER_CFLAGS=$(value) \(distributionFlag)"
247220
let cleanArch = isMacCatalyst ? Architecture.x86_64.rawValue : archs.map { $0.rawValue }
248221
.joined(separator: " ")
249222

@@ -265,6 +238,10 @@ struct FrameworkBuilder {
265238
"BUILD_DIR=\(buildDir.path)",
266239
"-sdk", platform.rawValue,
267240
cFlags]
241+
// Add bitcode option for devices.
242+
if platform.self == .device {
243+
args.append("BITCODE_GENERATION_MODE=bitcode")
244+
}
268245
// Code signing isn't needed for libraries. Disabling signing is required for
269246
// Catalyst libs with resources. See
270247
// https://github.com/CocoaPods/CocoaPods/issues/8891#issuecomment-573301570

0 commit comments

Comments
 (0)