diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 204cd230..b049576c 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -203,10 +203,10 @@ Settings are merged in the following order: groups, base, configs. - `TEST_TARGET_NAME`: for ui tests that target an application - `TEST_HOST`: for unit tests that target an application - [ ] **dependencies**: **[[Dependency](#dependency)]** - Dependencies for the target -- [ ] **info**: **[Plist](#plist)** - If defined, this will generate and write an `Info.plist` to the specified path and use it by setting the `INFOPLIST_FILE` build setting for every configuration, unless `INFOPLIST_FILE` is already defined in **settings** for this configuration. The following properties are generated automatically, the rest will have to be provided. +- [ ] **info**: **[Plist](#plist)** - If defined, this will generate and write an `Info.plist` to the specified path and use it by setting the `INFOPLIST_FILE` build setting for every configuration, unless `INFOPLIST_FILE` is already defined in **settings** for this configuration. The following properties are generated automatically if appropriate, the rest will have to be provided. - `CFBundleIdentifier` - `CFBundleInfoDictionaryVersion` - - `CFBundleExecutable` + - `CFBundleExecutable` **Not generated for targets of type bundle** - `CFBundleName` - `CFBundleDevelopmentRegion` - `CFBundleShortVersionString` diff --git a/Sources/XcodeGenKit/FileWriter.swift b/Sources/XcodeGenKit/FileWriter.swift index c26d656c..17af96c5 100644 --- a/Sources/XcodeGenKit/FileWriter.swift +++ b/Sources/XcodeGenKit/FileWriter.swift @@ -30,7 +30,7 @@ public class FileWriter { for target in project.targets { // write Info.plist if let plist = target.info { - let properties = infoPlistGenerator.generateProperties(target: target).merged(plist.properties) + let properties = infoPlistGenerator.generateProperties(for: target).merged(plist.properties) try writePlist(properties, path: plist.path) } diff --git a/Sources/XcodeGenKit/InfoPlistGenerator.swift b/Sources/XcodeGenKit/InfoPlistGenerator.swift index 533feeb4..165916f2 100644 --- a/Sources/XcodeGenKit/InfoPlistGenerator.swift +++ b/Sources/XcodeGenKit/InfoPlistGenerator.swift @@ -8,7 +8,7 @@ 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 */ - private func generateDefaultInfoPlist(target: Target) -> [String: Any] { + private func generateDefaultInfoPlist(for target: Target) -> [String: Any] { var dictionary: [String: Any] = [:] dictionary["CFBundleIdentifier"] = "$(PRODUCT_BUNDLE_IDENTIFIER)" dictionary["CFBundleInfoDictionaryVersion"] = "6.0" @@ -26,8 +26,8 @@ public class InfoPlistGenerator { return dictionary } - public func generateProperties(target: Target) -> [String: Any] { - var targetInfoPlist = generateDefaultInfoPlist(target: target) + public func generateProperties(for target: Target) -> [String: Any] { + var targetInfoPlist = generateDefaultInfoPlist(for: target) switch target.type { case .uiTestBundle, .unitTestBundle: diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 947b5e41..83ddbb0a 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -971,16 +971,17 @@ class ProjectGeneratorTests: XCTestCase { 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["CFBundleExecutable"] = "$(EXECUTABLE_NAME)" - expectedInfoPlist["CFBundleName"] = "$(PRODUCT_NAME)" - expectedInfoPlist["CFBundleDevelopmentRegion"] = "$(DEVELOPMENT_LANGUAGE)" - expectedInfoPlist["CFBundleShortVersionString"] = "1.0" - expectedInfoPlist["CFBundleVersion"] = "1" - expectedInfoPlist["CFBundlePackageType"] = "APPL" - expectedInfoPlist["UISupportedInterfaceOrientations"] = ["UIInterfaceOrientationPortrait", "UIInterfaceOrientationLandscapeLeft"] + let expectedInfoPlist: [String: Any] = [ + "CFBundleIdentifier": "$(PRODUCT_BUNDLE_IDENTIFIER)", + "CFBundleInfoDictionaryVersion": "6.0", + "CFBundleName": "$(PRODUCT_NAME)", + "CFBundleExecutable": "$(EXECUTABLE_NAME)", + "CFBundleDevelopmentRegion": "$(DEVELOPMENT_LANGUAGE)", + "CFBundleShortVersionString": "1.0", + "CFBundleVersion": "1", + "CFBundlePackageType": "APPL", + "UISupportedInterfaceOrientations": ["UIInterfaceOrientationPortrait", "UIInterfaceOrientationLandscapeLeft"] + ] try expect(NSDictionary(dictionary: expectedInfoPlist).isEqual(to: infoPlist)).beTrue() } @@ -1020,14 +1021,15 @@ class ProjectGeneratorTests: XCTestCase { 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" + let expectedInfoPlist: [String: Any] = [ + "CFBundleIdentifier": "$(PRODUCT_BUNDLE_IDENTIFIER)", + "CFBundleInfoDictionaryVersion": "6.0", + "CFBundleName": "$(PRODUCT_NAME)", + "CFBundleDevelopmentRegion": "$(DEVELOPMENT_LANGUAGE)", + "CFBundleShortVersionString": "1.0", + "CFBundleVersion": "1", + "CFBundlePackageType": "BNDL" + ] try expect(NSDictionary(dictionary: expectedInfoPlist).isEqual(to: infoPlist)).beTrue() }