2018-10-29 16:50:53 +03:00
|
|
|
import Foundation
|
|
|
|
import PathKit
|
2018-11-04 14:30:34 +03:00
|
|
|
import ProjectSpec
|
2018-10-29 16:50:53 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2019-10-22 11:39:42 +03:00
|
|
|
private func generateDefaultInfoPlist(for target: Target) -> [String: Any] {
|
2018-10-29 16:50:53 +03:00
|
|
|
var dictionary: [String: Any] = [:]
|
|
|
|
dictionary["CFBundleIdentifier"] = "$(PRODUCT_BUNDLE_IDENTIFIER)"
|
|
|
|
dictionary["CFBundleInfoDictionaryVersion"] = "6.0"
|
2019-10-22 10:39:22 +03:00
|
|
|
|
2018-10-29 16:50:53 +03:00
|
|
|
dictionary["CFBundleName"] = "$(PRODUCT_NAME)"
|
|
|
|
dictionary["CFBundleDevelopmentRegion"] = "$(DEVELOPMENT_LANGUAGE)"
|
|
|
|
dictionary["CFBundleShortVersionString"] = "1.0"
|
|
|
|
dictionary["CFBundleVersion"] = "1"
|
2019-10-22 10:39:22 +03:00
|
|
|
|
|
|
|
// Bundles should not contain any CFBundleExecutable otherwise they will be rejected when uploading.
|
|
|
|
if target.type != .bundle {
|
|
|
|
dictionary["CFBundleExecutable"] = "$(EXECUTABLE_NAME)"
|
|
|
|
}
|
|
|
|
|
2018-10-29 16:50:53 +03:00
|
|
|
return dictionary
|
2019-10-22 10:39:22 +03:00
|
|
|
}
|
2018-10-29 16:50:53 +03:00
|
|
|
|
2019-10-22 11:39:42 +03:00
|
|
|
public func generateProperties(for target: Target) -> [String: Any] {
|
|
|
|
var targetInfoPlist = generateDefaultInfoPlist(for: target)
|
2018-10-29 16:50:53 +03:00
|
|
|
switch target.type {
|
|
|
|
case .uiTestBundle,
|
|
|
|
.unitTestBundle:
|
|
|
|
targetInfoPlist["CFBundlePackageType"] = "BNDL"
|
|
|
|
case .application,
|
|
|
|
.watch2App:
|
|
|
|
targetInfoPlist["CFBundlePackageType"] = "APPL"
|
|
|
|
case .framework:
|
|
|
|
targetInfoPlist["CFBundlePackageType"] = "FMWK"
|
|
|
|
case .bundle:
|
|
|
|
targetInfoPlist["CFBundlePackageType"] = "BNDL"
|
2018-11-05 13:13:23 +03:00
|
|
|
case .xpcService,
|
|
|
|
.appExtension:
|
|
|
|
targetInfoPlist["CFBundlePackageType"] = "XPC!"
|
2018-10-29 16:50:53 +03:00
|
|
|
default: break
|
|
|
|
}
|
|
|
|
return targetInfoPlist
|
|
|
|
}
|
|
|
|
}
|