Package.swift 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. // swift-tools-version:5.3
  2. // The swift-tools-version declares the minimum version of Swift required to build this package.
  3. // Copyright 2020 Google LLC
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. // This Package.swift is a Work in Progress, primarily for CI at this point.
  17. // Those interested in experimenting with Swift Package Manager should use the
  18. // spm-master2020 branch for now.
  19. import PackageDescription
  20. let package = Package(
  21. name: "Firebase",
  22. platforms: [.iOS(.v9), .macOS(.v10_11), .tvOS(.v10)],
  23. products: [
  24. // Products define the executables and libraries produced by a package, and make them visible to
  25. // other packages.
  26. .library(
  27. name: "Firebase",
  28. targets: ["Firebase"]
  29. ),
  30. .library(
  31. name: "FirebaseCore",
  32. targets: ["FirebaseCore"]
  33. ),
  34. .library(
  35. name: "FirebaseAuth",
  36. targets: ["FirebaseAuth"]
  37. ),
  38. .library(
  39. name: "FirebaseCrashlytics",
  40. targets: ["FirebaseCrashlytics"]
  41. ),
  42. .library(
  43. name: "FirebaseDatabase",
  44. targets: ["FirebaseDatabase"]
  45. ),
  46. .library(
  47. name: "FirebaseFunctions",
  48. targets: ["FirebaseFunctions"]
  49. ),
  50. .library(
  51. name: "FirebaseInstallations",
  52. targets: ["FirebaseInstallations"]
  53. ),
  54. // .library(
  55. // name: "FirebaseInstanceID",
  56. // targets: ["FirebaseInstanceID"]
  57. // ),
  58. .library(
  59. name: "FirebaseRemoteConfig",
  60. targets: ["FirebaseRemoteConfig"]
  61. ),
  62. .library(
  63. name: "FirebaseStorage",
  64. targets: ["FirebaseStorage"]
  65. ),
  66. .library(
  67. name: "FirebaseStorageSwift",
  68. targets: ["FirebaseStorageSwift"]
  69. ),
  70. ],
  71. dependencies: [
  72. .package(name: "Promises", url: "https://github.com/google/promises.git", "1.2.8" ..< "1.3.0"),
  73. .package(
  74. name: "GTMSessionFetcher",
  75. url: "https://github.com/google/gtm-session-fetcher.git",
  76. "1.4.0" ..< "2.0.0"
  77. ),
  78. .package(
  79. name: "nanopb",
  80. url: "https://github.com/paulb777/nanopb.git",
  81. .branch("swift-package-manager")
  82. ),
  83. .package(name: "OCMock", url: "https://github.com/paulb777/ocmock.git", .revision("7291762")),
  84. .package(name: "leveldb", url: "https://github.com/paulb777/leveldb.git", .revision("3f04697")),
  85. // Branches need a force update with a run with the revision set like below.
  86. // .package(url: "https://github.com/paulb777/nanopb.git", .revision("564392bd87bd093c308a3aaed3997466efb95f74"))
  87. ],
  88. targets: [
  89. // Targets are the basic building blocks of a package. A target can define a module or a test suite.
  90. // Targets can depend on other targets in this package, and on products in packages which this package depends on.
  91. .testTarget(
  92. name: "firebase-test",
  93. dependencies: [
  94. "FirebaseAuth",
  95. "FirebaseABTesting",
  96. "FirebaseFunctions",
  97. "Firebase",
  98. "FirebaseCrashlytics",
  99. "FirebaseCore",
  100. "FirebaseDatabase",
  101. "FirebaseInstallations",
  102. // "FirebaseInstanceID",
  103. "FirebaseRemoteConfig",
  104. "FirebaseStorage",
  105. "FirebaseStorageSwift",
  106. "GoogleDataTransport",
  107. "GoogleUtilities_AppDelegateSwizzler",
  108. "GoogleUtilities_Environment",
  109. // "GoogleUtilities_ISASwizzler", // Build needs to disable ARC.
  110. "GoogleUtilities_Logger",
  111. "GoogleUtilities_MethodSwizzler",
  112. "GoogleUtilities_Network",
  113. "GoogleUtilities_NSData",
  114. "GoogleUtilities_Reachability",
  115. "GoogleUtilities_UserDefaults",
  116. "nanopb",
  117. ]
  118. ),
  119. .target(
  120. name: "GoogleUtilities_AppDelegateSwizzler",
  121. dependencies: ["GoogleUtilities_Environment", "GoogleUtilities_Logger",
  122. "GoogleUtilities_Network"],
  123. path: "GoogleUtilities",
  124. exclude: [
  125. "CHANGELOG.md",
  126. "CMakeLists.txt",
  127. "LICENSE",
  128. "README.md",
  129. "AppDelegateSwizzler/README.md",
  130. "Environment/",
  131. "Network/",
  132. "ISASwizzler/",
  133. "Logger/",
  134. "MethodSwizzler/",
  135. "NSData+zlib/",
  136. "Reachability",
  137. "SwizzlerTestHelpers/",
  138. "Tests",
  139. "UserDefaults/",
  140. ],
  141. sources: [
  142. "AppDelegateSwizzler/",
  143. "SceneDelegateSwizzler/",
  144. "Common/*.h",
  145. ],
  146. publicHeadersPath: "AppDelegateSwizzler/Public",
  147. cSettings: [
  148. .headerSearchPath("../"),
  149. ]
  150. ),
  151. .target(
  152. name: "GoogleUtilities_Environment",
  153. dependencies: [.product(name: "FBLPromises", package: "Promises")],
  154. path: "GoogleUtilities/Environment",
  155. exclude: ["third_party/LICENSE"],
  156. publicHeadersPath: "Private",
  157. cSettings: [
  158. .headerSearchPath("../../"),
  159. ]
  160. ),
  161. // Tests need OCMock and resource support.
  162. .target(
  163. name: "GoogleUtilities_Logger",
  164. dependencies: ["GoogleUtilities_Environment"],
  165. path: "GoogleUtilities/Logger",
  166. publicHeadersPath: "Public",
  167. cSettings: [
  168. .headerSearchPath("../../"),
  169. ]
  170. ),
  171. // TODO: ISA_Swizzler requires building without ARC.
  172. .target(
  173. name: "GoogleUtilities_MethodSwizzler",
  174. dependencies: ["GoogleUtilities_Logger"],
  175. path: "GoogleUtilities/MethodSwizzler",
  176. publicHeadersPath: "Private",
  177. cSettings: [
  178. .headerSearchPath("../../"),
  179. ]
  180. ),
  181. .target(
  182. name: "GoogleUtilities_Network",
  183. dependencies: ["GoogleUtilities_Logger", "GoogleUtilities_NSData",
  184. "GoogleUtilities_Reachability"],
  185. path: "GoogleUtilities/Network",
  186. publicHeadersPath: "Public",
  187. cSettings: [
  188. .headerSearchPath("../.."),
  189. ]
  190. ),
  191. .target(
  192. name: "GoogleUtilities_NSData",
  193. path: "GoogleUtilities/NSData+zlib",
  194. publicHeadersPath: "Public",
  195. cSettings: [
  196. .headerSearchPath("../.."),
  197. ],
  198. linkerSettings: [
  199. .linkedLibrary("z"),
  200. ]
  201. ),
  202. .target(
  203. name: "GoogleUtilities_Reachability",
  204. dependencies: ["GoogleUtilities_Logger"],
  205. path: "GoogleUtilities/Reachability",
  206. publicHeadersPath: "Private",
  207. cSettings: [
  208. .headerSearchPath("../../"),
  209. ]
  210. ),
  211. .target(
  212. name: "GoogleUtilities_UserDefaults",
  213. dependencies: ["GoogleUtilities_Logger"],
  214. path: "GoogleUtilities/UserDefaults",
  215. publicHeadersPath: "Private",
  216. cSettings: [
  217. .headerSearchPath("../../"),
  218. ]
  219. ),
  220. // TODO: - need to port Network/third_party/GTMHTTPServer.m to ARC.
  221. // .testTarget(
  222. // name: "UtilitiesUnit",
  223. // dependencies: [
  224. // "OCMock",
  225. // "GoogleUtilities_AppDelegateSwizzler",
  226. // "GoogleUtilities_Environment",
  227. // // "GoogleUtilities_ISASwizzler", // Build needs to disable ARC.
  228. // "GoogleUtilities_Logger",
  229. // "GoogleUtilities_MethodSwizzler",
  230. // "GoogleUtilities_Network",
  231. // "GoogleUtilities_NSData",
  232. // "GoogleUtilities_Reachability",
  233. // "GoogleUtilities_UserDefaults",
  234. // ],
  235. // path: "GoogleUtilities/Tests/Unit",
  236. // exclude: [
  237. // "Network/third_party/LICENSE",
  238. // "Network/third_party/GTMHTTPServer.m", // Requires disabling ARC
  239. // ],
  240. // cSettings: [
  241. // .headerSearchPath("../../.."),
  242. // ]
  243. // ),
  244. .target(
  245. name: "Firebase",
  246. path: "CoreOnly/Sources",
  247. publicHeadersPath: "./"
  248. ),
  249. .target(
  250. name: "FirebaseCore",
  251. dependencies: ["GoogleUtilities_Environment", "GoogleUtilities_Logger"],
  252. path: "FirebaseCore/Sources",
  253. publicHeadersPath: "Public",
  254. cSettings: [
  255. .headerSearchPath("../.."),
  256. .define("FIRCore_VERSION", to: "0.0.1"), // TODO: Fix version
  257. .define("Firebase_VERSION", to: "0.0.1"), // TODO: Fix version
  258. // TODO: - Add support for cflags cSetting so that we can set the -fno-autolink option
  259. ]
  260. ),
  261. .testTarget(
  262. name: "CoreUnit",
  263. dependencies: ["FirebaseCore", "OCMock"],
  264. path: "FirebaseCore/Tests/Unit",
  265. exclude: ["Resources/GoogleService-Info.plist"],
  266. cSettings: [
  267. .headerSearchPath("../../.."),
  268. ]
  269. ),
  270. .target(
  271. name: "FirebaseABTesting",
  272. dependencies: ["FirebaseCore"],
  273. path: "FirebaseABTesting/Sources",
  274. publicHeadersPath: "Public",
  275. cSettings: [
  276. .headerSearchPath("../../"),
  277. .define("FIRABTesting_VERSION", to: "0.0.1"), // TODO: Fix version
  278. ]
  279. ),
  280. .testTarget(
  281. name: "ABTestingUnit",
  282. dependencies: ["FirebaseABTesting", "OCMock"],
  283. path: "FirebaseABTesting/Tests/Unit",
  284. resources: [.process("Resources")],
  285. cSettings: [
  286. .headerSearchPath("../../.."),
  287. ]
  288. ),
  289. .target(
  290. name: "FirebaseAuth",
  291. dependencies: ["FirebaseCore",
  292. "GoogleUtilities_Environment",
  293. "GoogleUtilities_AppDelegateSwizzler",
  294. .product(name: "GTMSessionFetcherCore", package: "GTMSessionFetcher")],
  295. path: "FirebaseAuth/Sources",
  296. publicHeadersPath: "Public",
  297. cSettings: [
  298. .headerSearchPath("../../"),
  299. .define("FIRAuth_VERSION", to: "0.0.1"), // TODO: Fix version
  300. .define("FIRAuth_MINOR_VERSION", to: "1.1"), // TODO: Fix version
  301. ]
  302. ),
  303. .testTarget(
  304. name: "AuthUnit",
  305. dependencies: ["FirebaseAuth", "OCMock"],
  306. path: "FirebaseAuth/Tests/Unit",
  307. exclude: [
  308. "FIRAuthKeychainServicesTests.m", // TODO: figure out SPM keychain testing
  309. "FIRAuthTests.m",
  310. "FIRUserTests.m",
  311. ],
  312. cSettings: [
  313. .headerSearchPath("../../.."),
  314. ]
  315. ),
  316. .target(
  317. name: "FirebaseCrashlytics",
  318. dependencies: ["FirebaseCore", "FirebaseInstallations",
  319. .product(name: "FBLPromises", package: "Promises"),
  320. "GoogleDataTransport", "nanopb"],
  321. path: "Crashlytics",
  322. exclude: [
  323. "run",
  324. "CHANGELOG.md",
  325. "LICENSE",
  326. "README.md",
  327. "Data/",
  328. "Protos/",
  329. "ProtoSupport/",
  330. "UnitTests/",
  331. "generate_project.sh",
  332. "upload-symbols",
  333. "third_party/libunwind/LICENSE",
  334. ],
  335. sources: [
  336. "Crashlytics/",
  337. "Protogen/",
  338. "Shared/",
  339. "third_party/libunwind/dwarf.h",
  340. ],
  341. publicHeadersPath: "Crashlytics/Public",
  342. cSettings: [
  343. .headerSearchPath(".."),
  344. .define("DISPLAY_VERSION", to: "0.0.1"), // TODO: Fix version
  345. .define("CLS_SDK_NAME", to: "Crashlytics iOS SDK", .when(platforms: .some([.iOS]))),
  346. .define("CLS_SDK_NAME", to: "Crashlytics macOS SDK", .when(platforms: .some([.macOS]))),
  347. .define("CLS_SDK_NAME", to: "Crashlytics tvOS SDK", .when(platforms: .some([.tvOS]))),
  348. .define("PB_FIELD_32BIT", to: "1"),
  349. .define("PB_NO_PACKED_STRUCTS", to: "1"),
  350. .define("PB_ENABLE_MALLOC", to: "1"),
  351. ]
  352. ),
  353. .target(
  354. name: "FirebaseDatabase",
  355. dependencies: [
  356. "FirebaseCore",
  357. "leveldb",
  358. ],
  359. path: "FirebaseDatabase/Sources",
  360. exclude: [
  361. "third_party/Wrap-leveldb/LICENSE",
  362. "third_party/SocketRocket/LICENSE",
  363. "third_party/FImmutableSortedDictionary/LICENSE",
  364. "third_party/SocketRocket/aa2297808c225710e267afece4439c256f6efdb3",
  365. ],
  366. publicHeadersPath: "Public",
  367. cSettings: [
  368. .headerSearchPath("../../"),
  369. .define("FIRDatabase_VERSION", to: "0.0.1"), // TODO: Fix version
  370. ]
  371. ),
  372. .testTarget(
  373. name: "DatabaseUnit",
  374. dependencies: ["FirebaseDatabase", "OCMock", "SharedTestUtilities"],
  375. path: "FirebaseDatabase/Tests/",
  376. exclude: [
  377. "Integration/",
  378. ],
  379. resources: [.process("Resources")],
  380. cSettings: [
  381. .headerSearchPath("../.."),
  382. ]
  383. ),
  384. .target(
  385. name: "FirebaseFunctions",
  386. dependencies: [
  387. "FirebaseCore",
  388. .product(name: "GTMSessionFetcherCore", package: "GTMSessionFetcher"),
  389. ],
  390. path: "Functions/FirebaseFunctions",
  391. publicHeadersPath: "Public",
  392. cSettings: [
  393. .headerSearchPath("../../"),
  394. .define("FIRFunctions_VERSION", to: "0.0.1"), // TODO: Fix version
  395. ]
  396. ),
  397. // .target(
  398. // name: "FirebaseInstanceID",
  399. // dependencies: ["FirebaseCore", "FirebaseInstallations",
  400. // "GoogleUtilities_Environment", "GoogleUtilities_UserDefaults"],
  401. // path: "Firebase/InstanceID",
  402. // publicHeadersPath: "Public",
  403. // cSettings: [
  404. // .headerSearchPath("../../"),
  405. // .define("FIRInstanceID_LIB_VERSION", to: "0.0.1"), // TODO: Fix version
  406. // ]
  407. // ),
  408. .target(
  409. name: "FirebaseInstallations",
  410. dependencies: ["FirebaseCore", .product(name: "FBLPromises", package: "Promises"),
  411. "GoogleUtilities_Environment", "GoogleUtilities_UserDefaults"],
  412. path: "FirebaseInstallations/Source/Library",
  413. publicHeadersPath: "Public",
  414. cSettings: [
  415. .headerSearchPath("../../../"),
  416. ]
  417. ),
  418. .target(
  419. name: "SharedTestUtilities",
  420. dependencies: ["FirebaseCore"],
  421. path: "SharedTestUtilities",
  422. publicHeadersPath: "Public",
  423. cSettings: [
  424. .headerSearchPath("../"),
  425. ]
  426. ),
  427. .target(
  428. name: "FirebaseRemoteConfig",
  429. dependencies: [
  430. "FirebaseCore",
  431. "FirebaseABTesting",
  432. "FirebaseInstallations",
  433. "GoogleUtilities_NSData",
  434. ],
  435. path: "FirebaseRemoteConfig/Sources",
  436. publicHeadersPath: "Public",
  437. cSettings: [
  438. .headerSearchPath("../../"),
  439. .define("FIRRemoteConfig_VERSION", to: "0.0.1"), // TODO: Fix version
  440. ]
  441. ),
  442. .testTarget(
  443. name: "RemoteConfigUnit",
  444. dependencies: ["FirebaseRemoteConfig", "OCMock"],
  445. path: "FirebaseRemoteConfig/Tests/Unit",
  446. exclude: [
  447. // Need to be evaluated/ported to RC V2.
  448. "RCNConfigAnalyticsTest.m",
  449. "RCNConfigSettingsTest.m",
  450. "RCNConfigTest.m",
  451. "RCNRemoteConfig+FIRAppTest.m",
  452. "RCNThrottlingTests.m",
  453. ],
  454. resources: [
  455. .process("SecondApp-GoogleService-Info.plist"),
  456. .process("Defaults-testInfo.plist"),
  457. .process("TestABTPayload.txt"),
  458. ],
  459. cSettings: [
  460. .headerSearchPath("../../.."),
  461. ]
  462. ),
  463. .target(
  464. name: "FirebaseStorage",
  465. dependencies: [
  466. "FirebaseCore",
  467. .product(name: "GTMSessionFetcherCore", package: "GTMSessionFetcher"),
  468. ],
  469. path: "FirebaseStorage/Sources",
  470. publicHeadersPath: "Public",
  471. cSettings: [
  472. .headerSearchPath("../../"),
  473. .define("FIRStorage_VERSION", to: "0.0.1"), // TODO: Fix version
  474. ]
  475. ),
  476. .testTarget(
  477. name: "StorageUnit",
  478. dependencies: ["FirebaseStorage", "OCMock", "SharedTestUtilities"],
  479. path: "FirebaseStorage/Tests/Unit",
  480. cSettings: [
  481. .headerSearchPath("../../.."),
  482. ]
  483. ),
  484. .target(
  485. name: "FirebaseStorageSwift",
  486. dependencies: ["FirebaseStorage"],
  487. path: "FirebaseStorageSwift/Sources"
  488. ),
  489. .target(
  490. name: "GoogleDataTransport",
  491. dependencies: ["nanopb"],
  492. path: "GoogleDataTransport",
  493. exclude: [
  494. "CHANGELOG.md",
  495. "README.md",
  496. "generate_project.sh",
  497. "GDTCCTWatchOSTestApp/",
  498. "GDTWatchOSTestApp/",
  499. "GDTCCTTestApp/",
  500. "GDTTestApp/",
  501. "GDTCCTTests/",
  502. "GDTCORTests/",
  503. "ProtoSupport/",
  504. ],
  505. sources: [
  506. "GDTCORLibrary",
  507. "GDTCCTLibrary",
  508. ],
  509. publicHeadersPath: "GDTCORLibrary/Public",
  510. cSettings: [
  511. .headerSearchPath("../"),
  512. .define("GDTCOR_VERSION", to: "0.0.1"),
  513. .define("PB_FIELD_32BIT", to: "1"),
  514. .define("PB_NO_PACKED_STRUCTS", to: "1"),
  515. .define("PB_ENABLE_MALLOC", to: "1"),
  516. ]
  517. ),
  518. ],
  519. cLanguageStandard: .c99,
  520. cxxLanguageStandard: CXXLanguageStandard.gnucxx14
  521. )