diff --git a/CHANGELOG.md b/CHANGELOG.md index eccc1127..981e95b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ #### Fixed - Add base localisation by default even if no base localised files were found. Fixes warning in Xcode 11 [#685](https://github.com/yonaskolb/XcodeGen/pull/685) @yonaskolb +- Don't generate CFBundleExecutable for target of type `bundle` @FranzBusch ## 2.9.0 diff --git a/Sources/XcodeGenKit/InfoPlistGenerator.swift b/Sources/XcodeGenKit/InfoPlistGenerator.swift index f4850a18..533feeb4 100644 --- a/Sources/XcodeGenKit/InfoPlistGenerator.swift +++ b/Sources/XcodeGenKit/InfoPlistGenerator.swift @@ -8,20 +8,26 @@ public class InfoPlistGenerator { Default info plist attributes taken from: /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/Base/Base_DefinitionsInfoPlist.xctemplate/TemplateInfo.plist */ - var defaultInfoPlist: [String: Any] = { + private func generateDefaultInfoPlist(target: Target) -> [String: Any] { var dictionary: [String: Any] = [:] dictionary["CFBundleIdentifier"] = "$(PRODUCT_BUNDLE_IDENTIFIER)" dictionary["CFBundleInfoDictionaryVersion"] = "6.0" - dictionary["CFBundleExecutable"] = "$(EXECUTABLE_NAME)" + dictionary["CFBundleName"] = "$(PRODUCT_NAME)" dictionary["CFBundleDevelopmentRegion"] = "$(DEVELOPMENT_LANGUAGE)" dictionary["CFBundleShortVersionString"] = "1.0" dictionary["CFBundleVersion"] = "1" + + // Bundles should not contain any CFBundleExecutable otherwise they will be rejected when uploading. + if target.type != .bundle { + dictionary["CFBundleExecutable"] = "$(EXECUTABLE_NAME)" + } + return dictionary - }() + } public func generateProperties(target: Target) -> [String: Any] { - var targetInfoPlist = defaultInfoPlist + var targetInfoPlist = generateDefaultInfoPlist(target: target) switch target.type { case .uiTestBundle, .unitTestBundle: diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 266e1b42..947b5e41 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -1002,6 +1002,35 @@ class ProjectGeneratorTests: XCTestCase { // generated plist should not be in buildsettings try expect(targetConfig.buildSettings["INFOPLIST_FILE"] as? String) == predefinedPlistPath } + + $0.it("generate info.plist doesn't generate CFBundleExecutable for targets with type bundle") { + let plist = Plist(path: "Info.plist", attributes: [:]) + let tempPath = Path.temporary + "info" + let project = Project(basePath: tempPath, name: "", targets: [Target(name: "", type: .bundle, platform: .iOS, info: plist)]) + let pbxProject = try project.generatePbxProj() + let writer = FileWriter(project: project) + try writer.writePlists() + + guard let targetConfig = pbxProject.nativeTargets.first?.buildConfigurationList?.buildConfigurations.first else { + throw failure("Couldn't find Target config") + } + + try expect(targetConfig.buildSettings["INFOPLIST_FILE"] as? String) == plist.path + + let infoPlistFile = tempPath + plist.path + let data: Data = try infoPlistFile.read() + let infoPlist = try PropertyListSerialization.propertyList(from: data, options: [], format: nil) as! [String: Any] + var expectedInfoPlist: [String: Any] = [:] + expectedInfoPlist["CFBundleIdentifier"] = "$(PRODUCT_BUNDLE_IDENTIFIER)" + expectedInfoPlist["CFBundleInfoDictionaryVersion"] = "6.0" + expectedInfoPlist["CFBundleName"] = "$(PRODUCT_NAME)" + expectedInfoPlist["CFBundleDevelopmentRegion"] = "$(DEVELOPMENT_LANGUAGE)" + expectedInfoPlist["CFBundleShortVersionString"] = "1.0" + expectedInfoPlist["CFBundleVersion"] = "1" + expectedInfoPlist["CFBundlePackageType"] = "BNDL" + + try expect(NSDictionary(dictionary: expectedInfoPlist).isEqual(to: infoPlist)).beTrue() + } } } }