Skip to content

Fix OTHER_CFLAGS in zip build. #3497

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

Merged
merged 2 commits into from
Aug 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions ZipBuilder/Sources/ZipBuilder/FrameworkBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ private enum Architecture: String, CaseIterable {
case device = "iphoneos"
case simulator = "iphonesimulator"

/// Arguments that should be included as part of the build process for each target platform.
func extraArguments() -> [String] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for calling it "extra" instead of "other"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, no particular reason. I can change to other.

/// Extra C flags that should be included as part of the build process for each target platform.
func otherCFlags() -> [String] {
switch self {
case .device:
// For device, we want to enable bitcode.
return ["OTHER_CFLAGS=$(value) " + "-fembed-bitcode"]
return ["-fembed-bitcode"]
case .simulator:
// No extra arguments are required for simulator builds.
return []
Expand Down Expand Up @@ -220,16 +220,17 @@ struct FrameworkBuilder {
let platform = arch.platform
let workspacePath = projectDir.appendingPathComponent("FrameworkMaker.xcworkspace").path
let distributionFlag = carthageBuild ? "-DFIREBASE_BUILD_CARTHAGE" : "-DFIREBASE_BUILD_ZIP_FILE"
let standardOptions = ["build",
"-configuration", "release",
"-workspace", workspacePath,
"-scheme", framework,
"GCC_GENERATE_DEBUGGING_SYMBOLS=No",
"ARCHS=\(arch.rawValue)",
"BUILD_DIR=\(buildDir.path)",
"-sdk", platform.rawValue,
"OTHER_CFLAGS=$(value) \(distributionFlag)"]
let args = standardOptions + platform.extraArguments()
let platformSpecificFlags = platform.otherCFlags().joined(separator: " ")
let cFlags = "OTHER_CFLAGS=$(value) \(distributionFlag) \(platformSpecificFlags)"
let args = ["build",
"-configuration", "release",
"-workspace", workspacePath,
"-scheme", framework,
"GCC_GENERATE_DEBUGGING_SYMBOLS=No",
"ARCHS=\(arch.rawValue)",
"BUILD_DIR=\(buildDir.path)",
"-sdk", platform.rawValue,
cFlags]
print("""
Compiling \(framework) for \(arch.rawValue) with command:
/usr/bin/xcodebuild \(args.joined(separator: " "))
Expand Down Expand Up @@ -418,7 +419,7 @@ struct FrameworkBuilder {

// Verify Firebase headers include an explicit umbrella header for Firebase.h.
let headersDir = podsDir.appendingPathComponents(["Headers", "Public", framework])
if framework.hasPrefix("Firebase") && framework != "FirebaseCoreDiagnostics" {
if framework.hasPrefix("Firebase"), framework != "FirebaseCoreDiagnostics" {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was from running style.sh

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems a lot less readable to me! A comma operator instead of &&?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll have to look into why that's the preferred one there. I think some guard statements make sense with , but this is less readable I'd say.

let frameworkHeader = headersDir.appendingPathComponent("\(framework).h")
guard fileManager.fileExists(atPath: frameworkHeader.path) else {
fatalError("Missing explicit umbrella header for \(framework).")
Expand Down