// swift-tools-version:5.3 // The swift-tools-version declares the minimum version of Swift required to build this package. /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the license found in the * LICENSE file in the root directory of this source tree. */ import PackageDescription import Foundation #if os(Linux) import Glibc #else import Darwin.C #endif let package = Package( name: "Facebook", platforms: [.iOS(.v12)], products: [ // The Kernel of the SDK. Must be included as a runtime dependency. .basics, // The Facebook AEM Kit .aem, /* The Core SDK library that provides two importable modules: - FacebookCore which includes the most current interface and will contain interfaces for new features written in Swift - FBSDKCoreKit which contains legacy Objective-C interfaces that will be used to maintain backwards compatibility with types that have been converted to Swift. This will not contain interfaces for new features written in Swift. */ .core, // The Facebook Login SDK .login, // The Facebook Share SDK .share, // The Facebook Gaming Services SDK .gaming, ], targets: [ // The kernel of the SDK .Prefixed.basics, .basics, /* The legacy Objective-C implementation that will be converted to Swift. This will not contain interfaces for new features written in Swift. */ .Prefixed.aem, // The main AEM module .aem, /* The legacy Objective-C implementation that will be converted to Swift. This will not contain interfaces for new features written in Swift. */ .Prefixed.core, // The main Core SDK module .core, /* The legacy Objective-C implementation that will be converted to Swift. This will not contain interfaces for new features written in Swift. */ .Prefixed.login, // The main Login SDK module .login, /* The legacy Objective-C implementation that has been converted to Swift. This will not contain interfaces for new features written in Swift. */ .Prefixed.share, // The main Share SDK module .share, /* The legacy Objective-C implementation that has been converted to Swift. This will not contain interfaces for new features written in Swift. */ .Prefixed.gamingServices, // The main Facebook Gaming Services module .gaming, ], cxxLanguageStandard: .cxx11 ) extension Product { static let basics = library(name: .basics, targets: [.basics, .Prefixed.basics]) static let core = library(name: .core, targets: [.core, .Prefixed.core]) static let login = library(name: .login, targets: [.login]) static let share = library(name: .share, targets: [.share, .Prefixed.share]) static let gaming = library(name: .gaming, targets: [.gaming, .Prefixed.gaming]) static let aem = library(name: .aem, targets: [.aem, .Prefixed.aem]) } extension Target { static let binarySource = BinarySource() static func binaryTarget(name: String, remoteChecksum: String) -> Target { switch binarySource { case .local: return .binaryTarget( name: name, path: localBinaryPath(for: name) ) case .remote: return .binaryTarget( name: name, url: remoteBinaryURLString(for: name), checksum: remoteChecksum ) } } static func localBinaryPath(for targetName: String) -> String { "build/XCFrameworks/Dynamic/\(targetName).xcframework" } static func remoteBinaryURLString(for targetName: String) -> String { "https://github.com/facebook/facebook-ios-sdk/releases/download/v18.0.2/\(targetName)-Dynamic_XCFramework.zip" } static let basics = target( name: .basics, dependencies: [.Prefixed.basics], resources: [ .copy("Resources/PrivacyInfo.xcprivacy"), ] ) static let aem = target( name: .aem, dependencies: [.Prefixed.aem, .Prefixed.basics], resources: [ .copy("Resources/PrivacyInfo.xcprivacy"), ] ) static let core = target( name: .core, dependencies: [.aem, .Prefixed.basics, .Prefixed.core], resources: [ .copy("Resources/PrivacyInfo.xcprivacy"), ], linkerSettings: [ .cPlusPlusLibrary, .zLibrary, .accelerateFramework, ] ) static let login = target( name: .login, dependencies: [.core, .Prefixed.login], resources: [ .copy("Resources/PrivacyInfo.xcprivacy"), ] ) static let share = target( name: .share, dependencies: [.core, .Prefixed.share], resources: [ .copy("Resources/PrivacyInfo.xcprivacy"), ] ) static let gaming = target(name: .gaming, dependencies: [.core, .Prefixed.share, .Prefixed.gaming]) enum Prefixed { static let basics = binaryTarget( name: .Prefixed.basics, remoteChecksum: "c57eb4255c86b60ac0a19cd4c42694220f41985e104ced9cb1c998b650de1bf3" ) static let aem = binaryTarget( name: .Prefixed.aem, remoteChecksum: "2a2409a08917b6cfab27a66333ecb73c27b8852d45b2985e4281f68554c0dd5f" ) static let core = binaryTarget( name: .Prefixed.core, remoteChecksum: "a647fa24789d5c579ca8c7088c9394d5b410194d8c7e269f8d3f7cf3c33279fd" ) static let login = binaryTarget( name: .Prefixed.login, remoteChecksum: "0f984f04366fcc141e901de6c635fef40c7c496c015c0d1121e03c5913431d52" ) static let share = binaryTarget( name: .Prefixed.share, remoteChecksum: "dad67fc33428f9c793252a71607c08c6ce9748b6804d0b4241c63ab444c8fef8" ) static let gamingServices = binaryTarget( name: .Prefixed.gaming, remoteChecksum: "c603498c63c33283062f9c50be23ec31c952d1726ce9f50ba875cca2d378b450" ) } } extension Target.Dependency { static let aem = byName(name: .aem) static let core = byName(name: .core) enum Prefixed { static let aem = byName(name: .Prefixed.aem) static let basics = byName(name: .Prefixed.basics) static let core = byName(name: .Prefixed.core) static let login = byName(name: .Prefixed.login) static let share = byName(name: .Prefixed.share) static let gaming = byName(name: .Prefixed.gaming) } } extension LinkerSetting { static let cPlusPlusLibrary = linkedLibrary("c++") static let zLibrary = linkedLibrary("z") static let accelerateFramework = linkedFramework("Accelerate") } enum BinarySource { case local, remote init() { if getenv("USE_LOCAL_FB_BINARIES") != nil { self = .local } else { self = .remote } } } extension String { static let aem = "FacebookAEM" static let basics = "FacebookBasics" static let core = "FacebookCore" static let login = "FacebookLogin" static let share = "FacebookShare" static let gaming = "FacebookGamingServices" enum Prefixed { static let aem = "FBAEMKit" static let basics = "FBSDKCoreKit_Basics" static let core = "FBSDKCoreKit" static let login = "FBSDKLoginKit" static let share = "FBSDKShareKit" static let gaming = "FBSDKGamingServicesKit" } }