From 23a7e4e0b0f63ac223c5cf6c6e8ffcc6b2be6e8b Mon Sep 17 00:00:00 2001 From: mustiikhalil <26250654+mustiikhalil@users.noreply.github.com> Date: Wed, 23 Mar 2022 05:42:20 +0100 Subject: [PATCH] Adds no-includes flags to the swift code generator (#7182) --- scripts/generate_code.py | 2 +- src/idl_gen_swift.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/generate_code.py b/scripts/generate_code.py index 9871c0dff..fcf87cdcc 100755 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -367,7 +367,7 @@ flatc( # Swift Tests swift_prefix = "FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests" flatc( - SWIFT_OPTS + NO_INCL_OPTS + ["--grpc"], + SWIFT_OPTS + BASE_OPTS + ["--grpc"], schema="monster_test.fbs", include="include_test", prefix=swift_prefix, diff --git a/src/idl_gen_swift.cpp b/src/idl_gen_swift.cpp index 2ae28d8b4..c925c7184 100644 --- a/src/idl_gen_swift.cpp +++ b/src/idl_gen_swift.cpp @@ -167,9 +167,10 @@ class SwiftGenerator : public BaseGenerator { code_ += "// " + std::string(FlatBuffersGeneratedWarning()); code_ += "// swiftlint:disable all"; code_ += "// swiftformat:disable all\n"; - code_ += "import FlatBuffers\n"; - // Generate code for all the enum declarations. + if (parser_.opts.include_dependence_headers || parser_.opts.generate_all) + code_ += "import FlatBuffers\n"; + // Generate code for all the enum declarations. for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end(); ++it) { const auto &enum_def = **it;