From 73eab1cc4ae37c77a901c193df5072ed17632da2 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Wed, 9 Dec 2020 16:06:09 -0800 Subject: [PATCH] Update dependencies for the UrlGet sample project --- sample/UrlGet/Makefile | 4 +- sample/UrlGet/Pods.WORKSPACE | 2 +- .../Vendor/GoogleAppIndexing/.pod-version | 2 +- .../GoogleAppIndexing/{BUILD => BUILD.bazel} | 122 +++- .../Private/GoogleAppIndexing-prefix.pch | 11 + .../Public/GoogleAppIndexing/GSDAppIndexing.h | 1 + .../Public/GoogleAppIndexing/GSDDeepLink.h | 1 + .../GoogleAppIndexing/GoogleAppIndexing.h | 1 + .../{BUILD => BUILD.bazel} | 0 .../Vendor/GoogleAuthUtilities/.pod-version | 2 +- .../{BUILD => BUILD.bazel} | 85 ++- .../Private/GoogleAuthUtilities-prefix.pch | 11 + .../{BUILD => BUILD.bazel} | 0 .../GoogleNetworkingUtilities/.pod-version | 2 +- .../{BUILD => BUILD.bazel} | 84 ++- .../GoogleNetworkingUtilities-prefix.pch | 11 + .../{BUILD => BUILD.bazel} | 0 .../Vendor/GoogleSymbolUtilities/.pod-version | 2 +- .../{BUILD => BUILD.bazel} | 83 ++- .../Private/GoogleSymbolUtilities-prefix.pch | 11 + .../{BUILD => BUILD.bazel} | 0 sample/UrlGet/Vendor/PINCache/.buckconfig | 21 - .../Vendor/PINCache/.github/workflows/ci.yaml | 53 ++ .../.github/workflows/publish_release.yml | 39 ++ .../PINCache/.github_changelog_generator | 3 + sample/UrlGet/Vendor/PINCache/.gitignore | 5 + sample/UrlGet/Vendor/PINCache/.pod-version | 2 +- sample/UrlGet/Vendor/PINCache/.travis.yml | 18 - sample/UrlGet/Vendor/PINCache/BUCK | 23 - .../Vendor/PINCache/{BUILD => BUILD.bazel} | 208 +++++-- sample/UrlGet/Vendor/PINCache/CHANGELOG.md | 62 +- sample/UrlGet/Vendor/PINCache/CI/build.sh | 4 - .../PINCache/CI/exclude-from-build.json | 6 - .../UrlGet/Vendor/PINCache/CODE_OF_CONDUCT.md | 40 ++ sample/UrlGet/Vendor/PINCache/Cartfile | 2 +- .../UrlGet/Vendor/PINCache/Cartfile.resolved | 2 +- .../PINOperation/.github/workflows/ci.yml | 80 +++ .../PINOperation/.github_changelog_generator | 3 + .../Checkouts/PINOperation/.gitignore | 3 + .../Carthage/Checkouts/PINOperation/BUCK | 5 +- .../Checkouts/PINOperation/CHANGELOG.md | 27 +- .../PINOperation/CI/exclude-from-build.json | 4 +- .../Checkouts/PINOperation/CODE_OF_CONDUCT.md | 40 ++ .../project.pbxproj | 391 +++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../PINOperationExample/AppDelegate.swift | 31 + .../AppIcon.appiconset/Contents.json | 98 ++++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 + .../Example/PINOperationExample/Info.plist | 41 ++ .../PINOperationExample/MainViewController.h | 17 + .../PINOperationExample/MainViewController.m | 41 ++ .../PINOperationExample-Bridging-Header.h | 1 + .../Checkouts/PINOperation/Example/Podfile | 6 + .../PINOperation/Example/Podfile.lock | 16 + .../PINOperation/PINOperation.podspec | 4 +- .../PINOperation.xcodeproj/project.pbxproj | 146 ++++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcschemes/PINOperation-macOS.xcscheme | 4 +- .../xcschemes/PINOperation-tvOS.xcscheme | 4 +- .../xcschemes/PINOperation.xcscheme | 4 +- .../Checkouts/PINOperation/Package.swift | 18 + .../Carthage/Checkouts/PINOperation/README.md | 4 +- .../Checkouts/PINOperation/RELEASE.md | 13 + .../PINOperation/Source/PINOperation.h | 8 +- .../PINOperation/Source/PINOperationGroup.m | 2 +- .../PINOperation/Source/PINOperationQueue.m | 43 +- .../Tests/PINOperationGroupTests.m | 5 +- .../Tests/PINOperationQueueTests.m | 9 +- sample/UrlGet/Vendor/PINCache/Dangerfile | 23 - sample/UrlGet/Vendor/PINCache/Gemfile | 4 - sample/UrlGet/Vendor/PINCache/Makefile | 18 +- .../UrlGet/Vendor/PINCache/PINCache.podspec | 6 +- .../PINCache.xcodeproj/project.pbxproj | 364 ++++++------ .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcschemes/PINCache-macOS.xcscheme | 4 +- .../xcschemes/PINCache-tvOS.xcscheme | 4 +- .../xcshareddata/xcschemes/PINCache.xcscheme | 4 +- .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + sample/UrlGet/Vendor/PINCache/Package.swift | 47 ++ sample/UrlGet/Vendor/PINCache/README.md | 4 +- sample/UrlGet/Vendor/PINCache/RELEASE.md | 13 + .../UrlGet/Vendor/PINCache/Scripts/release.sh | 98 ++++ .../PINCache/Scripts/tag-release-branch.sh | 12 + .../UrlGet/Vendor/PINCache/Source/PINCache.h | 33 +- .../UrlGet/Vendor/PINCache/Source/PINCache.m | 96 ++- .../Vendor/PINCache/Source/PINCaching.h | 75 ++- .../Vendor/PINCache/Source/PINDiskCache.h | 112 +++- .../Vendor/PINCache/Source/PINDiskCache.m | 551 +++++++++++++----- .../Vendor/PINCache/Source/PINMemoryCache.h | 16 +- .../Vendor/PINCache/Source/PINMemoryCache.m | 239 ++++++-- .../PINCache/Tests/NSDate+PINCacheTests.h | 15 + .../PINCache/Tests/NSDate+PINCacheTests.m | 50 ++ .../Vendor/PINCache/Tests/PINCacheTests.m | 469 ++++++++++++--- .../Tests/PINDiskCache+PINCacheTests.h | 16 + .../Tests/PINDiskCache+PINCacheTests.m | 28 + .../Headers/Private/PINCache-prefix.pch | 3 + .../Public/Arc-exception-safe/PINCache.h | 1 + .../Arc-exception-safe/PINCacheMacros.h | 1 + .../PINCacheObjectSubscripting.h | 1 + .../Public/Arc-exception-safe/PINCaching.h | 1 + .../Public/Arc-exception-safe/PINDiskCache.h | 1 + .../Arc-exception-safe/PINMemoryCache.h | 1 + .../Headers/Public/Core/PINCache.h | 1 + .../Headers/Public/Core/PINCacheMacros.h | 1 + .../Public/Core/PINCacheObjectSubscripting.h | 1 + .../Headers/Public/Core/PINCaching.h | 1 + .../Headers/Public/Core/PINDiskCache.h | 1 + .../Headers/Public/Core/PINMemoryCache.h | 1 + .../{BUILD => BUILD.bazel} | 0 .../UrlGet/Vendor/PINOperation/.pod-version | 2 +- .../PINOperation/{BUILD => BUILD.bazel} | 182 ++++-- .../Headers/Private/PINOperation-prefix.pch | 3 + .../Public/PINOperation_cxx/PINOperation.h | 1 + .../PINOperation_cxx/PINOperationGroup.h | 1 + .../PINOperation_cxx/PINOperationMacros.h | 1 + .../PINOperation_cxx/PINOperationQueue.h | 1 + .../PINOperation_cxx/PINOperationTypes.h | 1 + .../{BUILD => BUILD.bazel} | 0 .../Vendor/rules_pods/BazelExtensions/BUILD | 6 + .../BazelExtensions/LLVM.LICENSE.TXT | 69 +++ .../rules_pods/BazelExtensions/extensions.bzl | 152 +++-- .../BazelExtensions/headermap_builder.py | 39 ++ .../BazelExtensions/headermap_tool.py | 301 ++++++++++ .../rules_pods/BazelExtensions/workspace.bzl | 49 +- 129 files changed, 4297 insertions(+), 916 deletions(-) rename sample/UrlGet/Vendor/GoogleAppIndexing/{BUILD => BUILD.bazel} (58%) create mode 100644 sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Private/GoogleAppIndexing-prefix.pch create mode 120000 sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GSDAppIndexing.h create mode 120000 sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GSDDeepLink.h create mode 120000 sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GoogleAppIndexing.h rename sample/UrlGet/Vendor/GoogleAppIndexing/pod_support_buildable/{BUILD => BUILD.bazel} (100%) rename sample/UrlGet/Vendor/GoogleAuthUtilities/{BUILD => BUILD.bazel} (66%) create mode 100644 sample/UrlGet/Vendor/GoogleAuthUtilities/pod_support/Headers/Private/GoogleAuthUtilities-prefix.pch rename sample/UrlGet/Vendor/GoogleAuthUtilities/pod_support_buildable/{BUILD => BUILD.bazel} (100%) rename sample/UrlGet/Vendor/GoogleNetworkingUtilities/{BUILD => BUILD.bazel} (63%) create mode 100644 sample/UrlGet/Vendor/GoogleNetworkingUtilities/pod_support/Headers/Private/GoogleNetworkingUtilities-prefix.pch rename sample/UrlGet/Vendor/GoogleNetworkingUtilities/pod_support_buildable/{BUILD => BUILD.bazel} (100%) rename sample/UrlGet/Vendor/GoogleSymbolUtilities/{BUILD => BUILD.bazel} (63%) create mode 100644 sample/UrlGet/Vendor/GoogleSymbolUtilities/pod_support/Headers/Private/GoogleSymbolUtilities-prefix.pch rename sample/UrlGet/Vendor/GoogleSymbolUtilities/pod_support_buildable/{BUILD => BUILD.bazel} (100%) delete mode 100644 sample/UrlGet/Vendor/PINCache/.buckconfig create mode 100644 sample/UrlGet/Vendor/PINCache/.github/workflows/ci.yaml create mode 100644 sample/UrlGet/Vendor/PINCache/.github/workflows/publish_release.yml create mode 100644 sample/UrlGet/Vendor/PINCache/.github_changelog_generator delete mode 100644 sample/UrlGet/Vendor/PINCache/.travis.yml delete mode 100755 sample/UrlGet/Vendor/PINCache/BUCK rename sample/UrlGet/Vendor/PINCache/{BUILD => BUILD.bazel} (67%) delete mode 100755 sample/UrlGet/Vendor/PINCache/CI/build.sh delete mode 100644 sample/UrlGet/Vendor/PINCache/CI/exclude-from-build.json create mode 100644 sample/UrlGet/Vendor/PINCache/CODE_OF_CONDUCT.md create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.github/workflows/ci.yml create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.github_changelog_generator create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CODE_OF_CONDUCT.md create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.pbxproj create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcworkspace/contents.xcworkspacedata create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/AppDelegate.swift create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/Assets.xcassets/Contents.json create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/Base.lproj/LaunchScreen.storyboard create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/Info.plist create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/MainViewController.h create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/MainViewController.m create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/PINOperationExample-Bridging-Header.h create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/Podfile create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/Podfile.lock create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Package.swift create mode 100644 sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/RELEASE.md delete mode 100644 sample/UrlGet/Vendor/PINCache/Dangerfile delete mode 100644 sample/UrlGet/Vendor/PINCache/Gemfile create mode 100644 sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 sample/UrlGet/Vendor/PINCache/PINCache.xcworkspace/contents.xcworkspacedata create mode 100644 sample/UrlGet/Vendor/PINCache/PINCache.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 sample/UrlGet/Vendor/PINCache/Package.swift create mode 100644 sample/UrlGet/Vendor/PINCache/RELEASE.md create mode 100755 sample/UrlGet/Vendor/PINCache/Scripts/release.sh create mode 100755 sample/UrlGet/Vendor/PINCache/Scripts/tag-release-branch.sh create mode 100644 sample/UrlGet/Vendor/PINCache/Tests/NSDate+PINCacheTests.h create mode 100644 sample/UrlGet/Vendor/PINCache/Tests/NSDate+PINCacheTests.m create mode 100644 sample/UrlGet/Vendor/PINCache/Tests/PINDiskCache+PINCacheTests.h create mode 100644 sample/UrlGet/Vendor/PINCache/Tests/PINDiskCache+PINCacheTests.m create mode 100644 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Private/PINCache-prefix.pch create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCache.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCacheMacros.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCacheObjectSubscripting.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCaching.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINDiskCache.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINMemoryCache.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCache.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCacheMacros.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCacheObjectSubscripting.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCaching.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINDiskCache.h create mode 120000 sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINMemoryCache.h rename sample/UrlGet/Vendor/PINCache/pod_support_buildable/{BUILD => BUILD.bazel} (100%) rename sample/UrlGet/Vendor/PINOperation/{BUILD => BUILD.bazel} (59%) create mode 100644 sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Private/PINOperation-prefix.pch create mode 120000 sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperation.h create mode 120000 sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationGroup.h create mode 120000 sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationMacros.h create mode 120000 sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationQueue.h create mode 120000 sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationTypes.h rename sample/UrlGet/Vendor/PINOperation/pod_support_buildable/{BUILD => BUILD.bazel} (100%) create mode 100644 sample/UrlGet/Vendor/rules_pods/BazelExtensions/LLVM.LICENSE.TXT create mode 100755 sample/UrlGet/Vendor/rules_pods/BazelExtensions/headermap_builder.py create mode 100755 sample/UrlGet/Vendor/rules_pods/BazelExtensions/headermap_tool.py diff --git a/sample/UrlGet/Makefile b/sample/UrlGet/Makefile index ec6713bb..d06254f3 100644 --- a/sample/UrlGet/Makefile +++ b/sample/UrlGet/Makefile @@ -2,6 +2,9 @@ IMPORT_INDEX=bazel-out/ios-x86_64-min9.3-applebin_ios-ios_x86_64-dbg/bin/index-s EXEC_ROOT=$(shell tools/bazelwrapper info execution_root) DERIVEDDATA=$(shell find ~/Library/Developer/Xcode/DerivedData/ -name FocusXcode-*) +deps: + tools/bazelwrapper run @rules_pods//:update_pods -- --src_root $$PWD + import: index-import -remap "$(EXEC_ROOT)=$(PWD)" $(IMPORT_INDEX) $(DERIVEDDATA)/Index/DataStore @@ -13,4 +16,3 @@ disable-indexing: enable-indexing: defaults write com.apple.dt.XCode IDEIndexDisable 0 - diff --git a/sample/UrlGet/Pods.WORKSPACE b/sample/UrlGet/Pods.WORKSPACE index ab212c74..69641f97 100644 --- a/sample/UrlGet/Pods.WORKSPACE +++ b/sample/UrlGet/Pods.WORKSPACE @@ -7,7 +7,7 @@ new_pod_repository( new_pod_repository( name = "PINCache", - url = "https://github.com/pinterest/PINCache/archive/f9f1e551d6a78d74f5528e43a8575f9d2d329e7d.zip", + url = "https://github.com/pinterest/PINCache/archive/3.0.3.zip", owner = "@ios-cx", ) diff --git a/sample/UrlGet/Vendor/GoogleAppIndexing/.pod-version b/sample/UrlGet/Vendor/GoogleAppIndexing/.pod-version index 9fc7e1fd..7c686ec7 100644 --- a/sample/UrlGet/Vendor/GoogleAppIndexing/.pod-version +++ b/sample/UrlGet/Vendor/GoogleAppIndexing/.pod-version @@ -1 +1 @@ --3247681909583964502-6870052013340196113-8379802094390313607 \ No newline at end of file +-482217743111471736155383679033427625333341535302669453200 \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleAppIndexing/BUILD b/sample/UrlGet/Vendor/GoogleAppIndexing/BUILD.bazel similarity index 58% rename from sample/UrlGet/Vendor/GoogleAppIndexing/BUILD rename to sample/UrlGet/Vendor/GoogleAppIndexing/BUILD.bazel index 35051675..cfcb74cc 100644 --- a/sample/UrlGet/Vendor/GoogleAppIndexing/BUILD +++ b/sample/UrlGet/Vendor/GoogleAppIndexing/BUILD.bazel @@ -2,10 +2,10 @@ load('@build_bazel_rules_apple//apple:resources.bzl', 'apple_bundle_import') load('@build_bazel_rules_apple//apple:apple.bzl', 'apple_static_framework_import') load( "//Vendor/rules_pods/BazelExtensions:extensions.bzl", - "pch_with_name_hint", "acknowledged_target", "gen_module_map", - "gen_includes" + "gen_includes", + "headermap" ) # Add a config setting release for compilation mode # Assume that people are using `opt` for release mode @@ -17,59 +17,109 @@ config_setting( "compilation_mode": "opt" } ) +config_setting( + name = "osxCase", + values = { + "apple_platform_type": "macos" + } +) +config_setting( + name = "tvosCase", + values = { + "apple_platform_type": "tvos" + } +) +config_setting( + name = "watchosCase", + values = { + "apple_platform_type": "watchos" + } +) filegroup( - name = "GoogleAppIndexing_hdrs", + name = "GoogleAppIndexing_package_hdrs", + srcs = [ + "GoogleAppIndexing_direct_hdrs" + ], + visibility = [ + "//visibility:public" + ] +) +filegroup( + name = "GoogleAppIndexing_direct_hdrs", srcs = glob( - [ - "pod_support/Headers/Public/**/*" - ], + glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ) + glob( + [ + "Changelog/**/*.h", + "Changelog/**/*.hpp", + "Changelog/**/*.hxx" + ], + exclude_directories = 1 + ), exclude_directories = 1 - ) + glob( - [ - "Changelog/**/*.h", - "Changelog/**/*.hpp", - "Changelog/**/*.hxx" - ], + ), + visibility = [ + "//visibility:public" + ] +) +filegroup( + name = "GoogleAppIndexing_hdrs", + srcs = glob( + glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ) + glob( + [ + "Changelog/**/*.h", + "Changelog/**/*.hpp", + "Changelog/**/*.hxx" + ], + exclude_directories = 1 + ), exclude_directories = 1 ), visibility = [ "//visibility:public" ] ) +headermap( + name = "GoogleAppIndexing_hmap", + namespace = "GoogleAppIndexing", + hdrs = [ + "GoogleAppIndexing_package_hdrs", + ":GoogleAppIndexing_hdrs" + ], + deps = [ + ":GoogleAppIndexing_VendoredFrameworks" + ], + visibility = [ + "//visibility:public" + ] +) gen_includes( name = "GoogleAppIndexing_includes", include = [ "Vendor/GoogleAppIndexing/pod_support/Headers/Public/" ] ) -gen_module_map( - "GoogleAppIndexing", - "GoogleAppIndexing_module_map", - "GoogleAppIndexing", - [ - "GoogleAppIndexing_hdrs" - ] -) objc_library( name = "GoogleAppIndexing", enable_modules = 1, hdrs = [ - ":GoogleAppIndexing_hdrs", - ":GoogleAppIndexing_module_map_module_map_file" - ], - pch = pch_with_name_hint( - "GoogleAppIndexing", - [] - ), - includes = [ - "GoogleAppIndexing_module_map" + ":GoogleAppIndexing_hdrs" ], + pch = "pod_support/Headers/Private/GoogleAppIndexing-prefix.pch", sdk_frameworks = [ "CoreText", "SafariServices" ], deps = [ - ":GoogleAppIndexing_Bundle_GoogleAppIndexingResources", ":GoogleAppIndexing_VendoredFrameworks", ":GoogleAppIndexing_includes" ], @@ -100,7 +150,7 @@ objc_library( ) + [ "-IVendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/" ] + [ - "-fmodule-name=GoogleAppIndexing_pod_module" + "-fmodule-name=GoogleAppIndexing" ], data = [ ":GoogleAppIndexing_Bundle_GoogleAppIndexingResources" @@ -123,6 +173,11 @@ apple_bundle_import( exclude_directories = 1 ) ) +acknowledged_target( + name = "GoogleAppIndexing_Bundle_GoogleAppIndexingResources_acknowledgement", + deps = [], + value = "//Vendor/GoogleAppIndexing/pod_support_buildable:acknowledgement_fragment" +) apple_static_framework_import( name = "GoogleAppIndexing_VendoredFrameworks", framework_imports = glob( @@ -134,4 +189,9 @@ apple_static_framework_import( visibility = [ "//visibility:public" ] +) +acknowledged_target( + name = "GoogleAppIndexing_VendoredFrameworks_acknowledgement", + deps = [], + value = "//Vendor/GoogleAppIndexing/pod_support_buildable:acknowledgement_fragment" ) \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Private/GoogleAppIndexing-prefix.pch b/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Private/GoogleAppIndexing-prefix.pch new file mode 100644 index 00000000..7bb570ba --- /dev/null +++ b/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Private/GoogleAppIndexing-prefix.pch @@ -0,0 +1,11 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GSDAppIndexing.h b/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GSDAppIndexing.h new file mode 120000 index 00000000..577084ce --- /dev/null +++ b/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GSDAppIndexing.h @@ -0,0 +1 @@ +../../../../Frameworks/GoogleAppIndexing.framework/Headers/GSDAppIndexing.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GSDDeepLink.h b/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GSDDeepLink.h new file mode 120000 index 00000000..b8406138 --- /dev/null +++ b/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GSDDeepLink.h @@ -0,0 +1 @@ +../../../../Frameworks/GoogleAppIndexing.framework/Headers/GSDDeepLink.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GoogleAppIndexing.h b/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GoogleAppIndexing.h new file mode 120000 index 00000000..e67165e0 --- /dev/null +++ b/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support/Headers/Public/GoogleAppIndexing/GoogleAppIndexing.h @@ -0,0 +1 @@ +../../../../Frameworks/GoogleAppIndexing.framework/Headers/GoogleAppIndexing.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support_buildable/BUILD b/sample/UrlGet/Vendor/GoogleAppIndexing/pod_support_buildable/BUILD.bazel similarity index 100% rename from sample/UrlGet/Vendor/GoogleAppIndexing/pod_support_buildable/BUILD rename to sample/UrlGet/Vendor/GoogleAppIndexing/pod_support_buildable/BUILD.bazel diff --git a/sample/UrlGet/Vendor/GoogleAuthUtilities/.pod-version b/sample/UrlGet/Vendor/GoogleAuthUtilities/.pod-version index b3b56388..82e0a288 100644 --- a/sample/UrlGet/Vendor/GoogleAuthUtilities/.pod-version +++ b/sample/UrlGet/Vendor/GoogleAuthUtilities/.pod-version @@ -1 +1 @@ --3247681909583964502-6870052013340196113-7670020901795115885 \ No newline at end of file +-482217743111471736155383679033427625331143402063872266254 \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleAuthUtilities/BUILD b/sample/UrlGet/Vendor/GoogleAuthUtilities/BUILD.bazel similarity index 66% rename from sample/UrlGet/Vendor/GoogleAuthUtilities/BUILD rename to sample/UrlGet/Vendor/GoogleAuthUtilities/BUILD.bazel index a39adce6..6be9fc9b 100644 --- a/sample/UrlGet/Vendor/GoogleAuthUtilities/BUILD +++ b/sample/UrlGet/Vendor/GoogleAuthUtilities/BUILD.bazel @@ -1,10 +1,10 @@ load('@build_bazel_rules_apple//apple:apple.bzl', 'apple_static_framework_import') load( "//Vendor/rules_pods/BazelExtensions:extensions.bzl", - "pch_with_name_hint", "acknowledged_target", "gen_module_map", - "gen_includes" + "gen_includes", + "headermap" ) # Add a config setting release for compilation mode # Assume that people are using `opt` for release mode @@ -16,6 +16,45 @@ config_setting( "compilation_mode": "opt" } ) +config_setting( + name = "osxCase", + values = { + "apple_platform_type": "macos" + } +) +config_setting( + name = "tvosCase", + values = { + "apple_platform_type": "tvos" + } +) +config_setting( + name = "watchosCase", + values = { + "apple_platform_type": "watchos" + } +) +filegroup( + name = "GoogleAuthUtilities_package_hdrs", + srcs = [ + "GoogleAuthUtilities_direct_hdrs" + ], + visibility = [ + "//visibility:public" + ] +) +filegroup( + name = "GoogleAuthUtilities_direct_hdrs", + srcs = glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ), + visibility = [ + "//visibility:public" + ] +) filegroup( name = "GoogleAuthUtilities_hdrs", srcs = glob( @@ -28,34 +67,35 @@ filegroup( "//visibility:public" ] ) +headermap( + name = "GoogleAuthUtilities_hmap", + namespace = "GoogleAuthUtilities", + hdrs = [ + "GoogleAuthUtilities_package_hdrs", + ":GoogleAuthUtilities_hdrs" + ], + deps = [ + "//Vendor/GoogleNetworkingUtilities:GoogleNetworkingUtilities", + "//Vendor/GoogleSymbolUtilities:GoogleSymbolUtilities", + ":GoogleAuthUtilities_VendoredFrameworks" + ], + visibility = [ + "//visibility:public" + ] +) gen_includes( name = "GoogleAuthUtilities_includes", include = [ "Vendor/GoogleAuthUtilities/pod_support/Headers/Public/" ] ) -gen_module_map( - "GoogleAuthUtilities", - "GoogleAuthUtilities_module_map", - "GoogleAuthUtilities", - [ - "GoogleAuthUtilities_hdrs" - ] -) objc_library( name = "GoogleAuthUtilities", enable_modules = 1, hdrs = [ - ":GoogleAuthUtilities_hdrs", - ":GoogleAuthUtilities_module_map_module_map_file" - ], - pch = pch_with_name_hint( - "GoogleAuthUtilities", - [] - ), - includes = [ - "GoogleAuthUtilities_module_map" + ":GoogleAuthUtilities_hdrs" ], + pch = "pod_support/Headers/Private/GoogleAuthUtilities-prefix.pch", sdk_frameworks = [ "Security", "SystemConfiguration" @@ -93,7 +133,7 @@ objc_library( ) + [ "-IVendor/GoogleAuthUtilities/pod_support/Headers/Public/GoogleAuthUtilities/" ] + [ - "-fmodule-name=GoogleAuthUtilities_pod_module" + "-fmodule-name=GoogleAuthUtilities" ], data = glob( [ @@ -124,4 +164,9 @@ apple_static_framework_import( visibility = [ "//visibility:public" ] +) +acknowledged_target( + name = "GoogleAuthUtilities_VendoredFrameworks_acknowledgement", + deps = [], + value = "//Vendor/GoogleAuthUtilities/pod_support_buildable:acknowledgement_fragment" ) \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleAuthUtilities/pod_support/Headers/Private/GoogleAuthUtilities-prefix.pch b/sample/UrlGet/Vendor/GoogleAuthUtilities/pod_support/Headers/Private/GoogleAuthUtilities-prefix.pch new file mode 100644 index 00000000..7bb570ba --- /dev/null +++ b/sample/UrlGet/Vendor/GoogleAuthUtilities/pod_support/Headers/Private/GoogleAuthUtilities-prefix.pch @@ -0,0 +1,11 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleAuthUtilities/pod_support_buildable/BUILD b/sample/UrlGet/Vendor/GoogleAuthUtilities/pod_support_buildable/BUILD.bazel similarity index 100% rename from sample/UrlGet/Vendor/GoogleAuthUtilities/pod_support_buildable/BUILD rename to sample/UrlGet/Vendor/GoogleAuthUtilities/pod_support_buildable/BUILD.bazel diff --git a/sample/UrlGet/Vendor/GoogleNetworkingUtilities/.pod-version b/sample/UrlGet/Vendor/GoogleNetworkingUtilities/.pod-version index 4bc7179a..6eaa6db9 100644 --- a/sample/UrlGet/Vendor/GoogleNetworkingUtilities/.pod-version +++ b/sample/UrlGet/Vendor/GoogleNetworkingUtilities/.pod-version @@ -1 +1 @@ --3247681909583964502-6870052013340196113-570112702148592745 \ No newline at end of file +-482217743111471736155383679033427625336885344944788458658 \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleNetworkingUtilities/BUILD b/sample/UrlGet/Vendor/GoogleNetworkingUtilities/BUILD.bazel similarity index 63% rename from sample/UrlGet/Vendor/GoogleNetworkingUtilities/BUILD rename to sample/UrlGet/Vendor/GoogleNetworkingUtilities/BUILD.bazel index e5284fbb..c4a4beed 100644 --- a/sample/UrlGet/Vendor/GoogleNetworkingUtilities/BUILD +++ b/sample/UrlGet/Vendor/GoogleNetworkingUtilities/BUILD.bazel @@ -1,10 +1,10 @@ load('@build_bazel_rules_apple//apple:apple.bzl', 'apple_static_framework_import') load( "//Vendor/rules_pods/BazelExtensions:extensions.bzl", - "pch_with_name_hint", "acknowledged_target", "gen_module_map", - "gen_includes" + "gen_includes", + "headermap" ) # Add a config setting release for compilation mode # Assume that people are using `opt` for release mode @@ -16,6 +16,45 @@ config_setting( "compilation_mode": "opt" } ) +config_setting( + name = "osxCase", + values = { + "apple_platform_type": "macos" + } +) +config_setting( + name = "tvosCase", + values = { + "apple_platform_type": "tvos" + } +) +config_setting( + name = "watchosCase", + values = { + "apple_platform_type": "watchos" + } +) +filegroup( + name = "GoogleNetworkingUtilities_package_hdrs", + srcs = [ + "GoogleNetworkingUtilities_direct_hdrs" + ], + visibility = [ + "//visibility:public" + ] +) +filegroup( + name = "GoogleNetworkingUtilities_direct_hdrs", + srcs = glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ), + visibility = [ + "//visibility:public" + ] +) filegroup( name = "GoogleNetworkingUtilities_hdrs", srcs = glob( @@ -28,34 +67,34 @@ filegroup( "//visibility:public" ] ) +headermap( + name = "GoogleNetworkingUtilities_hmap", + namespace = "GoogleNetworkingUtilities", + hdrs = [ + "GoogleNetworkingUtilities_package_hdrs", + ":GoogleNetworkingUtilities_hdrs" + ], + deps = [ + "//Vendor/GoogleSymbolUtilities:GoogleSymbolUtilities", + ":GoogleNetworkingUtilities_VendoredFrameworks" + ], + visibility = [ + "//visibility:public" + ] +) gen_includes( name = "GoogleNetworkingUtilities_includes", include = [ "Vendor/GoogleNetworkingUtilities/pod_support/Headers/Public/" ] ) -gen_module_map( - "GoogleNetworkingUtilities", - "GoogleNetworkingUtilities_module_map", - "GoogleNetworkingUtilities", - [ - "GoogleNetworkingUtilities_hdrs" - ] -) objc_library( name = "GoogleNetworkingUtilities", enable_modules = 1, hdrs = [ - ":GoogleNetworkingUtilities_hdrs", - ":GoogleNetworkingUtilities_module_map_module_map_file" - ], - pch = pch_with_name_hint( - "GoogleNetworkingUtilities", - [] - ), - includes = [ - "GoogleNetworkingUtilities_module_map" + ":GoogleNetworkingUtilities_hdrs" ], + pch = "pod_support/Headers/Private/GoogleNetworkingUtilities-prefix.pch", sdk_frameworks = [ "Security" ], @@ -91,7 +130,7 @@ objc_library( ) + [ "-IVendor/GoogleNetworkingUtilities/pod_support/Headers/Public/GoogleNetworkingUtilities/" ] + [ - "-fmodule-name=GoogleNetworkingUtilities_pod_module" + "-fmodule-name=GoogleNetworkingUtilities" ], visibility = [ "//visibility:public" @@ -115,4 +154,9 @@ apple_static_framework_import( visibility = [ "//visibility:public" ] +) +acknowledged_target( + name = "GoogleNetworkingUtilities_VendoredFrameworks_acknowledgement", + deps = [], + value = "//Vendor/GoogleNetworkingUtilities/pod_support_buildable:acknowledgement_fragment" ) \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleNetworkingUtilities/pod_support/Headers/Private/GoogleNetworkingUtilities-prefix.pch b/sample/UrlGet/Vendor/GoogleNetworkingUtilities/pod_support/Headers/Private/GoogleNetworkingUtilities-prefix.pch new file mode 100644 index 00000000..7bb570ba --- /dev/null +++ b/sample/UrlGet/Vendor/GoogleNetworkingUtilities/pod_support/Headers/Private/GoogleNetworkingUtilities-prefix.pch @@ -0,0 +1,11 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleNetworkingUtilities/pod_support_buildable/BUILD b/sample/UrlGet/Vendor/GoogleNetworkingUtilities/pod_support_buildable/BUILD.bazel similarity index 100% rename from sample/UrlGet/Vendor/GoogleNetworkingUtilities/pod_support_buildable/BUILD rename to sample/UrlGet/Vendor/GoogleNetworkingUtilities/pod_support_buildable/BUILD.bazel diff --git a/sample/UrlGet/Vendor/GoogleSymbolUtilities/.pod-version b/sample/UrlGet/Vendor/GoogleSymbolUtilities/.pod-version index af455d4f..73175364 100644 --- a/sample/UrlGet/Vendor/GoogleSymbolUtilities/.pod-version +++ b/sample/UrlGet/Vendor/GoogleSymbolUtilities/.pod-version @@ -1 +1 @@ --3247681909583964502-68700520133401961136121121555519423782 \ No newline at end of file +-48221774311147173615538367903342762533-3711548340224502087 \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleSymbolUtilities/BUILD b/sample/UrlGet/Vendor/GoogleSymbolUtilities/BUILD.bazel similarity index 63% rename from sample/UrlGet/Vendor/GoogleSymbolUtilities/BUILD rename to sample/UrlGet/Vendor/GoogleSymbolUtilities/BUILD.bazel index 72630095..87396d5b 100644 --- a/sample/UrlGet/Vendor/GoogleSymbolUtilities/BUILD +++ b/sample/UrlGet/Vendor/GoogleSymbolUtilities/BUILD.bazel @@ -1,10 +1,10 @@ load('@build_bazel_rules_apple//apple:apple.bzl', 'apple_static_framework_import') load( "//Vendor/rules_pods/BazelExtensions:extensions.bzl", - "pch_with_name_hint", "acknowledged_target", "gen_module_map", - "gen_includes" + "gen_includes", + "headermap" ) # Add a config setting release for compilation mode # Assume that people are using `opt` for release mode @@ -16,6 +16,45 @@ config_setting( "compilation_mode": "opt" } ) +config_setting( + name = "osxCase", + values = { + "apple_platform_type": "macos" + } +) +config_setting( + name = "tvosCase", + values = { + "apple_platform_type": "tvos" + } +) +config_setting( + name = "watchosCase", + values = { + "apple_platform_type": "watchos" + } +) +filegroup( + name = "GoogleSymbolUtilities_package_hdrs", + srcs = [ + "GoogleSymbolUtilities_direct_hdrs" + ], + visibility = [ + "//visibility:public" + ] +) +filegroup( + name = "GoogleSymbolUtilities_direct_hdrs", + srcs = glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ), + visibility = [ + "//visibility:public" + ] +) filegroup( name = "GoogleSymbolUtilities_hdrs", srcs = glob( @@ -28,34 +67,33 @@ filegroup( "//visibility:public" ] ) +headermap( + name = "GoogleSymbolUtilities_hmap", + namespace = "GoogleSymbolUtilities", + hdrs = [ + "GoogleSymbolUtilities_package_hdrs", + ":GoogleSymbolUtilities_hdrs" + ], + deps = [ + ":GoogleSymbolUtilities_VendoredFrameworks" + ], + visibility = [ + "//visibility:public" + ] +) gen_includes( name = "GoogleSymbolUtilities_includes", include = [ "Vendor/GoogleSymbolUtilities/pod_support/Headers/Public/" ] ) -gen_module_map( - "GoogleSymbolUtilities", - "GoogleSymbolUtilities_module_map", - "GoogleSymbolUtilities", - [ - "GoogleSymbolUtilities_hdrs" - ] -) objc_library( name = "GoogleSymbolUtilities", enable_modules = 1, hdrs = [ - ":GoogleSymbolUtilities_hdrs", - ":GoogleSymbolUtilities_module_map_module_map_file" - ], - pch = pch_with_name_hint( - "GoogleSymbolUtilities", - [] - ), - includes = [ - "GoogleSymbolUtilities_module_map" + ":GoogleSymbolUtilities_hdrs" ], + pch = "pod_support/Headers/Private/GoogleSymbolUtilities-prefix.pch", deps = [ ":GoogleSymbolUtilities_VendoredFrameworks", ":GoogleSymbolUtilities_includes" @@ -87,7 +125,7 @@ objc_library( ) + [ "-IVendor/GoogleSymbolUtilities/pod_support/Headers/Public/GoogleSymbolUtilities/" ] + [ - "-fmodule-name=GoogleSymbolUtilities_pod_module" + "-fmodule-name=GoogleSymbolUtilities" ], visibility = [ "//visibility:public" @@ -109,4 +147,9 @@ apple_static_framework_import( visibility = [ "//visibility:public" ] +) +acknowledged_target( + name = "GoogleSymbolUtilities_VendoredFrameworks_acknowledgement", + deps = [], + value = "//Vendor/GoogleSymbolUtilities/pod_support_buildable:acknowledgement_fragment" ) \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleSymbolUtilities/pod_support/Headers/Private/GoogleSymbolUtilities-prefix.pch b/sample/UrlGet/Vendor/GoogleSymbolUtilities/pod_support/Headers/Private/GoogleSymbolUtilities-prefix.pch new file mode 100644 index 00000000..7bb570ba --- /dev/null +++ b/sample/UrlGet/Vendor/GoogleSymbolUtilities/pod_support/Headers/Private/GoogleSymbolUtilities-prefix.pch @@ -0,0 +1,11 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif \ No newline at end of file diff --git a/sample/UrlGet/Vendor/GoogleSymbolUtilities/pod_support_buildable/BUILD b/sample/UrlGet/Vendor/GoogleSymbolUtilities/pod_support_buildable/BUILD.bazel similarity index 100% rename from sample/UrlGet/Vendor/GoogleSymbolUtilities/pod_support_buildable/BUILD rename to sample/UrlGet/Vendor/GoogleSymbolUtilities/pod_support_buildable/BUILD.bazel diff --git a/sample/UrlGet/Vendor/PINCache/.buckconfig b/sample/UrlGet/Vendor/PINCache/.buckconfig deleted file mode 100644 index 2ea97ebd..00000000 --- a/sample/UrlGet/Vendor/PINCache/.buckconfig +++ /dev/null @@ -1,21 +0,0 @@ -[cxx] - default_platform = iphonesimulator-x86_64 - combined_preprocess_and_compile = true - -[apple] - iphonesimulator_target_sdk_version = 5.0 - iphoneos_target_sdk_version = 5.0 - macosx_target_sdk_version = 10.7 - xctool_default_destination_specifier = platform=iOS Simulator, name=iPhone 6, OS=10.2 - -[alias] - lib = //:PINCache - tests = //tests:Tests - -[project] - parallel_parsing = true - ide = xcode - ignore = .buckd, \ - .hg, \ - .git, \ - buck-out, \ diff --git a/sample/UrlGet/Vendor/PINCache/.github/workflows/ci.yaml b/sample/UrlGet/Vendor/PINCache/.github/workflows/ci.yaml new file mode 100644 index 00000000..bdc6a36a --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/.github/workflows/ci.yaml @@ -0,0 +1,53 @@ +--- +name: CI + +on: + push: + branches: + - master + - 'releases/*' + pull_request: + branches: + - master + +jobs: + test: + name: Test + runs-on: macOS-latest + strategy: + matrix: + platform: ['iOS Simulator,name=iPhone 8'] + steps: + - uses: actions/checkout@v2 + - name: Test + run: make test + analyze: + name: Analyze + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - name: analyze + run: make analyze + cocoapods: + name: CocoaPods + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - name: Lint + run: make cocoapods + carthage: + name: Carthage + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - name: carthage + run: make carthage + swift-package-manager: + runs-on: macos-latest + env: + DEVELOPER_DIR: /Applications/Xcode_12.app/Contents/Developer + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Verify that PINCache can be build by SPM + run: make spm diff --git a/sample/UrlGet/Vendor/PINCache/.github/workflows/publish_release.yml b/sample/UrlGet/Vendor/PINCache/.github/workflows/publish_release.yml new file mode 100644 index 00000000..9a2cf58b --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/.github/workflows/publish_release.yml @@ -0,0 +1,39 @@ +name: Create Release +on: + workflow_dispatch: + inputs: + release-type: + description: 'The type of release. Must be major, minor or patch' + required: true +jobs: + create_release: + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + # Make sure we can lint before creating the release. + - name: Cocoapods lint + run: make cocoapods + - name: Create Release Branch + env: + GITHUB_CHANGELOG_API_KEY: ${{ secrets.GITHUB_TOKEN }} + OSS_PROJECT: PINCache + run: | + gem install github_changelog_generator + Scripts/release.sh --${{ github.event.inputs.release-type }} + git push origin HEAD + - name: Tag Release + run: Scripts/tag-release-branch.sh + - name: Publish Release + uses: actions/create-release@v1 + env: + GITHUB_CHANGELOG_API_KEY: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.RELEASE_TAG }} + release_name: ${{ env.RELEASE_TAG }} + body_path: RELEASE_NOTES.md + draft: false + - name: Push to Cocoapods + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + run: pod trunk push diff --git a/sample/UrlGet/Vendor/PINCache/.github_changelog_generator b/sample/UrlGet/Vendor/PINCache/.github_changelog_generator new file mode 100644 index 00000000..71e4626b --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/.github_changelog_generator @@ -0,0 +1,3 @@ +issues=false +since-tag=3.0.2 +future-release=3.0.3 diff --git a/sample/UrlGet/Vendor/PINCache/.gitignore b/sample/UrlGet/Vendor/PINCache/.gitignore index 7f818743..0046cbf2 100644 --- a/sample/UrlGet/Vendor/PINCache/.gitignore +++ b/sample/UrlGet/Vendor/PINCache/.gitignore @@ -23,3 +23,8 @@ xcuserdata /.buckd Carthage/Build + +# SPM +.swiftpm/ +.build/ +Package.resolved diff --git a/sample/UrlGet/Vendor/PINCache/.pod-version b/sample/UrlGet/Vendor/PINCache/.pod-version index 7394b2dd..f1f135f7 100644 --- a/sample/UrlGet/Vendor/PINCache/.pod-version +++ b/sample/UrlGet/Vendor/PINCache/.pod-version @@ -1 +1 @@ --3247681909583964502-6870052013340196113-2518053968576645255 \ No newline at end of file +-48221774311147173615538367903342762533-8513874510585422547 \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/.travis.yml b/sample/UrlGet/Vendor/PINCache/.travis.yml deleted file mode 100644 index ef93752c..00000000 --- a/sample/UrlGet/Vendor/PINCache/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: objective-c -osx_image: xcode7.3 -cache: - - bundler - - cocoapods -branches: - only: - - master -before_install: - - gem install cocoapods -v '0.39.0' -before_script: - - pod lib lint --verbose -env: - matrix: - - OS='8.4' name='iPhone 6' - - OS='latest' name='iPhone 6' -script: - - xcodebuild clean test -project tests/PINCache.xcodeproj -scheme PINCacheTests -sdk iphonesimulator -destination "platform=iOS Simulator,name=$name,OS=$OS" ONLY_ACTIVE_ARCH=NO diff --git a/sample/UrlGet/Vendor/PINCache/BUCK b/sample/UrlGet/Vendor/PINCache/BUCK deleted file mode 100755 index bbb8d2c8..00000000 --- a/sample/UrlGet/Vendor/PINCache/BUCK +++ /dev/null @@ -1,23 +0,0 @@ -apple_library( - name = 'PINCache', - exported_headers = glob(['Source/*.h']), - # PINDiskCache.m should be compiled with '-fobjc-arc-exceptions' (#105) - srcs = - glob(['Source/*.m'], excludes = ['Source/PINDiskCache.m']) + - [('Source/PINDiskCache.m', ['-fobjc-arc-exceptions'])], - preprocessor_flags = ['-fobjc-arc'], - lang_preprocessor_flags = { - 'C': ['-std=gnu99'], - 'CXX': ['-std=gnu++11', '-stdlib=libc++'], - }, - linker_flags = [ - '-weak_framework', - 'UIKit', - '-weak_framework', - 'AppKit', - ], - frameworks = [ - '$SDKROOT/System/Library/Frameworks/Foundation.framework', - ], - visibility = ['PUBLIC'], -) diff --git a/sample/UrlGet/Vendor/PINCache/BUILD b/sample/UrlGet/Vendor/PINCache/BUILD.bazel similarity index 67% rename from sample/UrlGet/Vendor/PINCache/BUILD rename to sample/UrlGet/Vendor/PINCache/BUILD.bazel index bad7fc28..b823e946 100644 --- a/sample/UrlGet/Vendor/PINCache/BUILD +++ b/sample/UrlGet/Vendor/PINCache/BUILD.bazel @@ -1,9 +1,10 @@ + load( "//Vendor/rules_pods/BazelExtensions:extensions.bzl", - "pch_with_name_hint", "acknowledged_target", "gen_module_map", - "gen_includes" + "gen_includes", + "headermap" ) # Add a config setting release for compilation mode # Assume that people are using `opt` for release mode @@ -16,17 +17,46 @@ config_setting( } ) config_setting( - name = "iosCase", + name = "osxCase", values = { - "cpu": "powerpc1" + "apple_platform_type": "macos" } ) config_setting( - name = "osxCase", + name = "tvosCase", values = { - "cpu": "powerpc2" + "apple_platform_type": "tvos" } ) +config_setting( + name = "watchosCase", + values = { + "apple_platform_type": "watchos" + } +) +filegroup( + name = "PINCache_package_hdrs", + srcs = [ + "PINCache_direct_hdrs", + "Core_direct_hdrs", + "Arc-exception-safe_direct_hdrs" + ], + visibility = [ + "//visibility:public" + ] +) +filegroup( + name = "PINCache_direct_hdrs", + srcs = glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ), + visibility = [ + "//visibility:public" + ] +) filegroup( name = "PINCache_hdrs", srcs = glob( @@ -35,8 +65,23 @@ filegroup( ], exclude_directories = 1 ) + [ - ":Core_hdrs", - ":Arc-exception-safe_hdrs" + ":Arc-exception-safe_hdrs", + ":Core_hdrs" + ], + visibility = [ + "//visibility:public" + ] +) +headermap( + name = "PINCache_hmap", + namespace = "PINCache", + hdrs = [ + "PINCache_package_hdrs", + ":PINCache_hdrs" + ], + deps = [ + ":Arc-exception-safe", + ":Core" ], visibility = [ "//visibility:public" @@ -48,28 +93,13 @@ gen_includes( "Vendor/PINCache/pod_support/Headers/Public/" ] ) -gen_module_map( - "PINCache", - "PINCache_module_map", - "PINCache", - [ - "PINCache_hdrs" - ] -) objc_library( name = "PINCache", enable_modules = 1, hdrs = [ - ":PINCache_hdrs", - ":PINCache_module_map_module_map_file" - ], - pch = pch_with_name_hint( - "PINCache", - [] - ), - includes = [ - "PINCache_module_map" + ":PINCache_hdrs" ], + pch = "pod_support/Headers/Private/PINCache-prefix.pch", sdk_frameworks = [ "Foundation" ], @@ -89,6 +119,7 @@ objc_library( ":PINCache_includes" ], copts = [ + "-Wno-everything", "-Wnon-modular-include-in-framework-module", "-g", "-stdlib=libc++", @@ -114,7 +145,7 @@ objc_library( ) + [ "-IVendor/PINCache/pod_support/Headers/Public/PINCache/" ] + [ - "-fmodule-name=PINCache_pod_module" + "-fmodule-name=PINCache" ], visibility = [ "//visibility:public" @@ -125,12 +156,40 @@ acknowledged_target( deps = [], value = "//Vendor/PINCache/pod_support_buildable:acknowledgement_fragment" ) +filegroup( + name = "Core_direct_hdrs", + srcs = glob( + glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ) + glob( + [ + "Source/*.h" + ], + exclude_directories = 1 + ), + exclude_directories = 1 + ), + visibility = [ + "//visibility:public" + ] +) filegroup( name = "Core_hdrs", srcs = glob( - [ - "Source/*.h" - ], + glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ) + glob( + [ + "Source/*.h" + ], + exclude_directories = 1 + ), exclude_directories = 1 ), visibility = [ @@ -147,6 +206,20 @@ filegroup( "//visibility:public" ] ) +headermap( + name = "Core_hmap", + namespace = "PINCache", + hdrs = [ + "PINCache_package_hdrs", + ":Core_union_hdrs" + ], + deps = [ + "//Vendor/PINOperation:PINOperation" + ], + visibility = [ + "//visibility:public" + ] +) gen_includes( name = "Core_includes", include = [ @@ -160,24 +233,18 @@ objc_library( [ "Source/*.m" ], - exclude = [ - "Source/PINDiskCache.m" - ], + exclude = glob( + [ + "Source/PINDiskCache.m" + ], + exclude_directories = 1 + ), exclude_directories = 1 ), hdrs = [ - ":Core_union_hdrs", - ":PINCache_module_map_module_map_file" - ], - pch = pch_with_name_hint( - "PINCache", - [ - "Source/**/*.pch" - ] - ), - includes = [ - "PINCache_module_map" + ":Core_hdrs" ], + pch = "pod_support/Headers/Private/PINCache-prefix.pch", sdk_frameworks = [ "Foundation" ], @@ -196,6 +263,7 @@ objc_library( ":Core_includes" ], copts = [ + "-Wno-everything", "-Wnon-modular-include-in-framework-module", "-g", "-stdlib=libc++", @@ -221,7 +289,7 @@ objc_library( ) + [ "-IVendor/PINCache/pod_support/Headers/Public/PINCache/" ] + [ - "-fmodule-name=PINCache_pod_module" + "-fmodule-name=PINCache" ], visibility = [ "//visibility:public" @@ -234,9 +302,26 @@ acknowledged_target( ], value = "//Vendor/PINCache/pod_support_buildable:acknowledgement_fragment" ) +filegroup( + name = "Arc-exception-safe_direct_hdrs", + srcs = glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ), + visibility = [ + "//visibility:public" + ] +) filegroup( name = "Arc-exception-safe_hdrs", - srcs = [], + srcs = glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ), visibility = [ "//visibility:public" ] @@ -245,7 +330,22 @@ filegroup( name = "Arc-exception-safe_union_hdrs", srcs = [ "Arc-exception-safe_hdrs", - "PINCache_hdrs" + "PINCache_hdrs", + ":Core_hdrs" + ], + visibility = [ + "//visibility:public" + ] +) +headermap( + name = "Arc-exception-safe_hmap", + namespace = "PINCache", + hdrs = [ + "PINCache_package_hdrs", + ":Arc-exception-safe_union_hdrs" + ], + deps = [ + ":Core" ], visibility = [ "//visibility:public" @@ -267,18 +367,9 @@ objc_library( exclude_directories = 1 ), hdrs = [ - ":Arc-exception-safe_union_hdrs", - ":PINCache_module_map_module_map_file" - ], - pch = pch_with_name_hint( - "PINCache", - [ - "Source/**/*.pch" - ] - ), - includes = [ - "PINCache_module_map" + ":Arc-exception-safe_hdrs" ], + pch = "pod_support/Headers/Private/PINCache-prefix.pch", sdk_frameworks = [ "Foundation" ], @@ -298,6 +389,7 @@ objc_library( ], copts = [ "-fobjc-arc-exceptions", + "-Wno-everything", "-Wnon-modular-include-in-framework-module", "-g", "-stdlib=libc++", @@ -323,7 +415,7 @@ objc_library( ) + [ "-IVendor/PINCache/pod_support/Headers/Public/PINCache/" ] + [ - "-fmodule-name=PINCache_pod_module" + "-fmodule-name=PINCache" ], visibility = [ "//visibility:public" diff --git a/sample/UrlGet/Vendor/PINCache/CHANGELOG.md b/sample/UrlGet/Vendor/PINCache/CHANGELOG.md index 4d318af2..4ad6ac04 100644 --- a/sample/UrlGet/Vendor/PINCache/CHANGELOG.md +++ b/sample/UrlGet/Vendor/PINCache/CHANGELOG.md @@ -1,6 +1,64 @@ -## master +# Changelog -* Add your own contributions to the next release on the line below this with your name. +## [3.0.3](https://github.com/Pinterest/PINCache/tree/3.0.3) (2020-10-22) + +[Full Changelog](https://github.com/Pinterest/PINCache/compare/3.0.2...3.0.3) + + +- Update PINOperation to fix imports [\#293](https://github.com/pinterest/PINCache/pull/293) ([garrettmoon](https://github.com/garrettmoon)) +- Add support for automated releases [\#292](https://github.com/pinterest/PINCache/pull/292) ([garrettmoon](https://github.com/garrettmoon)) +- Fix up imports [\#290](https://github.com/pinterest/PINCache/pull/290) ([garrettmoon](https://github.com/garrettmoon)) +- Fix build issues by removing nested PINOperation.xcodeproj [\#282](https://github.com/pinterest/PINCache/pull/282) ([elliottwilliams](https://github.com/elliottwilliams)) + +## [3.0.2](https://github.com/Pinterest/PINCache/tree/3.0.2) (2020-10-06) + +[Full Changelog](https://github.com/Pinterest/PINCache/compare/3.0.1...3.0.2) + +**Merged pull requests:** + +- Update checkout action [\#287](https://github.com/pinterest/PINCache/pull/287) ([garrettmoon](https://github.com/garrettmoon)) +- Use make commands on the CI so it actually fails [\#286](https://github.com/pinterest/PINCache/pull/286) ([garrettmoon](https://github.com/garrettmoon)) +- Added SPM support [\#283](https://github.com/pinterest/PINCache/pull/283) ([3a4oT](https://github.com/3a4oT)) +- Fix PINCaching compiling in Xcode 12.0b6 \(\#275\) [\#281](https://github.com/pinterest/PINCache/pull/281) ([sagesse-cn](https://github.com/sagesse-cn)) + +## [3.0.1](https://github.com/Pinterest/PINCache/tree/3.0.1) (2020-08-20) + +[Full Changelog](https://github.com/Pinterest/PINCache/compare/3.0.1-beta.8...3.0.1) + +**Implemented enhancements:** + +- Support Catalyst [\#272](https://github.com/pinterest/PINCache/pull/272) ([cgmaier](https://github.com/cgmaier)) + +**Merged pull requests:** + +- Update PINOperation [\#277](https://github.com/pinterest/PINCache/pull/277) ([garrettmoon](https://github.com/garrettmoon)) +- Fix PINCacheTests compiling in Xcode 12.0b4 [\#276](https://github.com/pinterest/PINCache/pull/276) ([arangato](https://github.com/arangato)) +- Remove BUCK files [\#274](https://github.com/pinterest/PINCache/pull/274) ([adlerj](https://github.com/adlerj)) +- Fix compiling in Xcode 12.0b4 [\#273](https://github.com/pinterest/PINCache/pull/273) ([zacwest](https://github.com/zacwest)) +- Fix the grammar in an assertion failure message [\#270](https://github.com/pinterest/PINCache/pull/270) ([jparise](https://github.com/jparise)) +- Add Carthage for watchOS, fix macOS min deployment target version [\#269](https://github.com/pinterest/PINCache/pull/269) ([dreampiggy](https://github.com/dreampiggy)) +- Remove the unused CI directory [\#265](https://github.com/pinterest/PINCache/pull/265) ([jparise](https://github.com/jparise)) +- Fix up analyze for github CI [\#264](https://github.com/pinterest/PINCache/pull/264) ([garrettmoon](https://github.com/garrettmoon)) +- Use correct class name in NSAssert\(\) messages [\#263](https://github.com/pinterest/PINCache/pull/263) ([jparise](https://github.com/jparise)) +- Check fileURL outside of the locked scope [\#262](https://github.com/pinterest/PINCache/pull/262) ([jparise](https://github.com/jparise)) +- Remove Danger from the project [\#261](https://github.com/pinterest/PINCache/pull/261) ([jparise](https://github.com/jparise)) +- Switch to GitHub Actions for CI [\#259](https://github.com/pinterest/PINCache/pull/259) ([jparise](https://github.com/jparise)) +- Test that the "remove object" blocks are called [\#258](https://github.com/pinterest/PINCache/pull/258) ([jparise](https://github.com/jparise)) +- Discrepancy between Header Comment and Implementation \#trivial [\#257](https://github.com/pinterest/PINCache/pull/257) ([jlaws](https://github.com/jlaws)) +- Optimization `PINMemoryCache` trim to date [\#252](https://github.com/pinterest/PINCache/pull/252) ([kinarobin](https://github.com/kinarobin)) +- Optimize `PINMemoryCache` remove objects when receive memory warning notification [\#251](https://github.com/pinterest/PINCache/pull/251) ([kinarobin](https://github.com/kinarobin)) + +## 3.0.1 -- Beta 8 +- [fix] Initing PINCache with TTL enabled should enable TTL on PINMemoryCache. [#246](https://github.com/pinterest/PINCache/pull/246) +- [performance] Return TTL cache objects without waiting for all metadata to be read. [#228](https://github.com/pinterest/PINCache/pull/228) +- [performance] Memory cache now performs some tasks such as trimming and removing experied objects with low priority. [#234](https://github.com/pinterest/PINCache/pull/234) + +## 3.0.1 -- Beta 7 +- [fix] Fix up warnings and upgrade to PINOperation 1.1.1: [#213](https://github.com/pinterest/PINCache/pull/213) +- [performance] Reduce locking churn in cleanup methods. [#212](https://github.com/pinterest/PINCache/pull/212) +- [fix] Don't set file protection unless requested. [#220](https://github.com/pinterest/PINCache/pull/220) +- [new] Add ability to set an object level TTL: [#209](https://github.com/pinterest/PINCache/pull/209) +- [performance] Improve performance of age limit trimming: [#224](https://github.com/pinterest/PINCache/pull/224) ## 3.0.1 -- Beta 6 - [fix] Add some sane limits to the disk cache: [#201]https://github.com/pinterest/PINCache/pull/201 diff --git a/sample/UrlGet/Vendor/PINCache/CI/build.sh b/sample/UrlGet/Vendor/PINCache/CI/build.sh deleted file mode 100755 index bbdb8f94..00000000 --- a/sample/UrlGet/Vendor/PINCache/CI/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -eo pipefail - -make all \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/CI/exclude-from-build.json b/sample/UrlGet/Vendor/PINCache/CI/exclude-from-build.json deleted file mode 100644 index 28cc1627..00000000 --- a/sample/UrlGet/Vendor/PINCache/CI/exclude-from-build.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "^plans/", - "^docs/", - "^README.md$", - "^CI/exclude-from-build.json$" -] \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/CODE_OF_CONDUCT.md b/sample/UrlGet/Vendor/PINCache/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..8b4e45e2 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/CODE_OF_CONDUCT.md @@ -0,0 +1,40 @@ +# Code of Conduct + +At Pinterest, we work hard to ensure that our work environment is welcoming +and inclusive to as many people as possible. We are committed to creating this +environment for everyone involved in our open source projects as well. We +welcome all participants regardless of ability, age, ethnicity, identified +gender, religion (or lack there of), sexual orientation and socioeconomic +status. + +This code of conduct details our expectations for upholding these values. + +## Good behavior + +We expect members of our community to exhibit good behavior including (but of +course not limited to): + +- Using intentional and empathetic language. +- Focusing on resolving instead of escalating conflict. +- Providing constructive feedback. + +## Unacceptable behavior + +Some examples of unacceptable behavior (again, this is not an exhaustive +list): + +- Harassment, publicly or in private. +- Trolling. +- Sexual advances (this isn’t the place for it). +- Publishing other’s personal information. +- Any behavior which would be deemed unacceptable in a professional environment. + +## Recourse + +If you are witness to or the target of unacceptable behavior, it should be +reported to Pinterest at opensource-policy@pinterest.com. All reporters will +be kept confidential and an appropriate response for each incident will be +evaluated. + +If the maintainers do not uphold and enforce this code of conduct in +good faith, community leadership will hold them accountable. \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/Cartfile b/sample/UrlGet/Vendor/PINCache/Cartfile index fba0de21..9265ddf2 100644 --- a/sample/UrlGet/Vendor/PINCache/Cartfile +++ b/sample/UrlGet/Vendor/PINCache/Cartfile @@ -1 +1 @@ -github "pinterest/PINOperation" ~> 1.1.0 \ No newline at end of file +github "pinterest/PINOperation" ~> 1.2.1 \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/Cartfile.resolved b/sample/UrlGet/Vendor/PINCache/Cartfile.resolved index d3f8bfc0..841e9a7d 100644 --- a/sample/UrlGet/Vendor/PINCache/Cartfile.resolved +++ b/sample/UrlGet/Vendor/PINCache/Cartfile.resolved @@ -1 +1 @@ -github "pinterest/PINOperation" "1.1" +github "pinterest/PINOperation" "1.2" diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.github/workflows/ci.yml b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.github/workflows/ci.yml new file mode 100644 index 00000000..cfe85acc --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +--- +name: CI + +on: + push: + branches: + - master + - 'releases/*' + pull_request: + branches: + - master + +jobs: + build: + name: Build + runs-on: macOS-latest + strategy: + matrix: + platform: ['iOS Simulator,name=iPhone 8'] + steps: + - uses: actions/checkout@v2 + - name: Analyze and Test + run: | + xcodebuild clean analyze test \ + -destination "platform=${{ matrix.platform }}" \ + -sdk "iphonesimulator" \ + -project PINOperation.xcodeproj \ + -scheme PINOperation \ + ONLY_ACTIVE_ARCH=NO \ + CODE_SIGNING_REQUIRED=NO \ + CLANG_ANALYZER_OUTPUT=plist-html \ + CLANG_ANALYZER_OUTPUT_DIR="$(pwd)/clang" \ + | xcpretty + if [[ -n `find $(pwd)/clang -name "*.html"` ]] ; then rm -rf $(pwd)/clang; exit 1; fi + rm -rf $(pwd)/clang + cocoapods: + name: CocoaPods + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - name: Lint + run: pod lib lint + carthage: + name: Carthage + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - name: Build + run: carthage build --no-skip-current + spm: + name: Swift Package Manager tests + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - name: Test + run: swift test + example: + name: Build Example project + runs-on: macOS-latest + strategy: + matrix: + platform: ['iOS Simulator,name=iPhone 8'] + steps: + - uses: actions/checkout@v2 + - name: Install Pods + run: cd Example && pod install + - name: Build + run: | + cd Example && xcodebuild clean analyze \ + -destination "platform=${{ matrix.platform }}" \ + -sdk "iphonesimulator" \ + -workspace PINOperationExample.xcworkspace \ + -scheme PINOperationExample \ + ONLY_ACTIVE_ARCH=NO \ + CODE_SIGNING_REQUIRED=NO \ + CLANG_ANALYZER_OUTPUT=plist-html \ + CLANG_ANALYZER_OUTPUT_DIR="$(pwd)/clang" \ + | xcpretty + if [[ -n `find $(pwd)/clang -name "*.html"` ]] ; then rm -rf $(pwd)/clang; exit 1; fi + rm -rf $(pwd)/clang diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.github_changelog_generator b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.github_changelog_generator new file mode 100644 index 00000000..19665f65 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.github_changelog_generator @@ -0,0 +1,3 @@ +issues=false +since-tag=1.1.1 +future-release=1.2 diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.gitignore b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.gitignore index fd433d36..4021767b 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.gitignore +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/.gitignore @@ -52,3 +52,6 @@ Carthage/Build # Bundler .bundle vendor + +# Example project +Example/Pods diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/BUCK b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/BUCK index 76cacd3d..c7ade9d1 100755 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/BUCK +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/BUCK @@ -1,8 +1,9 @@ apple_library( name = 'PINOperation', - exported_headers = glob(['PINOperation/*.h']), + modular = True, + exported_headers = glob(['Source/*.h']), srcs = - glob(['PINOperation/*.m']), + glob(['Source/*.m']), preprocessor_flags = ['-fobjc-arc'], lang_preprocessor_flags = { 'C': ['-std=gnu99'], diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CHANGELOG.md b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CHANGELOG.md index 1844305f..221ad3cb 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CHANGELOG.md +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CHANGELOG.md @@ -1,5 +1,28 @@ -## master -* Add your own contributions to the next release on the line below this with your name. +## [1.2](https://github.com/Pinterest/PINOperation/tree/1.2) (2020-06-30) + +[Full Changelog](https://github.com/Pinterest/PINOperation/compare/1.1.2...1.2) + +**Merged pull requests:** + +- Swift Package Manager support [\#32](https://github.com/pinterest/PINOperation/pull/32) ([martinpucik](https://github.com/martinpucik)) +- Add Carthage for watchOS, dependent by PINCache [\#31](https://github.com/pinterest/PINOperation/pull/31) ([dreampiggy](https://github.com/dreampiggy)) +- Fix analyzing [\#30](https://github.com/pinterest/PINOperation/pull/30) ([garrettmoon](https://github.com/garrettmoon)) +- Standardize our GitHub Actions CI workflow [\#29](https://github.com/pinterest/PINOperation/pull/29) ([jparise](https://github.com/jparise)) +- Github CI [\#26](https://github.com/pinterest/PINOperation/pull/26) ([rahul-malik](https://github.com/rahul-malik)) +- Fixes coalesce operation race condition [\#24](https://github.com/pinterest/PINOperation/pull/24) ([zhongwuzw](https://github.com/zhongwuzw)) + +## [1.1.2](https://github.com/Pinterest/PINOperation/tree/1.1.2) (2019-06-11) + +[Full Changelog](https://github.com/Pinterest/PINOperation/compare/1.1.1...1.1.2) + +**Merged pull requests:** + +- Modernizing project [\#21](https://github.com/pinterest/PINOperation/pull/21) ([garrettmoon](https://github.com/garrettmoon)) +- Updates BUCK build file to match source layout. [\#20](https://github.com/pinterest/PINOperation/pull/20) ([RCacheaux](https://github.com/RCacheaux)) +- 1.1.1 release [\#19](https://github.com/pinterest/PINOperation/pull/19) ([garrettmoon](https://github.com/garrettmoon)) + +## 1.1.1 -- 2018 February 3 +* Cleanup warnings [garrett](https://github.com/garrettmoon) ## 1.1 -- 2017 October 7 * Deprecate addOperation: in favor of scheduleOperation: [garrett](https://github.com/garrettmoon) diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CI/exclude-from-build.json b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CI/exclude-from-build.json index abc6f913..03853aa7 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CI/exclude-from-build.json +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CI/exclude-from-build.json @@ -1,5 +1,7 @@ [ "^plans/", "^docs/", - "^CI/exclude-from-build.json$" + "^CI/exclude-from-build.json$", + "^README.md$", + "^CHANGELOG.md$" ] \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CODE_OF_CONDUCT.md b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..8b4e45e2 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/CODE_OF_CONDUCT.md @@ -0,0 +1,40 @@ +# Code of Conduct + +At Pinterest, we work hard to ensure that our work environment is welcoming +and inclusive to as many people as possible. We are committed to creating this +environment for everyone involved in our open source projects as well. We +welcome all participants regardless of ability, age, ethnicity, identified +gender, religion (or lack there of), sexual orientation and socioeconomic +status. + +This code of conduct details our expectations for upholding these values. + +## Good behavior + +We expect members of our community to exhibit good behavior including (but of +course not limited to): + +- Using intentional and empathetic language. +- Focusing on resolving instead of escalating conflict. +- Providing constructive feedback. + +## Unacceptable behavior + +Some examples of unacceptable behavior (again, this is not an exhaustive +list): + +- Harassment, publicly or in private. +- Trolling. +- Sexual advances (this isn’t the place for it). +- Publishing other’s personal information. +- Any behavior which would be deemed unacceptable in a professional environment. + +## Recourse + +If you are witness to or the target of unacceptable behavior, it should be +reported to Pinterest at opensource-policy@pinterest.com. All reporters will +be kept confidential and an appropriate response for each incident will be +evaluated. + +If the maintainers do not uphold and enforce this code of conduct in +good faith, community leadership will hold them accountable. \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.pbxproj b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.pbxproj new file mode 100644 index 00000000..382c6346 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.pbxproj @@ -0,0 +1,391 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 1387274F245D5BB500C1F56D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1387274E245D5BB500C1F56D /* AppDelegate.swift */; }; + 13872758245D5BB800C1F56D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13872757245D5BB800C1F56D /* Assets.xcassets */; }; + 1387275B245D5BB800C1F56D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 13872759245D5BB800C1F56D /* LaunchScreen.storyboard */; }; + 13872765245D5D8200C1F56D /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 13872764245D5D8200C1F56D /* MainViewController.m */; }; + 6DD78925193625590E803994 /* libPods-PINOperationExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BDDE545CD189CC0B424ECD0 /* libPods-PINOperationExample.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 1387274B245D5BB500C1F56D /* PINOperationExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PINOperationExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1387274E245D5BB500C1F56D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 13872757245D5BB800C1F56D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 1387275A245D5BB800C1F56D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 1387275C245D5BB800C1F56D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 13872762245D5D8200C1F56D /* PINOperationExample-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PINOperationExample-Bridging-Header.h"; sourceTree = ""; }; + 13872763245D5D8200C1F56D /* MainViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; + 13872764245D5D8200C1F56D /* MainViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; + 15635AC2BB0501241D3126BA /* Pods-PINOperationExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PINOperationExample.release.xcconfig"; path = "Target Support Files/Pods-PINOperationExample/Pods-PINOperationExample.release.xcconfig"; sourceTree = ""; }; + 2F8A2FBFCEF95140E01995E8 /* Pods-PINOperationExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PINOperationExample.debug.xcconfig"; path = "Target Support Files/Pods-PINOperationExample/Pods-PINOperationExample.debug.xcconfig"; sourceTree = ""; }; + 7BDDE545CD189CC0B424ECD0 /* libPods-PINOperationExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PINOperationExample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 13872748245D5BB500C1F56D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6DD78925193625590E803994 /* libPods-PINOperationExample.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 110EBBE34DCD59092AC3306C /* Pods */ = { + isa = PBXGroup; + children = ( + 2F8A2FBFCEF95140E01995E8 /* Pods-PINOperationExample.debug.xcconfig */, + 15635AC2BB0501241D3126BA /* Pods-PINOperationExample.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + 13872742245D5BB500C1F56D = { + isa = PBXGroup; + children = ( + 1387274D245D5BB500C1F56D /* PINOperationExample */, + 1387274C245D5BB500C1F56D /* Products */, + 110EBBE34DCD59092AC3306C /* Pods */, + 5C200BF654CB547E7117CE2B /* Frameworks */, + ); + sourceTree = ""; + }; + 1387274C245D5BB500C1F56D /* Products */ = { + isa = PBXGroup; + children = ( + 1387274B245D5BB500C1F56D /* PINOperationExample.app */, + ); + name = Products; + sourceTree = ""; + }; + 1387274D245D5BB500C1F56D /* PINOperationExample */ = { + isa = PBXGroup; + children = ( + 1387274E245D5BB500C1F56D /* AppDelegate.swift */, + 13872763245D5D8200C1F56D /* MainViewController.h */, + 13872764245D5D8200C1F56D /* MainViewController.m */, + 13872757245D5BB800C1F56D /* Assets.xcassets */, + 13872759245D5BB800C1F56D /* LaunchScreen.storyboard */, + 1387275C245D5BB800C1F56D /* Info.plist */, + 13872762245D5D8200C1F56D /* PINOperationExample-Bridging-Header.h */, + ); + path = PINOperationExample; + sourceTree = ""; + }; + 5C200BF654CB547E7117CE2B /* Frameworks */ = { + isa = PBXGroup; + children = ( + 7BDDE545CD189CC0B424ECD0 /* libPods-PINOperationExample.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1387274A245D5BB500C1F56D /* PINOperationExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1387275F245D5BB800C1F56D /* Build configuration list for PBXNativeTarget "PINOperationExample" */; + buildPhases = ( + 6C859F1C363A79193D42EFC9 /* [CP] Check Pods Manifest.lock */, + 13872747245D5BB500C1F56D /* Sources */, + 13872748245D5BB500C1F56D /* Frameworks */, + 13872749245D5BB500C1F56D /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PINOperationExample; + productName = PINOperationExample; + productReference = 1387274B245D5BB500C1F56D /* PINOperationExample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 13872743245D5BB500C1F56D /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1140; + LastUpgradeCheck = 1140; + ORGANIZATIONNAME = Pinterest; + TargetAttributes = { + 1387274A245D5BB500C1F56D = { + CreatedOnToolsVersion = 11.4.1; + LastSwiftMigration = 1140; + }; + }; + }; + buildConfigurationList = 13872746245D5BB500C1F56D /* Build configuration list for PBXProject "PINOperationExample" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 13872742245D5BB500C1F56D; + productRefGroup = 1387274C245D5BB500C1F56D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1387274A245D5BB500C1F56D /* PINOperationExample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 13872749245D5BB500C1F56D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1387275B245D5BB800C1F56D /* LaunchScreen.storyboard in Resources */, + 13872758245D5BB800C1F56D /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 6C859F1C363A79193D42EFC9 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-PINOperationExample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 13872747245D5BB500C1F56D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1387274F245D5BB500C1F56D /* AppDelegate.swift in Sources */, + 13872765245D5D8200C1F56D /* MainViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 13872759245D5BB800C1F56D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 1387275A245D5BB800C1F56D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 1387275D245D5BB800C1F56D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 1387275E245D5BB800C1F56D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 13872760245D5BB800C1F56D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 2F8A2FBFCEF95140E01995E8 /* Pods-PINOperationExample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = PINOperationExample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINOperationExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "PINOperationExample/PINOperationExample-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 13872761245D5BB800C1F56D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 15635AC2BB0501241D3126BA /* Pods-PINOperationExample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = PINOperationExample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINOperationExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "PINOperationExample/PINOperationExample-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 13872746245D5BB500C1F56D /* Build configuration list for PBXProject "PINOperationExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1387275D245D5BB800C1F56D /* Debug */, + 1387275E245D5BB800C1F56D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1387275F245D5BB800C1F56D /* Build configuration list for PBXNativeTarget "PINOperationExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 13872760245D5BB800C1F56D /* Debug */, + 13872761245D5BB800C1F56D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 13872743245D5BB500C1F56D /* Project object */; +} diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..b6d9930d --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcworkspace/contents.xcworkspacedata b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..4cdc4885 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/AppDelegate.swift b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/AppDelegate.swift new file mode 100644 index 00000000..7aa52db8 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/AppDelegate.swift @@ -0,0 +1,31 @@ +// +// AppDelegate.swift +// PINOperationExample +// +// Created by Martin Púčik on 02/05/2020. +// Copyright © 2020 Pinterest. All rights reserved. +// + +import UIKit + +@UIApplicationMain +final class AppDelegate: UIResponder, UIApplicationDelegate { + private let queue: PINOperationQueue = PINOperationQueue(maxConcurrentOperations: 5) + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + let operationCount = 100 + let group = DispatchGroup() + for _ in 0.. + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/Info.plist b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/Info.plist new file mode 100644 index 00000000..75404a26 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/Info.plist @@ -0,0 +1,41 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/MainViewController.h b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/MainViewController.h new file mode 100644 index 00000000..df2e69c3 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/MainViewController.h @@ -0,0 +1,17 @@ +// +// MainViewController.h +// PINOperationExample +// +// Created by Martin Púčik on 02/05/2020. +// Copyright © 2020 Pinterest. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MainViewController : UIViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/MainViewController.m b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/MainViewController.m new file mode 100644 index 00000000..50d0c95d --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/MainViewController.m @@ -0,0 +1,41 @@ +// +// MainViewController.m +// PINOperationExample +// +// Created by Martin Púčik on 02/05/2020. +// Copyright © 2020 Pinterest. All rights reserved. +// + +#import "MainViewController.h" +#import +//#import + +@interface MainViewController () +@property (nonatomic, strong) PINOperationQueue *queue; +@end + +@implementation MainViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.queue = [[PINOperationQueue alloc] initWithMaxConcurrentOperations:5]; + + const NSUInteger operationCount = 100; + dispatch_group_t group = dispatch_group_create(); + + for (NSUInteger count = 0; count < operationCount; count++) { + dispatch_group_enter(group); + [self.queue scheduleOperation:^{ + dispatch_group_leave(group); + } withPriority:PINOperationQueuePriorityDefault]; + } + + NSUInteger success = dispatch_group_wait(group, [self timeout]); + NSAssert(success == 0, @"Timed out before completing 100 operations"); +} + +- (dispatch_time_t)timeout { + return dispatch_time(DISPATCH_TIME_NOW, (int64_t)(20 * NSEC_PER_SEC)); +} + +@end diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/PINOperationExample-Bridging-Header.h b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/PINOperationExample-Bridging-Header.h new file mode 100644 index 00000000..f3b5f384 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/PINOperationExample/PINOperationExample-Bridging-Header.h @@ -0,0 +1 @@ +#import diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/Podfile b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/Podfile new file mode 100644 index 00000000..ae5fd622 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/Podfile @@ -0,0 +1,6 @@ +source 'https://cdn.cocoapods.org/' +platform :ios, '8.0' + +target 'PINOperationExample' do + pod 'PINOperation', :path => '../' +end diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/Podfile.lock b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/Podfile.lock new file mode 100644 index 00000000..266cc700 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Example/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - PINOperation (1.1.2) + +DEPENDENCIES: + - PINOperation (from `../`) + +EXTERNAL SOURCES: + PINOperation: + :path: "../" + +SPEC CHECKSUMS: + PINOperation: 24b774353ca248fcf87d67b2d61eef42087c125a + +PODFILE CHECKSUM: b83a75d584abe07185e7be951687702dadbabf84 + +COCOAPODS: 1.9.1 diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.podspec b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.podspec index ecea6f8b..7e598595 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.podspec +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'PINOperation' - s.version = '1.1' + s.version = '1.2' s.homepage = 'https://github.com/pinterest/PINOperation' s.summary = 'Fast, concurrency-limited task queue for iOS and OS X.' s.authors = { 'Garrett Moon' => 'garrett@pinterest.com' } @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.license = { :type => 'Apache 2.0', :file => 'LICENSE.txt' } s.requires_arc = true s.frameworks = 'Foundation' - s.ios.deployment_target = '5.0' + s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.8' s.tvos.deployment_target = '9.0' s.watchos.deployment_target = '2.0' diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/project.pbxproj b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/project.pbxproj index abf27c9b..ddcb88c2 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/project.pbxproj +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/project.pbxproj @@ -7,6 +7,13 @@ objects = { /* Begin PBXBuildFile section */ + 3201179424444862004FD783 /* PINOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0105801E2711B700890935 /* PINOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3201179524444862004FD783 /* PINOperationGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0105811E2711B700890935 /* PINOperationGroup.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3201179624444862004FD783 /* PINOperationMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0105831E2711B700890935 /* PINOperationMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3201179724444862004FD783 /* PINOperationQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0105841E2711B700890935 /* PINOperationQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3201179824444862004FD783 /* PINOperationTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0105861E2711B700890935 /* PINOperationTypes.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3201179924444862004FD783 /* PINOperationGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0105821E2711B700890935 /* PINOperationGroup.m */; }; + 3201179A24444862004FD783 /* PINOperationQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0105851E2711B700890935 /* PINOperationQueue.m */; }; CC01055B1E27116600890935 /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC01052D1E27110D00890935 /* PINOperation.framework */; }; CC01056A1E27117300890935 /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC01053D1E27113700890935 /* PINOperation.framework */; }; CC0105791E27117F00890935 /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC01054A1E27114300890935 /* PINOperation.framework */; }; @@ -64,6 +71,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 3201178C24444859004FD783 /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CC01052D1E27110D00890935 /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CC01053D1E27113700890935 /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CC01054A1E27114300890935 /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -84,6 +92,13 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 3201178924444859004FD783 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; CC0105291E27110D00890935 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -153,6 +168,7 @@ CC0105561E27116600890935 /* PINOperationTests.xctest */, CC0105651E27117300890935 /* PINOperation-tvOSTests.xctest */, CC0105741E27117F00890935 /* PINOperation-macOSTests.xctest */, + 3201178C24444859004FD783 /* PINOperation.framework */, ); name = Products; sourceTree = ""; @@ -185,6 +201,18 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 3201178724444859004FD783 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 3201179824444862004FD783 /* PINOperationTypes.h in Headers */, + 3201179524444862004FD783 /* PINOperationGroup.h in Headers */, + 3201179424444862004FD783 /* PINOperation.h in Headers */, + 3201179724444862004FD783 /* PINOperationQueue.h in Headers */, + 3201179624444862004FD783 /* PINOperationMacros.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; CC01052A1E27110D00890935 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -224,6 +252,24 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + 3201178B24444859004FD783 /* PINOperation-watchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3201179324444859004FD783 /* Build configuration list for PBXNativeTarget "PINOperation-watchOS" */; + buildPhases = ( + 3201178724444859004FD783 /* Headers */, + 3201178824444859004FD783 /* Sources */, + 3201178924444859004FD783 /* Frameworks */, + 3201178A24444859004FD783 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "PINOperation-watchOS"; + productName = "PINOperation-watchOS"; + productReference = 3201178C24444859004FD783 /* PINOperation.framework */; + productType = "com.apple.product-type.framework"; + }; CC01052C1E27110D00890935 /* PINOperation */ = { isa = PBXNativeTarget; buildConfigurationList = CC0105351E27110D00890935 /* Build configuration list for PBXNativeTarget "PINOperation" */; @@ -338,9 +384,13 @@ CC0105241E27110D00890935 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = Pinterest; TargetAttributes = { + 3201178B24444859004FD783 = { + CreatedOnToolsVersion = 11.4; + ProvisioningStyle = Automatic; + }; CC01052C1E27110D00890935 = { CreatedOnToolsVersion = 7.3.1; }; @@ -363,9 +413,10 @@ }; buildConfigurationList = CC0105271E27110D00890935 /* Build configuration list for PBXProject "PINOperation" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( + Base, en, ); mainGroup = CC0105231E27110D00890935; @@ -379,11 +430,19 @@ CC0105641E27117300890935 /* PINOperation-tvOSTests */, CC0105491E27114300890935 /* PINOperation-macOS */, CC0105731E27117F00890935 /* PINOperation-macOSTests */, + 3201178B24444859004FD783 /* PINOperation-watchOS */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 3201178A24444859004FD783 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; CC01052B1E27110D00890935 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -429,6 +488,15 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 3201178824444859004FD783 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3201179924444862004FD783 /* PINOperationGroup.m in Sources */, + 3201179A24444862004FD783 /* PINOperationQueue.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; CC0105281E27110D00890935 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -504,6 +572,61 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ + 3201179124444859004FD783 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.pinterest.PINOperation-watchOS"; + PRODUCT_NAME = PINOperation; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.0; + }; + name = Debug; + }; + 3201179224444859004FD783 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.pinterest.PINOperation-watchOS"; + PRODUCT_NAME = PINOperation; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.0; + }; + name = Release; + }; CC0105331E27110D00890935 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -517,12 +640,15 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -573,12 +699,15 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -699,7 +828,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINOperation; PRODUCT_NAME = PINOperation; SDKROOT = macosx; @@ -720,7 +849,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINOperation; PRODUCT_NAME = PINOperation; SDKROOT = macosx; @@ -803,6 +932,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 3201179324444859004FD783 /* Build configuration list for PBXNativeTarget "PINOperation-watchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3201179124444859004FD783 /* Debug */, + 3201179224444859004FD783 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; CC0105271E27110D00890935 /* Build configuration list for PBXProject "PINOperation" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/xcshareddata/xcschemes/PINOperation-macOS.xcscheme b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/xcshareddata/xcschemes/PINOperation-macOS.xcscheme index b06db321..ebc5ab8b 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/xcshareddata/xcschemes/PINOperation-macOS.xcscheme +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/PINOperation.xcodeproj/xcshareddata/xcschemes/PINOperation-macOS.xcscheme @@ -1,6 +1,6 @@ --user Pinterest --project PINOperation`. To avoid hitting rate limit, the generator will replace the entire file with just the changes from this version – revert that giant deletion to get the entire new changelog. +- Update `spec.version` within `PINOperation.podspec` and the `since-tag` and `future-release` fields in `.github_changelog_generator`. +- Create a new PR with the updated `PINOperation.podspec` and the newly generated changelog, add `#changelog` to the PR message so the CI will not prevent merging it. +- After merging in the PR, [create a new GitHub release](https://github.com/Pinterest/PINOperation/releases/new). Use the generated changelog for the new release. +- Push to Cocoapods with `pod trunk push` diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperation.h b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperation.h index 1f67472b..68b074d2 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperation.h +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperation.h @@ -6,7 +6,7 @@ // Copyright © 2017 Pinterest. All rights reserved. // -#import -#import -#import -#import +#import "PINOperationMacros.h" +#import "PINOperationTypes.h" +#import "PINOperationQueue.h" +#import "PINOperationGroup.h" diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperationGroup.m b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperationGroup.m index dba6a5c6..ddd2ed01 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperationGroup.m +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperationGroup.m @@ -81,7 +81,7 @@ - (void)start dispatch_block_t originalOperation = _operations[idx]; dispatch_block_t groupBlock = ^{ originalOperation(); - dispatch_group_leave(_group); + dispatch_group_leave(self->_group); }; id operationReference = [_operationQueue scheduleOperation:groupBlock withPriority:[_operationPriorities[idx] unsignedIntegerValue]]; diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperationQueue.m b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperationQueue.m index 7009bc6c..5d0a38fe 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperationQueue.m +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Source/PINOperationQueue.m @@ -291,10 +291,10 @@ - (void)setMaxConcurrentOperations:(NSUInteger)maxConcurrentOperations dispatch_async(_semaphoreQueue, ^{ while (difference != 0) { if (difference > 0) { - dispatch_semaphore_signal(_concurrentSemaphore); + dispatch_semaphore_signal(self->_concurrentSemaphore); difference--; } else { - dispatch_semaphore_wait(_concurrentSemaphore, DISPATCH_TIME_FOREVER); + dispatch_semaphore_wait(self->_concurrentSemaphore, DISPATCH_TIME_FOREVER); difference++; } } @@ -305,16 +305,10 @@ - (void)setMaxConcurrentOperations:(NSUInteger)maxConcurrentOperations - (BOOL)locked_cancelOperation:(id )operationReference { - BOOL success = NO; PINOperation *operation = [_referenceToOperations objectForKey:operationReference]; - if (operation) { - NSMutableOrderedSet *queue = [self operationQueueWithPriority:operation.priority]; - if ([queue containsObject:operation]) { - success = YES; - [queue removeObject:operation]; - [_queuedOperations removeObject:operation]; - dispatch_group_leave(_group); - } + BOOL success = [self locked_removeOperation:operation]; + if (success) { + dispatch_group_leave(_group); } return success; } @@ -353,10 +347,10 @@ - (void)scheduleNextOperations:(BOOL)onlyCheckSerial for (dispatch_block_t completion in operation.completions) { completion(); } - dispatch_group_leave(_group); + dispatch_group_leave(self->_group); [self lock]; - _serialQueueBusy = NO; + self->_serialQueueBusy = NO; [self unlock]; //see if there are any other operations @@ -379,22 +373,22 @@ - (void)scheduleNextOperations:(BOOL)onlyCheckSerial } dispatch_async(_semaphoreQueue, ^{ - dispatch_semaphore_wait(_concurrentSemaphore, DISPATCH_TIME_FOREVER); + dispatch_semaphore_wait(self->_concurrentSemaphore, DISPATCH_TIME_FOREVER); [self lock]; PINOperation *operation = [self locked_nextOperationByPriority]; [self unlock]; if (operation) { - dispatch_async(_concurrentQueue, ^{ + dispatch_async(self->_concurrentQueue, ^{ operation.block(operation.data); for (dispatch_block_t completion in operation.completions) { completion(); } - dispatch_group_leave(_group); - dispatch_semaphore_signal(_concurrentSemaphore); + dispatch_group_leave(self->_group); + dispatch_semaphore_signal(self->_concurrentSemaphore); }); } else { - dispatch_semaphore_signal(_concurrentSemaphore); + dispatch_semaphore_signal(self->_concurrentSemaphore); } }); } @@ -448,13 +442,20 @@ - (void)waitUntilAllOperationsAreFinished } //Call with lock held -- (void)locked_removeOperation:(PINOperation *)operation +- (BOOL)locked_removeOperation:(PINOperation *)operation { if (operation) { NSMutableOrderedSet *priorityQueue = [self operationQueueWithPriority:operation.priority]; - [priorityQueue removeObject:operation]; - [_queuedOperations removeObject:operation]; + if ([priorityQueue containsObject:operation]) { + [priorityQueue removeObject:operation]; + [_queuedOperations removeObject:operation]; + if (operation.identifier) { + [_identifierToOperations removeObjectForKey:operation.identifier]; + } + return YES; + } } + return NO; } - (void)lock diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Tests/PINOperationGroupTests.m b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Tests/PINOperationGroupTests.m index a94ac25f..7505d56f 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Tests/PINOperationGroupTests.m +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Tests/PINOperationGroupTests.m @@ -6,12 +6,11 @@ // Copyright © 2016 Pinterest. All rights reserved. // -#import +@import PINOperation; +#import #import -#import - static NSTimeInterval PINOperationGroupTestBlockTimeout = 20; @interface PINOperationGroupTests : XCTestCase diff --git a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Tests/PINOperationQueueTests.m b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Tests/PINOperationQueueTests.m index 70ebb7f8..844968f2 100644 --- a/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Tests/PINOperationQueueTests.m +++ b/sample/UrlGet/Vendor/PINCache/Carthage/Checkouts/PINOperation/Tests/PINOperationQueueTests.m @@ -6,8 +6,8 @@ // Copyright © 2016 Pinterest. All rights reserved. // +@import PINOperation; #import -#import #import static NSTimeInterval PINOperationQueueTestBlockTimeout = 20; @@ -141,6 +141,7 @@ - (void)helperConfirmMaxOperations:(NSUInteger)maxOperations queue:(PINOperation __block NSUInteger runningOperationCount = 0; __block BOOL operationCountMaxedOut = NO; + XCTAssert(queue.maxConcurrentOperations == maxOperations, @"Max concurrent operations not correctly set."); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" for (NSUInteger count = 0; count < operationCount; count++) { @@ -154,7 +155,7 @@ - (void)helperConfirmMaxOperations:(NSUInteger)maxOperations queue:(PINOperation XCTAssert(runningOperationCount <= maxOperations, @"Running too many operations at once: %lu", (unsigned long)runningOperationCount); } - usleep(1000); + usleep(10000); @synchronized (self) { runningOperationCount--; @@ -512,10 +513,10 @@ - (void)testChangingMaximumNumberOfOperations PINOperationQueue *queue = [[PINOperationQueue alloc] initWithMaxConcurrentOperations:2]; [self helperConfirmMaxOperations:2 queue:queue]; queue.maxConcurrentOperations = 4; - usleep(1000); + usleep(10000); [self helperConfirmMaxOperations:4 queue:queue]; queue.maxConcurrentOperations = 2; - usleep(1000); + usleep(10000); [self helperConfirmMaxOperations:2 queue:queue]; } diff --git a/sample/UrlGet/Vendor/PINCache/Dangerfile b/sample/UrlGet/Vendor/PINCache/Dangerfile deleted file mode 100644 index d909431b..00000000 --- a/sample/UrlGet/Vendor/PINCache/Dangerfile +++ /dev/null @@ -1,23 +0,0 @@ -source_pattern = /(\.m|\.mm|\.h)$/ - -# Sometimes it's a README fix, or something like that - which isn't relevant for -# including in a project's CHANGELOG for example -declared_trivial = github.pr_title.include? "#trivial" -has_changes_in_source_directory = !git.modified_files.grep(/Source/).empty? - -modified_source_files = git.modified_files.grep(source_pattern) -has_modified_source_files = !modified_source_files.empty? -added_source_files = git.added_files.grep(source_pattern) -has_added_source_files = !added_source_files.empty? - -# Make it more obvious that a PR is a work in progress and shouldn't be merged yet -warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]" - -# Warn when there is a big PR -warn("This is a big PR, please consider splitting it up to ease code review.") if git.lines_of_code > 500 - -# Changelog entries are required for changes to source files. -no_changelog_entry = !git.modified_files.include?("CHANGELOG.md") -if has_changes_in_source_directory && no_changelog_entry && !declared_trivial - warn("Any source code changes should have an entry in CHANGELOG.md or have #trivial in their title.") -end diff --git a/sample/UrlGet/Vendor/PINCache/Gemfile b/sample/UrlGet/Vendor/PINCache/Gemfile deleted file mode 100644 index 38bfbc8e..00000000 --- a/sample/UrlGet/Vendor/PINCache/Gemfile +++ /dev/null @@ -1,4 +0,0 @@ -source 'https://rubygems.org' - -gem 'danger' -gem 'danger-slack' \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/Makefile b/sample/UrlGet/Vendor/PINCache/Makefile index ccc365f6..b69eb70a 100644 --- a/sample/UrlGet/Vendor/PINCache/Makefile +++ b/sample/UrlGet/Vendor/PINCache/Makefile @@ -1,14 +1,14 @@ -PLATFORM="platform=iOS Simulator,name=iPhone 7" +PLATFORM="platform=iOS Simulator,name=iPhone 8" SDK="iphonesimulator" SHELL=/bin/bash -o pipefail -.PHONY: all lint test carthage analyze +.PHONY: all cocoapods test carthage analyze spm -lint: +cocoapods: pod lib lint analyze: - xcodebuild clean analyze -destination ${PLATFORM} -sdk ${SDK} -project PINCache.xcodeproj -scheme PINCache \ + xcodebuild clean analyze -destination ${PLATFORM} -sdk ${SDK} -workspace PINCache.xcworkspace -scheme PINCache \ ONLY_ACTIVE_ARCH=NO \ CODE_SIGNING_REQUIRED=NO \ CLANG_ANALYZER_OUTPUT=plist-html \ @@ -17,7 +17,7 @@ analyze: rm -rf $(shell pwd)/clang test: - xcodebuild clean test -destination ${PLATFORM} -sdk ${SDK} -project PINCache.xcodeproj -scheme PINCache \ + xcodebuild clean test -destination ${PLATFORM} -sdk ${SDK} -workspace PINCache.xcworkspace -scheme PINCache \ ONLY_ACTIVE_ARCH=NO \ CODE_SIGNING_REQUIRED=NO | xcpretty @@ -25,4 +25,10 @@ carthage: carthage update --no-use-binaries --no-build carthage build --no-skip-current -all: carthage lint test analyze \ No newline at end of file +spm: +# For now just check whether we can assemble it +# TODO: replace it with "swift test --enable-test-discovery --sanitize=thread" when swiftPM resource-related bug would be fixed. +# https://bugs.swift.org/browse/SR-13560 + swift build + +all: carthage cocoapods test analyze spm diff --git a/sample/UrlGet/Vendor/PINCache/PINCache.podspec b/sample/UrlGet/Vendor/PINCache/PINCache.podspec index 32055c51..a8f95f39 100644 --- a/sample/UrlGet/Vendor/PINCache/PINCache.podspec +++ b/sample/UrlGet/Vendor/PINCache/PINCache.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'PINCache' - s.version = '3.0.1-beta.6' + s.version = '3.0.3' s.homepage = 'https://github.com/pinterest/PINCache' s.summary = 'Fast, thread safe, parallel object cache for iOS and OS X.' s.authors = { 'Garrett Moon' => 'garrett@pinterest.com', 'Justin Ouellette' => 'jstn@tumblr.com' } @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.frameworks = 'Foundation' s.ios.weak_frameworks = 'UIKit' s.osx.weak_frameworks = 'AppKit' - s.ios.deployment_target = '5.0' + s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.8' s.tvos.deployment_target = '9.0' s.watchos.deployment_target = '2.0' @@ -22,7 +22,7 @@ EOS s.prefix_header_contents = pch_PIN s.subspec 'Core' do |sp| sp.source_files = 'Source/*.{h,m}' - sp.dependency 'PINOperation', '~> 1.1.0' + sp.dependency 'PINOperation', '~> 1.2.1' end s.subspec 'Arc-exception-safe' do |sp| sp.dependency 'PINCache/Core' diff --git a/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/project.pbxproj b/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/project.pbxproj index 412e2577..5b927448 100644 --- a/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/project.pbxproj +++ b/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/project.pbxproj @@ -7,10 +7,16 @@ objects = { /* Begin PBXBuildFile section */ + 320117C524444E3C004FD783 /* PINCaching.h in Headers */ = {isa = PBXBuildFile; fileRef = 6928EED21E4160EE00B5D975 /* PINCaching.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 320117C624444E3D004FD783 /* PINCache.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0106051E271A9000890935 /* PINCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 320117C724444E3D004FD783 /* PINCache.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0106061E271A9000890935 /* PINCache.m */; }; + 320117C824444E3D004FD783 /* PINCacheObjectSubscripting.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0106071E271A9000890935 /* PINCacheObjectSubscripting.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 320117C924444E3D004FD783 /* PINDiskCache.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0106081E271A9000890935 /* PINDiskCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 320117CA24444E3D004FD783 /* PINDiskCache.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0106091E271A9000890935 /* PINDiskCache.m */; }; + 320117CB24444E3D004FD783 /* PINMemoryCache.h in Headers */ = {isa = PBXBuildFile; fileRef = CC01060A1E271A9000890935 /* PINMemoryCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 320117CC24444E3D004FD783 /* PINMemoryCache.m in Sources */ = {isa = PBXBuildFile; fileRef = CC01060B1E271A9000890935 /* PINMemoryCache.m */; }; + 320117CD24444E3D004FD783 /* PINCacheMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 68A0FBFF1E4D3282000B552D /* PINCacheMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6818C1491E55020400875DB7 /* PINCache.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC0105CE1E271A4900890935 /* PINCache.framework */; }; - 6818C2881E55217D00875DB7 /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6818C2871E55217D00875DB7 /* PINOperation.framework */; }; - 6818C28A1E55218400875DB7 /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6818C2891E55218400875DB7 /* PINOperation.framework */; }; - 6818C28C1E55218A00875DB7 /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6818C28B1E55218A00875DB7 /* PINOperation.framework */; }; 687BB0AA1E52706B005D70C6 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CC0106CA1E28248800890935 /* Default-568h@2x.png */; }; 68A0FC001E4D32C4000B552D /* PINCacheMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 68A0FBFF1E4D3282000B552D /* PINCacheMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; 68A0FC011E4D32C6000B552D /* PINCacheMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 68A0FBFF1E4D3282000B552D /* PINCacheMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -18,6 +24,11 @@ 6928EED31E4160EE00B5D975 /* PINCaching.h in Headers */ = {isa = PBXBuildFile; fileRef = 6928EED21E4160EE00B5D975 /* PINCaching.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6928EED41E4160FE00B5D975 /* PINCaching.h in Headers */ = {isa = PBXBuildFile; fileRef = 6928EED21E4160EE00B5D975 /* PINCaching.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6928EED51E41610700B5D975 /* PINCaching.h in Headers */ = {isa = PBXBuildFile; fileRef = 6928EED21E4160EE00B5D975 /* PINCaching.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C30EE1F520373D1900D78CB9 /* NSDate+PINCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C30EE1EA203717DE00D78CB9 /* NSDate+PINCacheTests.m */; }; + C30EE1F620373D1A00D78CB9 /* NSDate+PINCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C30EE1EA203717DE00D78CB9 /* NSDate+PINCacheTests.m */; }; + C30EE1F720373D1B00D78CB9 /* NSDate+PINCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C30EE1EA203717DE00D78CB9 /* NSDate+PINCacheTests.m */; }; + C38F01AA20A32E0200F47F0E /* PINDiskCache+PINCacheTests.h in Headers */ = {isa = PBXBuildFile; fileRef = C38F01A820A32E0200F47F0E /* PINDiskCache+PINCacheTests.h */; }; + C38F01AB20A32E0200F47F0E /* PINDiskCache+PINCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C38F01A920A32E0200F47F0E /* PINDiskCache+PINCacheTests.m */; }; CC0105DF1E271A5C00890935 /* PINCache.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC0105B11E271A1600890935 /* PINCache.framework */; }; CC0105EE1E271A6400890935 /* PINCache.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC0105C11E271A4000890935 /* PINCache.framework */; }; CC01060E1E271A9500890935 /* PINCache.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0106061E271A9000890935 /* PINCache.m */; }; @@ -46,72 +57,16 @@ CC0106C81E28226A00890935 /* PINCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC01060D1E271A9000890935 /* PINCacheTests.m */; }; CC0106CD1E28249C00890935 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CC0106CA1E28248800890935 /* Default-568h@2x.png */; }; CC0106CE1E28249D00890935 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CC0106CA1E28248800890935 /* Default-568h@2x.png */; }; + DD275346250AF8BC003A77F9 /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD275345250AF8BC003A77F9 /* PINOperation.framework */; }; + DD275348250AF8C9003A77F9 /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD275347250AF8C9003A77F9 /* PINOperation.framework */; }; + DD27534A250AF8D0003A77F9 /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD275349250AF8D0003A77F9 /* PINOperation.framework */; }; + DDF93F55252D585200C6A4DC /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDF93F54252D585200C6A4DC /* PINOperation.framework */; }; + DDF93F59252D585C00C6A4DC /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDF93F58252D585C00C6A4DC /* PINOperation.framework */; }; + DDF93F5D252D586100C6A4DC /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDF93F5C252D586100C6A4DC /* PINOperation.framework */; }; + DDF93F61252D587100C6A4DC /* PINOperation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDF93F60252D587100C6A4DC /* PINOperation.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 6818C2991E564C1100875DB7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = CC01052D1E27110D00890935; - remoteInfo = PINOperation; - }; - 6818C29B1E564C1100875DB7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = CC0105561E27116600890935; - remoteInfo = PINOperationTests; - }; - 6818C29D1E564C1100875DB7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = CC01053D1E27113700890935; - remoteInfo = "PINOperation-tvOS"; - }; - 6818C29F1E564C1100875DB7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = CC0105651E27117300890935; - remoteInfo = "PINOperation-tvOSTests"; - }; - 6818C2A11E564C1100875DB7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = CC01054A1E27114300890935; - remoteInfo = "PINOperation-macOS"; - }; - 6818C2A31E564C1100875DB7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = CC0105741E27117F00890935; - remoteInfo = "PINOperation-macOSTests"; - }; - 6818C2A51E564C2000875DB7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = CC01052C1E27110D00890935; - remoteInfo = PINOperation; - }; - 6818C2A71E564C2A00875DB7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = CC01053C1E27113700890935; - remoteInfo = "PINOperation-tvOS"; - }; - 6818C2A91E564C2F00875DB7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = CC0105491E27114300890935; - remoteInfo = "PINOperation-macOS"; - }; CC0105E01E271A5C00890935 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = CC0105A81E271A1600890935 /* Project object */; @@ -166,12 +121,13 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 6818C2871E55217D00875DB7 /* PINOperation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PINOperation.framework; path = "../../Library/Developer/Xcode/DerivedData/PINCache-cxjnintatqynfgceozwzgezmeypl/Build/Products/Debug-iphonesimulator/PINOperation.framework"; sourceTree = ""; }; - 6818C2891E55218400875DB7 /* PINOperation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PINOperation.framework; path = "../../Library/Developer/Xcode/DerivedData/PINCache-cxjnintatqynfgceozwzgezmeypl/Build/Products/Debug-appletvsimulator/PINOperation.framework"; sourceTree = ""; }; - 6818C28B1E55218A00875DB7 /* PINOperation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PINOperation.framework; path = Carthage/Checkouts/PINOperation/build/Debug/PINOperation.framework; sourceTree = ""; }; - 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PINOperation.xcodeproj; path = Carthage/Checkouts/PINOperation/PINOperation.xcodeproj; sourceTree = ""; }; + 320117A124444DF7004FD783 /* PINCache.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PINCache.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 68A0FBFF1E4D3282000B552D /* PINCacheMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PINCacheMacros.h; sourceTree = ""; }; 6928EED21E4160EE00B5D975 /* PINCaching.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PINCaching.h; sourceTree = ""; }; + C30EE1E9203717DE00D78CB9 /* NSDate+PINCacheTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSDate+PINCacheTests.h"; sourceTree = ""; }; + C30EE1EA203717DE00D78CB9 /* NSDate+PINCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSDate+PINCacheTests.m"; sourceTree = ""; }; + C38F01A820A32E0200F47F0E /* PINDiskCache+PINCacheTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PINDiskCache+PINCacheTests.h"; sourceTree = ""; }; + C38F01A920A32E0200F47F0E /* PINDiskCache+PINCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PINDiskCache+PINCacheTests.m"; sourceTree = ""; }; CC0105B11E271A1600890935 /* PINCache.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PINCache.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CC0105C11E271A4000890935 /* PINCache.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PINCache.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CC0105CE1E271A4900890935 /* PINCache.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PINCache.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -190,13 +146,31 @@ CC0106C51E281D6900890935 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; CC0106C91E28228300890935 /* PINCacheTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PINCacheTests.h; sourceTree = ""; }; CC0106CA1E28248800890935 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + DD275345250AF8BC003A77F9 /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DD275347250AF8C9003A77F9 /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DD275349250AF8D0003A77F9 /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DDF93F50252D582E00C6A4DC /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DDF93F52252D583B00C6A4DC /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DDF93F54252D585200C6A4DC /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DDF93F58252D585C00C6A4DC /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DDF93F5C252D586100C6A4DC /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DDF93F60252D587100C6A4DC /* PINOperation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PINOperation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 3201179E24444DF7004FD783 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DDF93F61252D587100C6A4DC /* PINOperation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; CC0105AD1E271A1600890935 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DDF93F55252D585200C6A4DC /* PINOperation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -204,6 +178,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DDF93F59252D585C00C6A4DC /* PINOperation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -211,6 +186,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DDF93F5D252D586100C6A4DC /* PINOperation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -218,7 +194,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6818C2881E55217D00875DB7 /* PINOperation.framework in Frameworks */, + DD275346250AF8BC003A77F9 /* PINOperation.framework in Frameworks */, CC0105DF1E271A5C00890935 /* PINCache.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -227,7 +203,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6818C28A1E55218400875DB7 /* PINOperation.framework in Frameworks */, + DD275348250AF8C9003A77F9 /* PINOperation.framework in Frameworks */, CC0105EE1E271A6400890935 /* PINCache.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -236,7 +212,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6818C28C1E55218A00875DB7 /* PINOperation.framework in Frameworks */, + DD27534A250AF8D0003A77F9 /* PINOperation.framework in Frameworks */, 6818C1491E55020400875DB7 /* PINCache.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -247,30 +223,22 @@ 6818C2861E55217D00875DB7 /* Frameworks */ = { isa = PBXGroup; children = ( - 6818C28B1E55218A00875DB7 /* PINOperation.framework */, - 6818C2891E55218400875DB7 /* PINOperation.framework */, - 6818C2871E55217D00875DB7 /* PINOperation.framework */, + DDF93F60252D587100C6A4DC /* PINOperation.framework */, + DDF93F5C252D586100C6A4DC /* PINOperation.framework */, + DDF93F58252D585C00C6A4DC /* PINOperation.framework */, + DDF93F54252D585200C6A4DC /* PINOperation.framework */, + DDF93F52252D583B00C6A4DC /* PINOperation.framework */, + DDF93F50252D582E00C6A4DC /* PINOperation.framework */, + DD275349250AF8D0003A77F9 /* PINOperation.framework */, + DD275347250AF8C9003A77F9 /* PINOperation.framework */, + DD275345250AF8BC003A77F9 /* PINOperation.framework */, ); name = Frameworks; sourceTree = ""; }; - 6818C2911E564C1100875DB7 /* Products */ = { - isa = PBXGroup; - children = ( - 6818C29A1E564C1100875DB7 /* PINOperation.framework */, - 6818C29C1E564C1100875DB7 /* PINOperationTests.xctest */, - 6818C29E1E564C1100875DB7 /* PINOperation.framework */, - 6818C2A01E564C1100875DB7 /* PINOperation-tvOSTests.xctest */, - 6818C2A21E564C1100875DB7 /* PINOperation.framework */, - 6818C2A41E564C1100875DB7 /* PINOperation-macOSTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; CC0105A71E271A1600890935 = { isa = PBXGroup; children = ( - 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */, CC0106031E271A9000890935 /* Source */, CC01060C1E271A9000890935 /* Tests */, CC0105B21E271A1600890935 /* Products */, @@ -287,6 +255,7 @@ CC0105DA1E271A5C00890935 /* PINCacheTests.xctest */, CC0105E91E271A6400890935 /* PINCache-tvOSTests.xctest */, CC0105F81E271A7300890935 /* PINCache-macOSTests.xctest */, + 320117A124444DF7004FD783 /* PINCache.framework */, ); name = Products; sourceTree = ""; @@ -313,8 +282,12 @@ children = ( CC0106CB1E28248A00890935 /* Assets */, CC0106C51E281D6900890935 /* Info.plist */, + C30EE1E9203717DE00D78CB9 /* NSDate+PINCacheTests.h */, + C30EE1EA203717DE00D78CB9 /* NSDate+PINCacheTests.m */, CC0106C91E28228300890935 /* PINCacheTests.h */, CC01060D1E271A9000890935 /* PINCacheTests.m */, + C38F01A820A32E0200F47F0E /* PINDiskCache+PINCacheTests.h */, + C38F01A920A32E0200F47F0E /* PINDiskCache+PINCacheTests.m */, ); path = Tests; sourceTree = ""; @@ -330,6 +303,19 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 3201179C24444DF7004FD783 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 320117CB24444E3D004FD783 /* PINMemoryCache.h in Headers */, + 320117C624444E3D004FD783 /* PINCache.h in Headers */, + 320117C824444E3D004FD783 /* PINCacheObjectSubscripting.h in Headers */, + 320117CD24444E3D004FD783 /* PINCacheMacros.h in Headers */, + 320117C924444E3D004FD783 /* PINDiskCache.h in Headers */, + 320117C524444E3C004FD783 /* PINCaching.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; CC0105AE1E271A1600890935 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -339,6 +325,7 @@ 68A0FC001E4D32C4000B552D /* PINCacheMacros.h in Headers */, CC0106181E271AAF00890935 /* PINCacheObjectSubscripting.h in Headers */, CC01061A1E271AAF00890935 /* PINMemoryCache.h in Headers */, + C38F01AA20A32E0200F47F0E /* PINDiskCache+PINCacheTests.h in Headers */, CC0106191E271AAF00890935 /* PINDiskCache.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -372,6 +359,24 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + 320117A024444DF7004FD783 /* PINCache-watchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 320117AE24444DF7004FD783 /* Build configuration list for PBXNativeTarget "PINCache-watchOS" */; + buildPhases = ( + 3201179D24444DF7004FD783 /* Sources */, + 3201179E24444DF7004FD783 /* Frameworks */, + 3201179C24444DF7004FD783 /* Headers */, + 3201179F24444DF7004FD783 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "PINCache-watchOS"; + productName = "PINCache-watchOS"; + productReference = 320117A124444DF7004FD783 /* PINCache.framework */; + productType = "com.apple.product-type.framework"; + }; CC0105B01E271A1600890935 /* PINCache */ = { isa = PBXNativeTarget; buildConfigurationList = CC0105B91E271A1600890935 /* Build configuration list for PBXNativeTarget "PINCache" */; @@ -384,7 +389,6 @@ buildRules = ( ); dependencies = ( - 6818C2A61E564C2000875DB7 /* PBXTargetDependency */, ); name = PINCache; productName = PINCache; @@ -403,7 +407,6 @@ buildRules = ( ); dependencies = ( - 6818C2A81E564C2A00875DB7 /* PBXTargetDependency */, ); name = "PINCache-tvOS"; productName = "PINCache-tvOS"; @@ -422,7 +425,6 @@ buildRules = ( ); dependencies = ( - 6818C2AA1E564C2F00875DB7 /* PBXTargetDependency */, ); name = "PINCache-macOS"; productName = "PINCache-macOS"; @@ -492,9 +494,13 @@ CC0105A81E271A1600890935 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = Pinterest; TargetAttributes = { + 320117A024444DF7004FD783 = { + CreatedOnToolsVersion = 11.4; + ProvisioningStyle = Automatic; + }; CC0105B01E271A1600890935 = { CreatedOnToolsVersion = 7.3.1; }; @@ -520,17 +526,11 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( - en, + English, ); mainGroup = CC0105A71E271A1600890935; productRefGroup = CC0105B21E271A1600890935 /* Products */; projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 6818C2911E564C1100875DB7 /* Products */; - ProjectRef = 6818C2901E564C1100875DB7 /* PINOperation.xcodeproj */; - }, - ); projectRoot = ""; targets = ( CC0105B01E271A1600890935 /* PINCache */, @@ -539,56 +539,19 @@ CC0105E81E271A6400890935 /* PINCache-tvOSTests */, CC0105CD1E271A4900890935 /* PINCache-macOS */, CC0105F71E271A7300890935 /* PINCache-macOSTests */, + 320117A024444DF7004FD783 /* PINCache-watchOS */, ); }; /* End PBXProject section */ -/* Begin PBXReferenceProxy section */ - 6818C29A1E564C1100875DB7 /* PINOperation.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = PINOperation.framework; - remoteRef = 6818C2991E564C1100875DB7 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 6818C29C1E564C1100875DB7 /* PINOperationTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = PINOperationTests.xctest; - remoteRef = 6818C29B1E564C1100875DB7 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 6818C29E1E564C1100875DB7 /* PINOperation.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = PINOperation.framework; - remoteRef = 6818C29D1E564C1100875DB7 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 6818C2A01E564C1100875DB7 /* PINOperation-tvOSTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = "PINOperation-tvOSTests.xctest"; - remoteRef = 6818C29F1E564C1100875DB7 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 6818C2A21E564C1100875DB7 /* PINOperation.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = PINOperation.framework; - remoteRef = 6818C2A11E564C1100875DB7 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 6818C2A41E564C1100875DB7 /* PINOperation-macOSTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = "PINOperation-macOSTests.xctest"; - remoteRef = 6818C2A31E564C1100875DB7 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - /* Begin PBXResourcesBuildPhase section */ + 3201179F24444DF7004FD783 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; CC0105AF1E271A1600890935 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -637,12 +600,23 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 3201179D24444DF7004FD783 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 320117C724444E3D004FD783 /* PINCache.m in Sources */, + 320117CC24444E3D004FD783 /* PINMemoryCache.m in Sources */, + 320117CA24444E3D004FD783 /* PINDiskCache.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; CC0105AC1E271A1600890935 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( CC01060E1E271A9500890935 /* PINCache.m in Sources */, CC0106101E271A9500890935 /* PINMemoryCache.m in Sources */, + C38F01AB20A32E0200F47F0E /* PINDiskCache+PINCacheTests.m in Sources */, CC01060F1E271A9500890935 /* PINDiskCache.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -672,6 +646,7 @@ buildActionMask = 2147483647; files = ( CC0106C61E28226900890935 /* PINCacheTests.m in Sources */, + C30EE1F520373D1900D78CB9 /* NSDate+PINCacheTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -680,6 +655,7 @@ buildActionMask = 2147483647; files = ( CC0106C71E28226A00890935 /* PINCacheTests.m in Sources */, + C30EE1F620373D1A00D78CB9 /* NSDate+PINCacheTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -688,27 +664,13 @@ buildActionMask = 2147483647; files = ( CC0106C81E28226A00890935 /* PINCacheTests.m in Sources */, + C30EE1F720373D1B00D78CB9 /* NSDate+PINCacheTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 6818C2A61E564C2000875DB7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = PINOperation; - targetProxy = 6818C2A51E564C2000875DB7 /* PBXContainerItemProxy */; - }; - 6818C2A81E564C2A00875DB7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "PINOperation-tvOS"; - targetProxy = 6818C2A71E564C2A00875DB7 /* PBXContainerItemProxy */; - }; - 6818C2AA1E564C2F00875DB7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "PINOperation-macOS"; - targetProxy = 6818C2A91E564C2F00875DB7 /* PBXContainerItemProxy */; - }; CC0105E11E271A5C00890935 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = CC0105B01E271A1600890935 /* PINCache */; @@ -727,6 +689,63 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ + 320117A624444DF7004FD783 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS"; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINCache; + PRODUCT_NAME = PINCache; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.0; + }; + name = Debug; + }; + 320117A724444DF7004FD783 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS"; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINCache; + PRODUCT_NAME = PINCache; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.0; + }; + name = Release; + }; CC0105B71E271A1600890935 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -740,12 +759,15 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -797,12 +819,15 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -854,6 +879,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINCache; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; }; name = Debug; }; @@ -876,6 +902,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINCache; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; }; name = Release; }; @@ -900,7 +927,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.2; + TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Debug; }; @@ -925,7 +952,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.2; + TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Release; }; @@ -947,6 +974,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINCache; PRODUCT_NAME = PINCache; SDKROOT = macosx; @@ -972,6 +1000,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_BUNDLE_IDENTIFIER = com.pinterest.PINCache; PRODUCT_NAME = PINCache; SDKROOT = macosx; @@ -1062,6 +1091,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 320117AE24444DF7004FD783 /* Build configuration list for PBXNativeTarget "PINCache-watchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 320117A624444DF7004FD783 /* Debug */, + 320117A724444DF7004FD783 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; CC0105AB1E271A1600890935 /* Build configuration list for PBXProject "PINCache" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/xcshareddata/xcschemes/PINCache-macOS.xcscheme b/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/xcshareddata/xcschemes/PINCache-macOS.xcscheme index 537f23e3..4dfc852e 100644 --- a/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/xcshareddata/xcschemes/PINCache-macOS.xcscheme +++ b/sample/UrlGet/Vendor/PINCache/PINCache.xcodeproj/xcshareddata/xcschemes/PINCache-macOS.xcscheme @@ -1,6 +1,6 @@ + + + + + + diff --git a/sample/UrlGet/Vendor/PINCache/PINCache.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/sample/UrlGet/Vendor/PINCache/PINCache.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/PINCache.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/sample/UrlGet/Vendor/PINCache/Package.swift b/sample/UrlGet/Vendor/PINCache/Package.swift new file mode 100644 index 00000000..38447e31 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Package.swift @@ -0,0 +1,47 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "PINCache", + platforms: [ + .macOS(.v10_10), + .iOS(.v9), + .watchOS(.v2), + .tvOS(.v9) + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "PINCache", + targets: ["PINCache"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + .package(url: "https://github.com/pinterest/PINOperation.git", from: "1.2.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "PINCache", + dependencies: ["PINOperation"], + path: "Source", + exclude: ["Carthage", "docs", + "build_docs.sh", "Cartfile", + "Cartfile.resolved", "Makefile", + "PINCache.podspec", "Info.plist"], + publicHeadersPath: "."), + .testTarget( + name: "PINCacheTests", + dependencies: ["PINCache"], + path: "Tests", + exclude: ["Info.plist"], + resources: [.process("Default-568h@2x.png")], + cSettings: [ + .define("TEST_AS_SPM"), + ]), + ] +) diff --git a/sample/UrlGet/Vendor/PINCache/README.md b/sample/UrlGet/Vendor/PINCache/README.md index 65226402..aa81564a 100644 --- a/sample/UrlGet/Vendor/PINCache/README.md +++ b/sample/UrlGet/Vendor/PINCache/README.md @@ -2,7 +2,7 @@ [![CocoaPods](https://img.shields.io/cocoapods/v/PINCache.svg)](http://cocoadocs.org/docsets/PINCache/) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) -[![Build status](https://badge.buildkite.com/03e247305c96c3371f2ff2766e9c8c1efdd5fdb3a7eceaff43.svg?branch=master&style=flat)](https://buildkite.com/pinterest/pincache) +[![Build status](https://github.com/pinterest/PINCache/workflows/CI/badge.svg)](https://github.com/pinterest/PINCache/actions?query=workflow%3ACI+branch%3Amaster) ## Fast, non-deadlocking parallel object cache for iOS and OS X. @@ -82,7 +82,7 @@ Add the following line to your `Cartfile` and run `carthage update --platform io ## Requirements -__PINCache__ requires iOS 5.0, tvOS 9.0, watchOS 2.0 or OS X 10.7 and greater. +__PINCache__ requires iOS 8.0, tvOS 9.0, watchOS 2.0 or macOS 10.8 and greater. ## Contact diff --git a/sample/UrlGet/Vendor/PINCache/RELEASE.md b/sample/UrlGet/Vendor/PINCache/RELEASE.md new file mode 100644 index 00000000..6e86b11c --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/RELEASE.md @@ -0,0 +1,13 @@ +# Release Process +This document describes the process for a public PINCache release. + +### Preparation +- Install [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator): `sudo gem install github_changelog_generator` +- Generate a GitHub Personal Access Token to prevent running into public GitHub API rate limits: https://github.com/github-changelog-generator/github-changelog-generator#github-token + +### Process +- Run `github_changelog_generator` in PINCache project directory: `github_changelog_generator --token --user Pinterest --project PINCache`. To avoid hitting rate limit, the generator will replace the entire file with just the changes from this version – revert that giant deletion to get the entire new changelog. +- Update `spec.version` within `PINCache.podspec` and the `since-tag` and `future-release` fields in `.github_changelog_generator`. +- Create a new PR with the updated `PINCache.podspec` and the newly generated changelog, add `#changelog` to the PR message so the CI will not prevent merging it. +- After merging in the PR, [create a new GitHub release](https://github.com/Pinterest/PINCache/releases/new). Use the generated changelog for the new release. +- Push to Cocoapods with `pod trunk push` diff --git a/sample/UrlGet/Vendor/PINCache/Scripts/release.sh b/sample/UrlGet/Vendor/PINCache/Scripts/release.sh new file mode 100755 index 00000000..fd094a6b --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Scripts/release.sh @@ -0,0 +1,98 @@ +#!/bin/bash +set -e + +if [ -z "$OSS_PROJECT" ]; then + echo "Must set \$OSS_PROJECT envirnonment variable before running." +fi + +PROJECT="$OSS_PROJECT" + +if ! git diff-index --quiet HEAD --; then + echo "Please commit or stash any changes before running." + exit 1 +fi + +if [ -z "$GITHUB_CHANGELOG_API_KEY" ]; then + echo "Must set \$GITHUB_CHANGELOG_API_KEY environment variable" + exit 1 +fi + +case $1 in + "--major") + UPDATE_TYPE="major" + ;; + + "--minor") + UPDATE_TYPE="minor" + ;; + + "--patch") + UPDATE_TYPE="patch" + ;; + + *) + echo "Usage release.sh --patch / --minor / --major" + exit 1 + ;; +esac + +PODSPEC="$PROJECT.podspec" +CURRENT_VERSION=`grep "version" -m 1 $PODSPEC | sed -E "s/^.*version[ \t]*=[ \t]*'([0-9\.]+)'/\1/"` +DOT_COUNT=`echo "$CURRENT_VERSION" | grep -o '\.' | wc -l` + +if [ "$DOT_COUNT" -eq "0" ]; then + major=$CURRENT_VERSION + minor="0" + patch="0" +elif [ "$DOT_COUNT" -eq "1" ]; then + major=`echo "$CURRENT_VERSION" | sed -E "s/([0-9])+\.([0-9]+)/\1/"` + minor=`echo "$CURRENT_VERSION" | sed -E "s/([0-9])+\.([0-9]+)/\2/"` + patch="0" +elif [ "$DOT_COUNT" -eq "2" ]; then + major=`echo "$CURRENT_VERSION" | sed -E "s/([0-9])+\.([0-9]+)\.([0-9]+)/\1/"` + minor=`echo "$CURRENT_VERSION" | sed -E "s/([0-9])+\.([0-9]+)\.([0-9]+)/\2/"` + patch=`echo "$CURRENT_VERSION" | sed -E "s/([0-9])+\.([0-9]+)\.([0-9]+)/\3/"` +fi + +echo "Current version: $major.$minor.$patch" + +if [ "$UPDATE_TYPE" == "major" ]; then + major=$((major + 1)) + minor=0 + patch=0 +elif [ "$UPDATE_TYPE" == "minor" ]; then + minor=$((minor + 1)) + patch=0 +elif [ "$UPDATE_TYPE" == "patch" ]; then + patch=$((patch + 1)) +fi + +NEW_VERSION="$major.$minor.$patch" +echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV +echo "New version: $NEW_VERSION" + +echo "Updating $PODSPEC" +sed -E "s/^(.*version[ \t]*=[ \t]*)'$CURRENT_VERSION'/\1'$NEW_VERSION'/" $PODSPEC > new.podspec +mv new.podspec $PODSPEC + +echo "Updating .github_changelog_generator" +cat << EOF > .github_changelog_generator +issues=false +since-tag=$CURRENT_VERSION +future-release=$NEW_VERSION +EOF + +github_changelog_generator --token $GITHUB_CHANGELOG_API_KEY --user Pinterest --project $PROJECT --output NEW_CHANGES.md + +# Delete # Changelog at the top of the old CHANGELOG +grep -v "# Changelog" CHANGELOG.md > CHANGELOG.tmp && mv CHANGELOG.tmp CHANGELOG.md + +# Delete the last line and first line then use a magic sed command the internet told me +# about to delete trailing newlines (except the last one) +# Then prepend to existing changelog +grep -v "\*" NEW_CHANGES.md | sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' | cat - CHANGELOG.md > CHANGELOG.tmp +mv CHANGELOG.tmp CHANGELOG.md +rm NEW_CHANGES.md + +git add .github_changelog_generator CHANGELOG.md $PODSPEC +git commit --message "[AUTO] Update CHANGELOG.md and bump for $UPDATE_TYPE update." diff --git a/sample/UrlGet/Vendor/PINCache/Scripts/tag-release-branch.sh b/sample/UrlGet/Vendor/PINCache/Scripts/tag-release-branch.sh new file mode 100755 index 00000000..a66af230 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Scripts/tag-release-branch.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -ex + +echo "Tagging release branch" +TAG=$NEW_VERSION + +echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV +git tag $TAG +git push origin --tags + +echo "Setting Release Notes" +cat CHANGELOG.md | awk '/^#/{f=1} f; /^#/ && ++c==3{exit}' | sed '$ d' > RELEASE_NOTES.md diff --git a/sample/UrlGet/Vendor/PINCache/Source/PINCache.h b/sample/UrlGet/Vendor/PINCache/Source/PINCache.h index fa743a89..bfc9d850 100644 --- a/sample/UrlGet/Vendor/PINCache/Source/PINCache.h +++ b/sample/UrlGet/Vendor/PINCache/Source/PINCache.h @@ -4,10 +4,10 @@ #import -#import -#import -#import -#import +#import "PINCacheMacros.h" +#import "PINCaching.h" +#import "PINDiskCache.h" +#import "PINMemoryCache.h" NS_ASSUME_NONNULL_BEGIN @@ -103,6 +103,27 @@ PIN_SUBCLASSING_RESTRICTED serializer:(nullable PINDiskCacheSerializerBlock)serializer deserializer:(nullable PINDiskCacheDeserializerBlock)deserializer; +/** + Multiple instances with the same name are *not* allowed and can *not* safely + access the same data on disk. Also used to create the . + Initializer allows you to override default NSKeyedArchiver/NSKeyedUnarchiver serialization for . + You must provide both serializer and deserializer, or opt-out to default implementation providing nil values. + + @see name + @param name The name of the cache. + @param rootPath The path of the cache on disk. + @param serializer A block used to serialize object before writing to disk. If nil provided, default NSKeyedArchiver serialized will be used. + @param deserializer A block used to deserialize object read from disk. If nil provided, default NSKeyedUnarchiver serialized will be used. + @param keyEncoder A block used to encode key(filename). If nil provided, default url encoder will be used + @param keyDecoder A block used to decode key(filename). If nil provided, default url decoder will be used + @result A new cache with the specified name. + */ +- (instancetype)initWithName:(nonnull NSString *)name + rootPath:(nonnull NSString *)rootPath + serializer:(nullable PINDiskCacheSerializerBlock)serializer + deserializer:(nullable PINDiskCacheDeserializerBlock)deserializer + keyEncoder:(nullable PINDiskCacheKeyEncoderBlock)keyEncoder + keyDecoder:(nullable PINDiskCacheKeyDecoderBlock)keyDecoder; /** Multiple instances with the same name are *not* allowed and can *not* safely @@ -117,6 +138,7 @@ PIN_SUBCLASSING_RESTRICTED @param deserializer A block used to deserialize object read from disk. If nil provided, default NSKeyedUnarchiver serialized will be used. @param keyEncoder A block used to encode key(filename). If nil provided, default url encoder will be used @param keyDecoder A block used to decode key(filename). If nil provided, default url decoder will be used + @param ttlCache Whether or not the cache should behave as a TTL cache. @result A new cache with the specified name. */ - (instancetype)initWithName:(nonnull NSString *)name @@ -124,7 +146,8 @@ PIN_SUBCLASSING_RESTRICTED serializer:(nullable PINDiskCacheSerializerBlock)serializer deserializer:(nullable PINDiskCacheDeserializerBlock)deserializer keyEncoder:(nullable PINDiskCacheKeyEncoderBlock)keyEncoder - keyDecoder:(nullable PINDiskCacheKeyDecoderBlock)keyDecoder NS_DESIGNATED_INITIALIZER; + keyDecoder:(nullable PINDiskCacheKeyDecoderBlock)keyDecoder + ttlCache:(BOOL)ttlCache NS_DESIGNATED_INITIALIZER; @end diff --git a/sample/UrlGet/Vendor/PINCache/Source/PINCache.m b/sample/UrlGet/Vendor/PINCache/Source/PINCache.m index 81c15649..b52f1f63 100644 --- a/sample/UrlGet/Vendor/PINCache/Source/PINCache.m +++ b/sample/UrlGet/Vendor/PINCache/Source/PINCache.m @@ -4,7 +4,11 @@ #import "PINCache.h" +#if SWIFT_PACKAGE +@import PINOperation; +#else #import +#endif static NSString * const PINCachePrefix = @"com.pinterest.PINCache"; static NSString * const PINCacheSharedName = @"PINCacheShared"; @@ -44,6 +48,17 @@ - (instancetype)initWithName:(NSString *)name deserializer:(PINDiskCacheDeserializerBlock)deserializer keyEncoder:(PINDiskCacheKeyEncoderBlock)keyEncoder keyDecoder:(PINDiskCacheKeyDecoderBlock)keyDecoder +{ + return [self initWithName:name rootPath:rootPath serializer:serializer deserializer:deserializer keyEncoder:keyEncoder keyDecoder:keyDecoder ttlCache:NO]; +} + +- (instancetype)initWithName:(NSString *)name + rootPath:(NSString *)rootPath + serializer:(PINDiskCacheSerializerBlock)serializer + deserializer:(PINDiskCacheDeserializerBlock)deserializer + keyEncoder:(PINDiskCacheKeyEncoderBlock)keyEncoder + keyDecoder:(PINDiskCacheKeyDecoderBlock)keyDecoder + ttlCache:(BOOL)ttlCache { if (!name) return nil; @@ -58,10 +73,11 @@ - (instancetype)initWithName:(NSString *)name rootPath:rootPath serializer:serializer deserializer:deserializer - keyEncoder:nil - keyDecoder:nil - operationQueue:_operationQueue]; - _memoryCache = [[PINMemoryCache alloc] initWithOperationQueue:_operationQueue]; + keyEncoder:keyEncoder + keyDecoder:keyDecoder + operationQueue:_operationQueue + ttlCache:ttlCache]; + _memoryCache = [[PINMemoryCache alloc] initWithName:_name operationQueue:_operationQueue ttlCache:ttlCache]; } return self; } @@ -106,7 +122,7 @@ - (void)objectForKeyAsync:(NSString *)key completion:(PINCacheObjectBlock)block return; [self.operationQueue scheduleOperation:^{ - [self->_memoryCache objectForKeyAsync:key completion:^(PINMemoryCache *memoryCache, NSString *memoryCacheKey, id memoryCacheObject) { + [self->_memoryCache objectForKeyAsync:key completion:^(id memoryCache, NSString *memoryCacheKey, id memoryCacheObject) { if (memoryCacheObject) { // Update file modification date. TODO: make this a separate method? [self->_diskCache fileURLForKeyAsync:memoryCacheKey completion:^(NSString * _Nonnull key, NSURL * _Nullable fileURL) {}]; @@ -134,7 +150,17 @@ - (void)setObjectAsync:(id )object forKey:(NSString *)key completion:( [self setObjectAsync:object forKey:key withCost:0 completion:block]; } +- (void)setObjectAsync:(id )object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit completion:(PINCacheObjectBlock)block +{ + [self setObjectAsync:object forKey:key withCost:0 ageLimit:ageLimit completion:block]; +} + - (void)setObjectAsync:(id )object forKey:(NSString *)key withCost:(NSUInteger)cost completion:(PINCacheObjectBlock)block +{ + [self setObjectAsync:object forKey:key withCost:cost ageLimit:0.0 completion:block]; +} + +- (void)setObjectAsync:(nonnull id)object forKey:(nonnull NSString *)key withCost:(NSUInteger)cost ageLimit:(NSTimeInterval)ageLimit completion:(nullable PINCacheObjectBlock)block { if (!key || !object) return; @@ -142,10 +168,10 @@ - (void)setObjectAsync:(id )object forKey:(NSString *)key withCost:(NS PINOperationGroup *group = [PINOperationGroup asyncOperationGroupWithQueue:_operationQueue]; [group addOperation:^{ - [_memoryCache setObject:object forKey:key withCost:cost]; + [self->_memoryCache setObject:object forKey:key withCost:cost ageLimit:ageLimit]; }]; [group addOperation:^{ - [_diskCache setObject:object forKey:key]; + [self->_diskCache setObject:object forKey:key withAgeLimit:ageLimit]; }]; if (block) { @@ -165,10 +191,10 @@ - (void)removeObjectForKeyAsync:(NSString *)key completion:(PINCacheObjectBlock) PINOperationGroup *group = [PINOperationGroup asyncOperationGroupWithQueue:_operationQueue]; [group addOperation:^{ - [_memoryCache removeObjectForKey:key]; + [self->_memoryCache removeObjectForKey:key]; }]; [group addOperation:^{ - [_diskCache removeObjectForKey:key]; + [self->_diskCache removeObjectForKey:key]; }]; if (block) { @@ -185,10 +211,10 @@ - (void)removeAllObjectsAsync:(PINCacheBlock)block PINOperationGroup *group = [PINOperationGroup asyncOperationGroupWithQueue:_operationQueue]; [group addOperation:^{ - [_memoryCache removeAllObjects]; + [self->_memoryCache removeAllObjects]; }]; [group addOperation:^{ - [_diskCache removeAllObjects]; + [self->_diskCache removeAllObjects]; }]; if (block) { @@ -208,10 +234,10 @@ - (void)trimToDateAsync:(NSDate *)date completion:(PINCacheBlock)block PINOperationGroup *group = [PINOperationGroup asyncOperationGroupWithQueue:_operationQueue]; [group addOperation:^{ - [_memoryCache trimToDate:date]; + [self->_memoryCache trimToDate:date]; }]; [group addOperation:^{ - [_diskCache trimToDate:date]; + [self->_diskCache trimToDate:date]; }]; if (block) { @@ -223,14 +249,34 @@ - (void)trimToDateAsync:(NSDate *)date completion:(PINCacheBlock)block [group start]; } +- (void)removeExpiredObjectsAsync:(PINCacheBlock)block +{ + PINOperationGroup *group = [PINOperationGroup asyncOperationGroupWithQueue:_operationQueue]; + + [group addOperation:^{ + [self->_memoryCache removeExpiredObjects]; + }]; + [group addOperation:^{ + [self->_diskCache removeExpiredObjects]; + }]; + + if (block) { + [group setCompletion:^{ + block(self); + }]; + } + + [group start]; +} + #pragma mark - Public Synchronous Accessors - - (NSUInteger)diskByteCount { __block NSUInteger byteCount = 0; - [_diskCache synchronouslyLockFileAccessWhileExecutingBlock:^(PINDiskCache *diskCache) { - byteCount = diskCache.byteCount; + [_diskCache synchronouslyLockFileAccessWhileExecutingBlock:^(id diskCache) { + byteCount = ((PINDiskCache *)diskCache).byteCount; }]; return byteCount; @@ -269,13 +315,23 @@ - (void)setObject:(id )object forKey:(NSString *)key [self setObject:object forKey:key withCost:0]; } +- (void)setObject:(id )object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit +{ + [self setObject:object forKey:key withCost:0 ageLimit:ageLimit]; +} + - (void)setObject:(id )object forKey:(NSString *)key withCost:(NSUInteger)cost +{ + [self setObject:object forKey:key withCost:cost ageLimit:0.0]; +} + +- (void)setObject:(nullable id)object forKey:(nonnull NSString *)key withCost:(NSUInteger)cost ageLimit:(NSTimeInterval)ageLimit { if (!key || !object) return; - [_memoryCache setObject:object forKey:key withCost:cost]; - [_diskCache setObject:object forKey:key]; + [_memoryCache setObject:object forKey:key withCost:cost ageLimit:ageLimit]; + [_diskCache setObject:object forKey:key withAgeLimit:ageLimit]; } - (nullable id)objectForKeyedSubscript:(NSString *)key @@ -310,6 +366,12 @@ - (void)trimToDate:(NSDate *)date [_diskCache trimToDate:date]; } +- (void)removeExpiredObjects +{ + [_memoryCache removeExpiredObjects]; + [_diskCache removeExpiredObjects]; +} + - (void)removeAllObjects { [_memoryCache removeAllObjects]; diff --git a/sample/UrlGet/Vendor/PINCache/Source/PINCaching.h b/sample/UrlGet/Vendor/PINCache/Source/PINCaching.h index 6b94136f..326cd456 100644 --- a/sample/UrlGet/Vendor/PINCache/Source/PINCaching.h +++ b/sample/UrlGet/Vendor/PINCache/Source/PINCaching.h @@ -17,18 +17,18 @@ NS_ASSUME_NONNULL_BEGIN /** A callback block which provides only the cache as an argument */ -typedef void (^PINCacheBlock)(id cache); +typedef void (^PINCacheBlock)(__kindof id cache); /** A callback block which provides the cache, key and object as arguments */ -typedef void (^PINCacheObjectBlock)(id cache, NSString *key, id _Nullable object); +typedef void (^PINCacheObjectBlock)(__kindof id cache, NSString *key, id _Nullable object); /** A callback block used for enumeration which provides the cache, key and object as arguments plus a stop flag that may be flipped by the caller. */ -typedef void (^PINCacheObjectEnumerationBlock)(id cache, NSString *key, id _Nullable object, BOOL *stop); +typedef void (^PINCacheObjectEnumerationBlock)(__kindof id cache, NSString *key, id _Nullable object, BOOL *stop); /** A callback block which provides a BOOL value as argument @@ -78,6 +78,19 @@ typedef void (^PINCacheObjectContainmentBlock)(BOOL containsObject); */ - (void)setObjectAsync:(id)object forKey:(NSString *)key completion:(nullable PINCacheObjectBlock)block; +/** + Stores an object in the cache for the specified key and the specified age limit. This method returns immediately + and executes the passed block after the object has been stored, potentially in parallel with other blocks + on the . + + @param object An object to store in the cache. + @param key A key to associate with the object. This string will be copied. + @param ageLimit The age limit (in seconds) to associate with the object. An age limit <= 0 means there is no object-level age limit and the + cache-level TTL will be used for this object. + @param block A block to be executed concurrently after the object has been stored, or nil. + */ +- (void)setObjectAsync:(id)object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit completion:(nullable PINCacheObjectBlock)block; + /** Stores an object in the cache for the specified key and the specified memory cost. If the cost causes the total to go over the the cache is trimmed (oldest objects first). This method returns immediately @@ -91,6 +104,21 @@ typedef void (^PINCacheObjectContainmentBlock)(BOOL containsObject); */ - (void)setObjectAsync:(id)object forKey:(NSString *)key withCost:(NSUInteger)cost completion:(nullable PINCacheObjectBlock)block; +/** + Stores an object in the cache for the specified key and the specified memory cost and age limit. If the cost causes the total + to go over the the cache is trimmed (oldest objects first). This method returns immediately + and executes the passed block after the object has been stored, potentially in parallel with other blocks + on the . + + @param object An object to store in the cache. + @param key A key to associate with the object. This string will be copied. + @param cost An amount to add to the . + @param ageLimit The age limit (in seconds) to associate with the object. An age limit <= 0 means there is no object-level age limit and the cache-level TTL will be + used for this object. + @param block A block to be executed concurrently after the object has been stored, or nil. + */ +- (void)setObjectAsync:(id)object forKey:(NSString *)key withCost:(NSUInteger)cost ageLimit:(NSTimeInterval)ageLimit completion:(nullable PINCacheObjectBlock)block; + /** Removes the object for the specified key. This method returns immediately and executes the passed block after the object has been removed, potentially in parallel with other blocks on the . @@ -109,6 +137,15 @@ typedef void (^PINCacheObjectContainmentBlock)(BOOL containsObject); */ - (void)trimToDateAsync:(NSDate *)date completion:(nullable PINCacheBlock)block; +/** + Removes all expired objects from the cache. This includes objects that are considered expired due to the cache-level ageLimit + as well as object-level ageLimits. This method returns immediately and executes the passed block after the objects have been removed, + potentially in parallel with other blocks on the . + + @param block A block to be executed concurrently after the objects have been removed, or nil. + */ +- (void)removeExpiredObjectsAsync:(nullable PINCacheBlock)block; + /** Removes all objects from the cache.This method returns immediately and executes the passed block after the cache has been cleared, potentially in parallel with other blocks on the . @@ -150,6 +187,18 @@ typedef void (^PINCacheObjectContainmentBlock)(BOOL containsObject); */ - (void)setObject:(nullable id)object forKey:(NSString *)key; +/** + Stores an object in the cache for the specified key and age limit. This method blocks the calling thread until the + object has been set. Uses a lock to achieve synchronicity on the disk cache. + + @see setObjectAsync:forKey:completion: + @param object An object to store in the cache. + @param key A key to associate with the object. This string will be copied. + @param ageLimit The age limit (in seconds) to associate with the object. An age limit <= 0 means there is no + object-level age limit and the cache-level TTL will be used for this object. + */ +- (void)setObject:(nullable id)object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit; + /** Stores an object in the cache for the specified key and the specified memory cost. If the cost causes the total to go over the the cache is trimmed (oldest objects first). This method blocks the calling thread @@ -161,6 +210,19 @@ typedef void (^PINCacheObjectContainmentBlock)(BOOL containsObject); */ - (void)setObject:(nullable id)object forKey:(NSString *)key withCost:(NSUInteger)cost; +/** + Stores an object in the cache for the specified key and the specified memory cost and age limit. If the cost causes the total + to go over the the cache is trimmed (oldest objects first). This method blocks the calling thread + until the object has been stored. + + @param object An object to store in the cache. + @param key A key to associate with the object. This string will be copied. + @param cost An amount to add to the . + @param ageLimit The age limit (in seconds) to associate with the object. An age limit <= 0 means there is no object-level age + limit and the cache-level TTL will be used for this object. + */ +- (void)setObject:(nullable id)object forKey:(NSString *)key withCost:(NSUInteger)cost ageLimit:(NSTimeInterval)ageLimit; + /** Removes the object for the specified key. This method blocks the calling thread until the object has been removed. @@ -181,6 +243,13 @@ typedef void (^PINCacheObjectContainmentBlock)(BOOL containsObject); */ - (void)trimToDate:(NSDate *)date; +/** + Removes all expired objects from the cache. This includes objects that are considered expired due to the cache-level ageLimit + as well as object-level ageLimits. This method blocks the calling thread until the objects have been removed. + Uses a lock to achieve synchronicity on the disk cache. + */ +- (void)removeExpiredObjects; + /** Removes all objects from the cache. This method blocks the calling thread until the cache has been cleared. Uses a lock to achieve synchronicity on the disk cache. diff --git a/sample/UrlGet/Vendor/PINCache/Source/PINDiskCache.h b/sample/UrlGet/Vendor/PINCache/Source/PINDiskCache.h index d7ee5596..81bb26a4 100644 --- a/sample/UrlGet/Vendor/PINCache/Source/PINDiskCache.h +++ b/sample/UrlGet/Vendor/PINCache/Source/PINDiskCache.h @@ -4,21 +4,29 @@ #import -#import -#import -#import +#import "PINCacheMacros.h" +#import "PINCaching.h" +#import "PINCacheObjectSubscripting.h" NS_ASSUME_NONNULL_BEGIN @class PINDiskCache; @class PINOperationQueue; +extern NSString * const PINDiskCacheErrorDomain; +extern NSErrorUserInfoKey const PINDiskCacheErrorReadFailureCodeKey; +extern NSErrorUserInfoKey const PINDiskCacheErrorWriteFailureCodeKey; extern NSString * const PINDiskCachePrefix; +typedef NS_ENUM(NSInteger, PINDiskCacheError) { + PINDiskCacheErrorReadFailure = -1000, + PINDiskCacheErrorWriteFailure = -1001, +}; + /** A callback block which provides the cache, key and object as arguments */ -typedef void (^PINDiskCacheObjectBlock)(PINDiskCache *cache, NSString *key, id _Nullable object); +typedef void (^PINDiskCacheObjectBlock)(PINDiskCache *cache, NSString *key, id _Nullable object); /** A callback block which provides the key and fileURL of the object @@ -103,11 +111,6 @@ PIN_SUBCLASSING_RESTRICTED #pragma mark - Class -/** - This is temporary and should not be checked into the main branch - */ -@property (class, assign, nonatomic) BOOL disableAsynchronousStartup; - /** @param rootPath The path for where the cache should be stored. @param prefix The prefix for the cache name. @@ -152,7 +155,7 @@ PIN_SUBCLASSING_RESTRICTED /** The maximum number of bytes allowed on disk. This value is checked every time an object is set, if the written - size exceeds the limit a trim call is queued. Defaults to `0.0`, meaning no practical limit. + size exceeds the limit a trim call is queued. Defaults to 50MB. */ @property (assign) NSUInteger byteLimit; @@ -160,7 +163,7 @@ PIN_SUBCLASSING_RESTRICTED /** The maximum number of seconds an object is allowed to exist in the cache. Setting this to a value greater than `0.0` will start a recurring GCD timer with the same period that calls . - Setting it back to `0.0` will stop the timer. Defaults to `0.0`, meaning no limit. + Setting it back to `0.0` will stop the timer. Defaults to 30 days. */ @property (assign) NSTimeInterval ageLimit; @@ -185,9 +188,13 @@ PIN_SUBCLASSING_RESTRICTED - Accessing an object in the cache does not extend that object's lifetime in the cache - When attempting to access an object in the cache that has lived longer than self.ageLimit, the cache will behave as if the object does not exist + + @note If an object-level age limit is set via one of the @c -setObject:forKey:withAgeLimit methods, + that age limit overrides self.ageLimit. The overridden object age limit could be greater or less + than self.agelimit but must be greater than zero. */ -@property (nonatomic, assign, getter=isTTLCache) BOOL ttlCache; +@property (nonatomic, readonly, getter=isTTLCache) BOOL ttlCache; #pragma mark - Event Blocks /// @name Event Blocks @@ -242,8 +249,8 @@ PIN_SUBCLASSING_RESTRICTED - (instancetype)init NS_UNAVAILABLE; /** - Multiple instances with the same name are allowed and can safely access - the same data on disk thanks to the magic of seriality. + Multiple instances with the same name are *not* allowed as they would conflict + with each other. @see name @param name The name of the cache. @@ -252,8 +259,8 @@ PIN_SUBCLASSING_RESTRICTED - (instancetype)initWithName:(nonnull NSString *)name; /** - Multiple instances with the same name are allowed and can safely access - the same data on disk thanks to the magic of seriality. + Multiple instances with the same name are *not* allowed as they would conflict + with each other. @see name @param name The name of the cache. @@ -272,9 +279,7 @@ PIN_SUBCLASSING_RESTRICTED */ - (instancetype)initWithName:(nonnull NSString *)name rootPath:(nonnull NSString *)rootPath serializer:(nullable PINDiskCacheSerializerBlock)serializer deserializer:(nullable PINDiskCacheDeserializerBlock)deserializer; -/** - The designated initializer allowing you to override default NSKeyedArchiver/NSKeyedUnarchiver serialization. - +/** @see name @param name The name of the cache. @param rootPath The path of the cache. @@ -285,6 +290,27 @@ PIN_SUBCLASSING_RESTRICTED */ - (instancetype)initWithName:(nonnull NSString *)name rootPath:(nonnull NSString *)rootPath serializer:(nullable PINDiskCacheSerializerBlock)serializer deserializer:(nullable PINDiskCacheDeserializerBlock)deserializer operationQueue:(nonnull PINOperationQueue *)operationQueue __attribute__((deprecated)); +/** + @see name + @param name The name of the cache. + @param prefix The prefix for the cache name. Defaults to com.pinterest.PINDiskCache + @param rootPath The path of the cache. + @param serializer A block used to serialize object. If nil provided, default NSKeyedArchiver serialized will be used. + @param deserializer A block used to deserialize object. If nil provided, default NSKeyedUnarchiver serialized will be used. + @param keyEncoder A block used to encode key(filename). If nil provided, default url encoder will be used + @param keyDecoder A block used to decode key(filename). If nil provided, default url decoder will be used + @param operationQueue A PINOperationQueue to run asynchronous operations + @result A new cache with the specified name. + */ +- (instancetype)initWithName:(nonnull NSString *)name + prefix:(nonnull NSString *)prefix + rootPath:(nonnull NSString *)rootPath + serializer:(nullable PINDiskCacheSerializerBlock)serializer + deserializer:(nullable PINDiskCacheDeserializerBlock)deserializer + keyEncoder:(nullable PINDiskCacheKeyEncoderBlock)keyEncoder + keyDecoder:(nullable PINDiskCacheKeyDecoderBlock)keyDecoder + operationQueue:(nonnull PINOperationQueue *)operationQueue; + /** The designated initializer allowing you to override default NSKeyedArchiver/NSKeyedUnarchiver serialization. @@ -297,6 +323,7 @@ PIN_SUBCLASSING_RESTRICTED @param keyEncoder A block used to encode key(filename). If nil provided, default url encoder will be used @param keyDecoder A block used to decode key(filename). If nil provided, default url decoder will be used @param operationQueue A PINOperationQueue to run asynchronous operations + @param ttlCache Whether or not the cache should behave as a TTL cache. @result A new cache with the specified name. */ - (instancetype)initWithName:(nonnull NSString *)name @@ -306,7 +333,8 @@ PIN_SUBCLASSING_RESTRICTED deserializer:(nullable PINDiskCacheDeserializerBlock)deserializer keyEncoder:(nullable PINDiskCacheKeyEncoderBlock)keyEncoder keyDecoder:(nullable PINDiskCacheKeyDecoderBlock)keyDecoder - operationQueue:(nonnull PINOperationQueue *)operationQueue NS_DESIGNATED_INITIALIZER; + operationQueue:(nonnull PINOperationQueue *)operationQueue + ttlCache:(BOOL)ttlCache NS_DESIGNATED_INITIALIZER; #pragma mark - Asynchronous Methods /// @name Asynchronous Methods @@ -355,6 +383,18 @@ PIN_SUBCLASSING_RESTRICTED */ - (void)setObjectAsync:(id )object forKey:(NSString *)key completion:(nullable PINDiskCacheObjectBlock)block; +/** + Stores an object in the cache for the specified key and age limit. This method returns immediately and executes the + passed block as soon as the object has been stored. + + @param object An object to store in the cache. + @param key A key to associate with the object. This string will be copied. + @param ageLimit The age limit (in seconds) to associate with the object. An age limit <= 0 means there is no object-level age limit and the cache-level TTL + will be used for this object. + @param block A block to be executed serially after the object has been stored, or nil. + */ +- (void)setObjectAsync:(id )object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit completion:(nullable PINDiskCacheObjectBlock)block; + /** Stores an object in the cache for the specified key and the specified memory cost. If the cost causes the total to go over the the cache is trimmed (oldest objects first). This method returns immediately @@ -368,6 +408,21 @@ PIN_SUBCLASSING_RESTRICTED */ - (void)setObjectAsync:(id )object forKey:(NSString *)key withCost:(NSUInteger)cost completion:(nullable PINCacheObjectBlock)block; +/** + Stores an object in the cache for the specified key and the specified memory cost and age limit. If the cost causes the total + to go over the the cache is trimmed (oldest objects first). This method returns immediately + and executes the passed block after the object has been stored, potentially in parallel with other blocks + on the . + + @param object An object to store in the cache. + @param key A key to associate with the object. This string will be copied. + @param cost An amount to add to the . + @param ageLimit The age limit (in seconds) to associate with the object. An age limit <= 0 means there is no object-level age limit and the cache-level TTL will be used for + this object. + @param block A block to be executed concurrently after the object has been stored, or nil. + */ +- (void)setObjectAsync:(id )object forKey:(NSString *)key withCost:(NSUInteger)cost ageLimit:(NSTimeInterval)ageLimit completion:(nullable PINCacheObjectBlock)block; + /** Removes the object for the specified key. This method returns immediately and executes the passed block as soon as the object has been removed. @@ -393,6 +448,8 @@ PIN_SUBCLASSING_RESTRICTED @param byteCount The cache will be trimmed equal to or smaller than this size. @param block A block to be executed serially after the cache has been trimmed, or nil. + + @note This will not remove objects that have been added via one of the @c -setObject:forKey:withAgeLimit methods. */ - (void)trimToSizeByDateAsync:(NSUInteger)byteCount completion:(nullable PINCacheBlock)block; @@ -456,6 +513,18 @@ PIN_SUBCLASSING_RESTRICTED */ - (void)setObject:(nullable id )object forKey:(NSString *)key; +/** + Stores an object in the cache for the specified key and age limit. This method blocks the calling thread until + the object has been stored. + + @see setObjectAsync:forKey:completion: + @param object An object to store in the cache. + @param key A key to associate with the object. This string will be copied. + @param ageLimit The age limit (in seconds) to associate with the object. An age limit <= 0 means there is + no object-level age limit and the cache-level TTL will be used for this object. + */ +- (void)setObject:(nullable id )object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit; + /** Removes objects from the cache, largest first, until the cache is equal to or smaller than the specified byteCount. This method blocks the calling thread until the cache has been trimmed. @@ -471,6 +540,8 @@ PIN_SUBCLASSING_RESTRICTED @see trimToSizeByDateAsync: @param byteCount The cache will be trimmed equal to or smaller than this size. + + @note This will not remove objects that have been added via one of the @c -setObject:forKey:withAgeLimit methods. */ - (void)trimToSizeByDate:(NSUInteger)byteCount; @@ -515,6 +586,7 @@ typedef void (^PINDiskCacheBlock)(PINDiskCache *cache); - (void)trimToSizeByDate:(NSUInteger)byteCount block:(nullable PINDiskCacheBlock)block __attribute__((deprecated)); - (void)removeAllObjects:(nullable PINDiskCacheBlock)block __attribute__((deprecated)); - (void)enumerateObjectsWithBlock:(PINDiskCacheFileURLBlock)block completionBlock:(nullable PINDiskCacheBlock)completionBlock __attribute__((deprecated)); +- (void)setTtlCache:(BOOL)ttlCache DEPRECATED_MSG_ATTRIBUTE("ttlCache is no longer a settable property and must now be set via initializer."); @end NS_ASSUME_NONNULL_END diff --git a/sample/UrlGet/Vendor/PINCache/Source/PINDiskCache.m b/sample/UrlGet/Vendor/PINCache/Source/PINDiskCache.m index 96a19af1..f30a5ad7 100644 --- a/sample/UrlGet/Vendor/PINCache/Source/PINDiskCache.m +++ b/sample/UrlGet/Vendor/PINCache/Source/PINDiskCache.m @@ -9,8 +9,13 @@ #endif #import +#import +#if SWIFT_PACKAGE +@import PINOperation; +#else #import +#endif #define PINDiskCacheError(error) if (error) { NSLog(@"%@ (%d) ERROR: %@", \ [[NSString stringWithUTF8String:__FILE__] lastPathComponent], \ @@ -18,6 +23,10 @@ #define PINDiskCacheException(exception) if (exception) { NSAssert(NO, [exception reason]); } +const char * PINDiskCacheAgeLimitAttributeName = "com.pinterest.PINDiskCache.ageLimit"; +NSString * const PINDiskCacheErrorDomain = @"com.pinterest.PINDiskCache"; +NSErrorUserInfoKey const PINDiskCacheErrorReadFailureCodeKey = @"PINDiskCacheErrorReadFailureCodeKey"; +NSErrorUserInfoKey const PINDiskCacheErrorWriteFailureCodeKey = @"PINDiskCacheErrorWriteFailureCodeKey"; NSString * const PINDiskCachePrefix = @"com.pinterest.PINDiskCache"; static NSString * const PINDiskCacheSharedName = @"PINDiskCacheShared"; @@ -25,8 +34,6 @@ static NSString * const PINDiskCacheOperationIdentifierTrimToSize = @"PINDiskCacheOperationIdentifierTrimToSize"; static NSString * const PINDiskCacheOperationIdentifierTrimToSizeByDate = @"PINDiskCacheOperationIdentifierTrimToSizeByDate"; -static BOOL _disableAsyncronousStartup = NO; - typedef NS_ENUM(NSUInteger, PINDiskCacheCondition) { PINDiskCacheConditionNotReady = 0, PINDiskCacheConditionReady = 1, @@ -42,9 +49,25 @@ typedef NS_ENUM(NSUInteger, PINDiskCacheCondition) { return (result == NSOrderedDescending) ? newDate : existingDate; }; +const char * PINDiskCacheFileSystemRepresentation(NSURL *url) +{ +#ifdef __MAC_10_13 // Xcode >= 9 + // -fileSystemRepresentation is available on macOS >= 10.9 + if (@available(macOS 10.9, iOS 7.0, watchOS 2.0, tvOS 9.0, *)) { + return url.fileSystemRepresentation; + } +#endif + return [url.path cStringUsingEncoding:NSUTF8StringEncoding]; +} + @interface PINDiskCacheMetadata : NSObject -@property (nonatomic, strong) NSDate *date; +// When the object was added to the disk cache +@property (nonatomic, strong) NSDate *createdDate; +// Last time the object was accessed +@property (nonatomic, strong) NSDate *lastModifiedDate; @property (nonatomic, strong) NSNumber *size; +// Age limit is used in conjuction with ttl +@property (nonatomic) NSTimeInterval ageLimit; @end @interface PINDiskCache () { @@ -65,6 +88,7 @@ @interface PINDiskCache () { @property (assign, nonatomic) BOOL diskWritable; @property (assign, nonatomic) pthread_cond_t diskStateKnownCondition; @property (assign, nonatomic) BOOL diskStateKnown; +@property (assign, nonatomic) BOOL writingProtectionOptionSet; @end @implementation PINDiskCache @@ -83,24 +107,15 @@ @implementation PINDiskCache #if TARGET_OS_IPHONE @synthesize writingProtectionOption = _writingProtectionOption; +@synthesize writingProtectionOptionSet = _writingProtectionOptionSet; #endif #pragma mark - Initialization - -+ (BOOL)disableAsynchronousStartup -{ - return _disableAsyncronousStartup; -} - -+ (void)setDisableAsynchronousStartup:(BOOL)disableAsynchronousStartup -{ - _disableAsyncronousStartup = disableAsynchronousStartup; -} - - (void)dealloc { __unused int result = pthread_mutex_destroy(&_mutex); - NSCAssert(result == 0, @"Failed to destroy lock in PINMemoryCache %p. Code: %d", (void *)self, result); + NSCAssert(result == 0, @"Failed to destroy lock in PINDiskCache %p. Code: %d", (void *)self, result); pthread_cond_destroy(&_diskWritableCondition); pthread_cond_destroy(&_diskStateKnownCondition); } @@ -154,23 +169,44 @@ - (instancetype)initWithName:(NSString *)name keyDecoder:(PINDiskCacheKeyDecoderBlock)keyDecoder operationQueue:(PINOperationQueue *)operationQueue { - if (!name) + return [self initWithName:name prefix:prefix + rootPath:rootPath + serializer:serializer + deserializer:deserializer + keyEncoder:keyEncoder + keyDecoder:keyDecoder + operationQueue:operationQueue + ttlCache:NO]; +} + +- (instancetype)initWithName:(NSString *)name + prefix:(NSString *)prefix + rootPath:(NSString *)rootPath + serializer:(PINDiskCacheSerializerBlock)serializer + deserializer:(PINDiskCacheDeserializerBlock)deserializer + keyEncoder:(PINDiskCacheKeyEncoderBlock)keyEncoder + keyDecoder:(PINDiskCacheKeyDecoderBlock)keyDecoder + operationQueue:(PINOperationQueue *)operationQueue + ttlCache:(BOOL)ttlCache +{ + if (!name) { return nil; - + } NSAssert(((!serializer && !deserializer) || (serializer && deserializer)), @"PINDiskCache must be initialized with a serializer AND deserializer."); NSAssert(((!keyEncoder && !keyDecoder) || (keyEncoder && keyDecoder)), - @"PINDiskCache must be initialized with a encoder AND decoder."); + @"PINDiskCache must be initialized with an encoder AND decoder."); if (self = [super init]) { __unused int result = pthread_mutex_init(&_mutex, NULL); - NSAssert(result == 0, @"Failed to init lock in PINMemoryCache %@. Code: %d", self, result); + NSAssert(result == 0, @"Failed to init lock in PINDiskCache %@. Code: %d", self, result); _name = [name copy]; _prefix = [prefix copy]; _operationQueue = operationQueue; + _ttlCache = ttlCache; _willAddObjectBlock = nil; _willRemoveObjectBlock = nil; _willRemoveAllObjectsBlock = nil; @@ -186,7 +222,9 @@ - (instancetype)initWithName:(NSString *)name _ageLimit = 60 * 60 * 24 * 30; #if TARGET_OS_IPHONE - _writingProtectionOption = NSDataWritingFileProtectionNone; + _writingProtectionOptionSet = NO; + // This is currently the default for files, but we'd rather not write it if it's unspecified. + _writingProtectionOption = NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication; #endif _metadata = [[NSMutableDictionary alloc] init]; @@ -225,7 +263,7 @@ - (instancetype)initWithName:(NSString *)name //we don't want to do anything without setting up the disk cache, but we also don't want to block init, it can take a while to initialize. This must *not* be done on _operationQueue because other operations added may hold the lock and fill up the queue. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - [self lockForStartup]; + [self lock]; [self _locked_createCacheDirectory]; [self unlock]; [self initializeDiskProperties]; @@ -236,7 +274,7 @@ - (instancetype)initWithName:(NSString *)name - (NSString *)description { - return [[NSString alloc] initWithFormat:@"%@.%@.%p", PINDiskCachePrefix, _name, (void *)self]; + return [[NSString alloc] initWithFormat:@"%@.%@.%p", PINDiskCachePrefix, _name, (__bridge void *)self]; } + (PINDiskCache *)sharedCache @@ -291,7 +329,14 @@ - (NSString *)decodedString:(NSString *)string - (PINDiskCacheSerializerBlock)defaultSerializer { return ^NSData*(id object, NSString *key){ - return [NSKeyedArchiver archivedDataWithRootObject:object]; + if (@available(iOS 11.0, macOS 10.13, tvOS 11.0, watchOS 4.0, *)) { + NSError *error = nil; + NSData *data = [NSKeyedArchiver archivedDataWithRootObject:object requiringSecureCoding:NO error:&error]; + PINDiskCacheError(error); + return data; + } else { + return [NSKeyedArchiver archivedDataWithRootObject:object]; + } }; } @@ -458,16 +503,72 @@ - (BOOL)_locked_createCacheDirectory return created; } ++ (NSArray *)resourceKeys +{ + static NSArray *resourceKeys = nil; + static dispatch_once_t predicate; + + dispatch_once(&predicate, ^{ + resourceKeys = @[ NSURLCreationDateKey, NSURLContentModificationDateKey, NSURLTotalFileAllocatedSizeKey ]; + }); + + return resourceKeys; +} + +/** + * @return File size in bytes. + */ +- (NSUInteger)_locked_initializeDiskPropertiesForFile:(NSURL *)fileURL fileKey:(NSString *)fileKey +{ + NSError *error = nil; + + NSDictionary *dictionary = [fileURL resourceValuesForKeys:[PINDiskCache resourceKeys] error:&error]; + PINDiskCacheError(error); + + if (_metadata[fileKey] == nil) { + _metadata[fileKey] = [[PINDiskCacheMetadata alloc] init]; + } + + NSDate *createdDate = dictionary[NSURLCreationDateKey]; + if (createdDate && fileKey) + _metadata[fileKey].createdDate = createdDate; + + NSDate *lastModifiedDate = dictionary[NSURLContentModificationDateKey]; + if (lastModifiedDate && fileKey) + _metadata[fileKey].lastModifiedDate = lastModifiedDate; + + NSNumber *fileSize = dictionary[NSURLTotalFileAllocatedSizeKey]; + if (fileSize) { + _metadata[fileKey].size = fileSize; + } + + if (_ttlCache) { + NSTimeInterval ageLimit; + ssize_t res = getxattr(PINDiskCacheFileSystemRepresentation(fileURL), PINDiskCacheAgeLimitAttributeName, &ageLimit, sizeof(NSTimeInterval), 0, 0); + if(res > 0) { + _metadata[fileKey].ageLimit = ageLimit; + } else if (res == -1) { + // Ignore if the extended attribute was never recorded for this file. + if (errno != ENOATTR) { + NSDictionary *userInfo = @{ PINDiskCacheErrorReadFailureCodeKey : @(errno)}; + error = [NSError errorWithDomain:PINDiskCacheErrorDomain code:PINDiskCacheErrorReadFailure userInfo:userInfo]; + PINDiskCacheError(error); + } + } + } + + return [fileSize unsignedIntegerValue]; +} + - (void)initializeDiskProperties { NSUInteger byteCount = 0; - NSArray *keys = @[ NSURLContentModificationDateKey, NSURLTotalFileAllocatedSizeKey ]; - + NSError *error = nil; - [self lockForStartup]; + [self lock]; NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:_cacheURL - includingPropertiesForKeys:keys + includingPropertiesForKeys:[PINDiskCache resourceKeys] options:NSDirectoryEnumerationSkipsHiddenFiles error:&error]; [self unlock]; @@ -475,37 +576,24 @@ - (void)initializeDiskProperties PINDiskCacheError(error); for (NSURL *fileURL in files) { - NSString *key = [self keyForEncodedFileURL:fileURL]; - - error = nil; - + NSString *fileKey = [self keyForEncodedFileURL:fileURL]; // Continually grab and release lock while processing files to avoid contention - [self lockForStartup]; - NSDictionary *dictionary = [fileURL resourceValuesForKeys:keys error:&error]; - PINDiskCacheError(error); - - if (_metadata[key] == nil) { - _metadata[key] = [[PINDiskCacheMetadata alloc] init]; - } - - NSDate *date = [dictionary objectForKey:NSURLContentModificationDateKey]; - if (date && key) - _metadata[key].date = date; - - NSNumber *fileSize = [dictionary objectForKey:NSURLTotalFileAllocatedSizeKey]; - if (fileSize) { - _metadata[key].size = fileSize; - byteCount += [fileSize unsignedIntegerValue]; - } + [self lock]; + if (_metadata[fileKey] == nil) { + byteCount += [self _locked_initializeDiskPropertiesForFile:fileURL fileKey:fileKey]; + } [self unlock]; } - [self lockForStartup]; + [self lock]; if (byteCount > 0) _byteCount = byteCount; if (self->_byteLimit > 0 && self->_byteCount > self->_byteLimit) [self trimToSizeByDateAsync:self->_byteLimit completion:nil]; + + if (self->_ttlCache) + [self removeExpiredObjectsAsync:nil]; _diskStateKnown = YES; pthread_cond_broadcast(&_diskStateKnownCondition); @@ -533,28 +621,67 @@ - (BOOL)_locked_setFileModificationDate:(NSDate *)date forURL:(NSURL *)fileURL error:&error]; PINDiskCacheError(error); - if (success) { + return success; +} + +- (void)asynchronouslySetAgeLimit:(NSTimeInterval)ageLimit forURL:(NSURL *)fileURL +{ + [self.operationQueue scheduleOperation:^{ + [self lockForWriting]; + [self _locked_setAgeLimit:ageLimit forURL:fileURL]; + [self unlock]; + } withPriority:PINOperationQueuePriorityLow]; +} + +- (BOOL)_locked_setAgeLimit:(NSTimeInterval)ageLimit forURL:(NSURL *)fileURL +{ + if (!fileURL) { + return NO; + } + + NSError *error = nil; + if (ageLimit <= 0.0) { + if (removexattr(PINDiskCacheFileSystemRepresentation(fileURL), PINDiskCacheAgeLimitAttributeName, 0) != 0) { + // Ignore if the extended attribute was never recorded for this file. + if (errno != ENOATTR) { + NSDictionary *userInfo = @{ PINDiskCacheErrorWriteFailureCodeKey : @(errno)}; + error = [NSError errorWithDomain:PINDiskCacheErrorDomain code:PINDiskCacheErrorWriteFailure userInfo:userInfo]; + PINDiskCacheError(error); + } + } + } else { + if (setxattr(PINDiskCacheFileSystemRepresentation(fileURL), PINDiskCacheAgeLimitAttributeName, &ageLimit, sizeof(NSTimeInterval), 0, 0) != 0) { + NSDictionary *userInfo = @{ PINDiskCacheErrorWriteFailureCodeKey : @(errno)}; + error = [NSError errorWithDomain:PINDiskCacheErrorDomain code:PINDiskCacheErrorWriteFailure userInfo:userInfo]; + PINDiskCacheError(error); + } + } + + if (!error) { NSString *key = [self keyForEncodedFileURL:fileURL]; if (key) { - _metadata[key].date = date; + _metadata[key].ageLimit = ageLimit; } } - - return success; + + return !error; } - (BOOL)removeFileAndExecuteBlocksForKey:(NSString *)key { NSURL *fileURL = [self encodedFileURLForKey:key]; - + if (!fileURL) { + return NO; + } + // We only need to lock until writable at the top because once writable, always writable [self lockForWriting]; - if (!fileURL || ![[NSFileManager defaultManager] fileExistsAtPath:[fileURL path]]) { + if (![[NSFileManager defaultManager] fileExistsAtPath:[fileURL path]]) { [self unlock]; return NO; } - PINCacheObjectBlock willRemoveObjectBlock = _willRemoveObjectBlock; + PINDiskCacheObjectBlock willRemoveObjectBlock = _willRemoveObjectBlock; if (willRemoveObjectBlock) { [self unlock]; willRemoveObjectBlock(self, key, nil); @@ -575,7 +702,7 @@ - (BOOL)removeFileAndExecuteBlocksForKey:(NSString *)key [_metadata removeObjectForKey:key]; - PINCacheObjectBlock didRemoveObjectBlock = _didRemoveObjectBlock; + PINDiskCacheObjectBlock didRemoveObjectBlock = _didRemoveObjectBlock; if (didRemoveObjectBlock) { [self unlock]; _didRemoveObjectBlock(self, key, nil); @@ -589,74 +716,98 @@ - (BOOL)removeFileAndExecuteBlocksForKey:(NSString *)key - (void)trimDiskToSize:(NSUInteger)trimByteCount { + NSMutableArray *keysToRemove = nil; + [self lockForWriting]; if (_byteCount > trimByteCount) { + keysToRemove = [[NSMutableArray alloc] init]; + NSArray *keysSortedBySize = [_metadata keysSortedByValueUsingComparator:^NSComparisonResult(PINDiskCacheMetadata * _Nonnull obj1, PINDiskCacheMetadata * _Nonnull obj2) { return [obj1.size compare:obj2.size]; }]; + NSUInteger bytesSaved = 0; for (NSString *key in [keysSortedBySize reverseObjectEnumerator]) { // largest objects first - [self unlock]; - - //unlock, removeFileAndExecuteBlocksForKey handles locking itself - [self removeFileAndExecuteBlocksForKey:key]; - - [self lock]; - - if (_byteCount <= trimByteCount) + [keysToRemove addObject:key]; + NSNumber *byteSize = _metadata[key].size; + if (byteSize) { + bytesSaved += [byteSize unsignedIntegerValue]; + } + if (_byteCount - bytesSaved <= trimByteCount) { break; + } } } [self unlock]; + + for (NSString *key in keysToRemove) { + [self removeFileAndExecuteBlocksForKey:key]; + } } +// This is the default trimming method which happens automatically - (void)trimDiskToSizeByDate:(NSUInteger)trimByteCount { + if (self.isTTLCache) { + [self removeExpiredObjects]; + } + + NSMutableArray *keysToRemove = nil; + [self lockForWriting]; if (_byteCount > trimByteCount) { - NSArray *keysSortedByDate = [_metadata keysSortedByValueUsingComparator:^NSComparisonResult(PINDiskCacheMetadata * _Nonnull obj1, PINDiskCacheMetadata * _Nonnull obj2) { - return [obj1.date compare:obj2.date]; + keysToRemove = [[NSMutableArray alloc] init]; + + // last modified represents last access. + NSArray *keysSortedByLastModifiedDate = [_metadata keysSortedByValueUsingComparator:^NSComparisonResult(PINDiskCacheMetadata * _Nonnull obj1, PINDiskCacheMetadata * _Nonnull obj2) { + return [obj1.lastModifiedDate compare:obj2.lastModifiedDate]; }]; - for (NSString *key in keysSortedByDate) { // oldest objects first - [self unlock]; - - //unlock, removeFileAndExecuteBlocksForKey handles locking itself - [self removeFileAndExecuteBlocksForKey:key]; - - [self lock]; - - if (_byteCount <= trimByteCount) + NSUInteger bytesSaved = 0; + // objects accessed last first. + for (NSString *key in keysSortedByLastModifiedDate) { + [keysToRemove addObject:key]; + NSNumber *byteSize = _metadata[key].size; + if (byteSize) { + bytesSaved += [byteSize unsignedIntegerValue]; + } + if (_byteCount - bytesSaved <= trimByteCount) { break; + } } } [self unlock]; + + for (NSString *key in keysToRemove) { + [self removeFileAndExecuteBlocksForKey:key]; + } } - (void)trimDiskToDate:(NSDate *)trimDate { [self lockForWriting]; - NSArray *keysSortedByDate = [_metadata keysSortedByValueUsingComparator:^NSComparisonResult(PINDiskCacheMetadata * _Nonnull obj1, PINDiskCacheMetadata * _Nonnull obj2) { - return [obj1.date compare:obj2.date]; + NSArray *keysSortedByCreatedDate = [_metadata keysSortedByValueUsingComparator:^NSComparisonResult(PINDiskCacheMetadata * _Nonnull obj1, PINDiskCacheMetadata * _Nonnull obj2) { + return [obj1.createdDate compare:obj2.createdDate]; }]; + + NSMutableArray *keysToRemove = [[NSMutableArray alloc] init]; - for (NSString *key in keysSortedByDate) { // oldest files first - NSDate *accessDate = _metadata[key].date; - if (!accessDate) + for (NSString *key in keysSortedByCreatedDate) { // oldest files first + NSDate *createdDate = _metadata[key].createdDate; + if (!createdDate || _metadata[key].ageLimit > 0.0) continue; - if ([accessDate compare:trimDate] == NSOrderedAscending) { // older than trim date - [self unlock]; - - //unlock, removeFileAndExecuteBlocksForKey handles locking itself - [self removeFileAndExecuteBlocksForKey:key]; - - [self lock]; + if ([createdDate compare:trimDate] == NSOrderedAscending) { // older than trim date + [keysToRemove addObject:key]; } else { break; } } [self unlock]; + + for (NSString *key in keysToRemove) { + [self removeFileAndExecuteBlocksForKey:key]; + } } - (void)trimToAgeLimitRecursively @@ -668,13 +819,24 @@ - (void)trimToAgeLimitRecursively return; NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:-ageLimit]; - [self trimDiskToDate:date]; + [self trimToDateAsync:date completion:nil]; - dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(_ageLimit * NSEC_PER_SEC)); + dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(ageLimit * NSEC_PER_SEC)); dispatch_after(time, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { - [self.operationQueue scheduleOperation:^{ - [self trimToAgeLimitRecursively]; - } withPriority:PINOperationQueuePriorityLow]; + // Ensure that ageLimit is the same as when we were scheduled, otherwise, we've been + // rescheduled (another dispatch_after was issued) and should cancel. + BOOL shouldReschedule = YES; + [self lock]; + if (ageLimit != self->_ageLimit) { + shouldReschedule = NO; + } + [self unlock]; + + if (shouldReschedule) { + [self.operationQueue scheduleOperation:^{ + [self trimToAgeLimitRecursively]; + } withPriority:PINOperationQueuePriorityLow]; + } }); } @@ -729,10 +891,15 @@ - (void)fileURLForKeyAsync:(NSString *)key completion:(PINDiskCacheFileURLBlock) } - (void)setObjectAsync:(id )object forKey:(NSString *)key completion:(PINDiskCacheObjectBlock)block +{ + [self setObjectAsync:object forKey:key withAgeLimit:0.0 completion:(PINDiskCacheObjectBlock)block]; +} + +- (void)setObjectAsync:(id )object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit completion:(nullable PINDiskCacheObjectBlock)block { [self.operationQueue scheduleOperation:^{ NSURL *fileURL = nil; - [self setObject:object forKey:key fileURL:&fileURL]; + [self setObject:object forKey:key withAgeLimit:ageLimit fileURL:&fileURL]; if (block) { block(self, key, object); @@ -745,6 +912,11 @@ - (void)setObjectAsync:(id )object forKey:(NSString *)key withCost:(NS [self setObjectAsync:object forKey:key completion:(PINDiskCacheObjectBlock)block]; } +- (void)setObjectAsync:(id )object forKey:(NSString *)key withCost:(NSUInteger)cost ageLimit:(NSTimeInterval)ageLimit completion:(nullable PINCacheObjectBlock)block +{ + [self setObjectAsync:object forKey:key withAgeLimit:ageLimit completion:(PINDiskCacheObjectBlock)block]; +} + - (void)removeObjectForKeyAsync:(NSString *)key completion:(PINDiskCacheObjectBlock)block { [self.operationQueue scheduleOperation:^{ @@ -820,6 +992,17 @@ - (void)trimToSizeByDateAsync:(NSUInteger)trimByteCount completion:(PINCacheBloc completion:completion]; } +- (void)removeExpiredObjectsAsync:(PINCacheBlock)block +{ + [self.operationQueue scheduleOperation:^{ + [self removeExpiredObjects]; + + if (block) { + block(self); + } + } withPriority:PINOperationQueuePriorityLow]; +} + - (void)removeAllObjectsAsync:(PINCacheBlock)block { [self.operationQueue scheduleOperation:^{ @@ -844,7 +1027,7 @@ - (void)enumerateObjectsWithBlockAsync:(PINDiskCacheFileURLEnumerationBlock)bloc #pragma mark - Public Synchronous Methods - -- (void)synchronouslyLockFileAccessWhileExecutingBlock:(PINCacheBlock)block +- (void)synchronouslyLockFileAccessWhileExecutingBlock:(PIN_NOESCAPE PINCacheBlock)block { if (block) { [self lockForWriting]; @@ -857,8 +1040,13 @@ - (BOOL)containsObjectForKey:(NSString *)key { [self lock]; if (_metadata[key] != nil || _diskStateKnown == NO) { + BOOL objectExpired = NO; + if (self->_ttlCache && _metadata[key].createdDate != nil) { + NSTimeInterval ageLimit = _metadata[key].ageLimit > 0.0 ? _metadata[key].ageLimit : self->_ageLimit; + objectExpired = ageLimit > 0 && fabs([_metadata[key].createdDate timeIntervalSinceDate:[NSDate date]]) > ageLimit; + } [self unlock]; - return ([self fileURLForKey:key updateFileModificationDate:NO] != nil); + return (!objectExpired && [self fileURLForKey:key updateFileModificationDate:NO] != nil); } [self unlock]; return NO; @@ -886,15 +1074,19 @@ - (id)objectForKeyedSubscript:(NSString *)key id object = nil; NSURL *fileURL = [self encodedFileURLForKey:key]; - NSDate *now = [[NSDate alloc] init]; + NSDate *now = [NSDate date]; [self lock]; if (self->_ttlCache) { - // We actually need to know the entire disk state if we're a TTL cache. - [self unlock]; - [self lockAndWaitForKnownState]; + if (!_diskStateKnown) { + if (_metadata[key] == nil) { + NSString *fileKey = [self keyForEncodedFileURL:fileURL]; + [self _locked_initializeDiskPropertiesForFile:fileURL fileKey:fileKey]; + } + } } - - if (!self->_ttlCache || self->_ageLimit <= 0 || fabs([_metadata[key].date timeIntervalSinceDate:now]) < self->_ageLimit) { + + NSTimeInterval ageLimit = _metadata[key].ageLimit > 0.0 ? _metadata[key].ageLimit : self->_ageLimit; + if (!self->_ttlCache || ageLimit <= 0 || fabs([_metadata[key].createdDate timeIntervalSinceDate:now]) < ageLimit) { // If the cache should behave like a TTL cache, then only fetch the object if there's a valid ageLimit and the object is still alive NSData *objectData = [[NSData alloc] initWithContentsOfFile:[fileURL path]]; @@ -915,7 +1107,8 @@ - (id)objectForKeyedSubscript:(NSString *)key } [self lock]; } - if (object && !self->_ttlCache) { + if (object) { + _metadata[key].lastModifiedDate = now; [self asynchronouslySetFileModificationDate:now forURL:fileURL]; } } @@ -941,12 +1134,13 @@ - (NSURL *)fileURLForKey:(NSString *)key updateFileModificationDate:(BOOL)update return nil; } - NSDate *now = [[NSDate alloc] init]; + NSDate *now = [NSDate date]; NSURL *fileURL = [self encodedFileURLForKey:key]; [self lockForWriting]; if (fileURL.path && [[NSFileManager defaultManager] fileExistsAtPath:fileURL.path]) { if (updateFileModificationDate) { + _metadata[key].lastModifiedDate = now; [self asynchronouslySetFileModificationDate:now forURL:fileURL]; } } else { @@ -958,7 +1152,17 @@ - (NSURL *)fileURLForKey:(NSString *)key updateFileModificationDate:(BOOL)update - (void)setObject:(id )object forKey:(NSString *)key { - [self setObject:object forKey:key fileURL:nil]; + [self setObject:object forKey:key withAgeLimit:0.0]; +} + +- (void)setObject:(id )object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit +{ + [self setObject:object forKey:key withAgeLimit:ageLimit fileURL:nil]; +} + +- (void)setObject:(id )object forKey:(NSString *)key withCost:(NSUInteger)cost ageLimit:(NSTimeInterval)ageLimit +{ + [self setObject:object forKey:key withAgeLimit:ageLimit]; } - (void)setObject:(id )object forKey:(NSString *)key withCost:(NSUInteger)cost @@ -975,15 +1179,18 @@ - (void)setObject:(id)object forKeyedSubscript:(NSString *)key } } -- (void)setObject:(id )object forKey:(NSString *)key fileURL:(NSURL **)outFileURL +- (void)setObject:(id )object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit fileURL:(NSURL **)outFileURL { + NSAssert(ageLimit <= 0.0 || (ageLimit > 0.0 && _ttlCache), @"ttlCache must be set to YES if setting an object-level age limit."); + if (!key || !object) return; + NSDataWritingOptions writeOptions = NSDataWritingAtomic; #if TARGET_OS_IPHONE - NSDataWritingOptions writeOptions = NSDataWritingAtomic | self.writingProtectionOption; - #else - NSDataWritingOptions writeOptions = NSDataWritingAtomic; + if (self.writingProtectionOptionSet) { + writeOptions |= self.writingProtectionOption; + } #endif // Remain unlocked here so that we're not locked while serializing. @@ -1004,7 +1211,7 @@ - (void)setObject:(id )object forKey:(NSString *)key fileURL:(NSURL ** } [self lockForWriting]; - PINCacheObjectBlock willAddObjectBlock = self->_willAddObjectBlock; + PINDiskCacheObjectBlock willAddObjectBlock = self->_willAddObjectBlock; if (willAddObjectBlock) { [self unlock]; willAddObjectBlock(self, key, object); @@ -1021,7 +1228,7 @@ - (void)setObject:(id )object forKey:(NSString *)key fileURL:(NSURL ** } NSError *error = nil; - NSDictionary *values = [fileURL resourceValuesForKeys:@[ NSURLContentModificationDateKey, NSURLTotalFileAllocatedSizeKey ] error:&error]; + NSDictionary *values = [fileURL resourceValuesForKeys:@[ NSURLCreationDateKey, NSURLContentModificationDateKey, NSURLTotalFileAllocatedSizeKey ] error:&error]; PINDiskCacheError(error); NSNumber *diskFileSize = [values objectForKey:NSURLTotalFileAllocatedSizeKey]; @@ -1033,18 +1240,22 @@ - (void)setObject:(id )object forKey:(NSString *)key fileURL:(NSURL ** self->_metadata[key].size = diskFileSize; self.byteCount = self->_byteCount + [diskFileSize unsignedIntegerValue]; // atomic } - NSDate *date = [values objectForKey:NSURLContentModificationDateKey]; - if (date) { - self->_metadata[key].date = date; + NSDate *createdDate = [values objectForKey:NSURLCreationDateKey]; + if (createdDate) { + self->_metadata[key].createdDate = createdDate; } - + NSDate *lastModifiedDate = [values objectForKey:NSURLContentModificationDateKey]; + if (lastModifiedDate) { + self->_metadata[key].lastModifiedDate = lastModifiedDate; + } + [self asynchronouslySetAgeLimit:ageLimit forURL:fileURL]; if (self->_byteLimit > 0 && self->_byteCount > self->_byteLimit) [self trimToSizeByDateAsync:self->_byteLimit completion:nil]; } else { fileURL = nil; } - PINCacheObjectBlock didAddObjectBlock = self->_didAddObjectBlock; + PINDiskCacheObjectBlock didAddObjectBlock = self->_didAddObjectBlock; if (didAddObjectBlock) { [self unlock]; didAddObjectBlock(self, key, object); @@ -1111,6 +1322,26 @@ - (void)trimToSizeByDate:(NSUInteger)trimByteCount [self trimDiskToSizeByDate:trimByteCount]; } +- (void)removeExpiredObjects +{ + [self lockForWriting]; + NSDate *now = [NSDate date]; + NSMutableArray *expiredObjectKeys = [NSMutableArray array]; + [_metadata enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, PINDiskCacheMetadata * _Nonnull obj, BOOL * _Nonnull stop) { + NSTimeInterval ageLimit = obj.ageLimit > 0.0 ? obj.ageLimit : self->_ageLimit; + NSDate *expirationDate = [obj.createdDate dateByAddingTimeInterval:ageLimit]; + if ([expirationDate compare:now] == NSOrderedAscending) { // Expiration date has passed + [expiredObjectKeys addObject:key]; + } + }]; + [self unlock]; + + for (NSString *key in expiredObjectKeys) { + //unlock, removeFileAndExecuteBlocksForKey handles locking itself + [self removeFileAndExecuteBlocksForKey:key]; + } +} + - (void)removeAllObjects { // We don't need to know the disk state since we're just going to remove everything. @@ -1140,7 +1371,7 @@ - (void)removeAllObjects [self unlock]; } -- (void)enumerateObjectsWithBlock:(PINDiskCacheFileURLEnumerationBlock)block +- (void)enumerateObjectsWithBlock:(PIN_NOESCAPE PINDiskCacheFileURLEnumerationBlock)block { if (!block) return; @@ -1151,8 +1382,9 @@ - (void)enumerateObjectsWithBlock:(PINDiskCacheFileURLEnumerationBlock)block for (NSString *key in _metadata) { NSURL *fileURL = [self encodedFileURLForKey:key]; // If the cache should behave like a TTL cache, then only fetch the object if there's a valid ageLimit and the object is still alive - NSDate *date = _metadata[key].date; - if (!self->_ttlCache || self->_ageLimit <= 0 || (date && fabs([date timeIntervalSinceDate:now]) < self->_ageLimit)) { + NSDate *createdDate = _metadata[key].createdDate; + NSTimeInterval ageLimit = _metadata[key].ageLimit > 0.0 ? _metadata[key].ageLimit : self->_ageLimit; + if (!self->_ttlCache || ageLimit <= 0 || (createdDate && fabs([createdDate timeIntervalSinceDate:now]) < ageLimit)) { BOOL stop = NO; block(key, fileURL, &stop); if (stop) @@ -1325,11 +1557,14 @@ - (void)setAgeLimit:(NSTimeInterval)ageLimit self->_ageLimit = ageLimit; [self unlock]; - [self trimToAgeLimitRecursively]; + [self.operationQueue scheduleOperation:^{ + [self trimToAgeLimitRecursively]; + } withPriority:PINOperationQueuePriorityLow]; } withPriority:PINOperationQueuePriorityHigh]; } -- (BOOL)isTTLCache { +- (BOOL)isTTLCache +{ BOOL isTTLCache; [self lock]; @@ -1339,16 +1574,9 @@ - (BOOL)isTTLCache { return isTTLCache; } -- (void)setTtlCache:(BOOL)ttlCache { - [self.operationQueue scheduleOperation:^{ - [self lock]; - self->_ttlCache = ttlCache; - [self unlock]; - } withPriority:PINOperationQueuePriorityHigh]; -} - #if TARGET_OS_IPHONE -- (NSDataWritingOptions)writingProtectionOption { +- (NSDataWritingOptions)writingProtectionOption +{ NSDataWritingOptions option; [self lock]; @@ -1358,13 +1586,15 @@ - (NSDataWritingOptions)writingProtectionOption { return option; } -- (void)setWritingProtectionOption:(NSDataWritingOptions)writingProtectionOption { +- (void)setWritingProtectionOption:(NSDataWritingOptions)writingProtectionOption +{ [self.operationQueue scheduleOperation:^{ - NSDataWritingOptions option = NSDataWritingFileProtectionMask & writingProtectionOption; + NSDataWritingOptions option = NSDataWritingFileProtectionMask & writingProtectionOption; - [self lock]; - self->_writingProtectionOption = option; - [self unlock]; + [self lock]; + self->_writingProtectionOptionSet = YES; + self->_writingProtectionOption = option; + [self unlock]; } withPriority:PINOperationQueuePriorityHigh]; } #endif @@ -1373,7 +1603,7 @@ - (void)lockForWriting { [self lock]; - // spinlock if the disk isn't writable + // Lock if the disk isn't writable. if (_diskWritable == NO) { pthread_cond_wait(&_diskWritableCondition, &_mutex); } @@ -1383,26 +1613,16 @@ - (void)lockAndWaitForKnownState { [self lock]; - // spinlock if the disk state isn't known + // Lock if the disk state isn't known. if (_diskStateKnown == NO) { pthread_cond_wait(&_diskStateKnownCondition, &_mutex); } } -- (void)lockForStartup -{ - __unused int result = pthread_mutex_lock(&_mutex); - NSAssert(result == 0, @"Failed to lock PINDiskCache %@. Code: %d", self, result); -} - - (void)lock { __unused int result = pthread_mutex_lock(&_mutex); NSAssert(result == 0, @"Failed to lock PINDiskCache %@. Code: %d", self, result); - - if (_disableAsyncronousStartup && _diskStateKnown == NO) { - pthread_cond_wait(&_diskStateKnownCondition, &_mutex); - } } - (void)unlock @@ -1447,29 +1667,58 @@ - (void)removeObjectForKey:(NSString *)key block:(nullable PINDiskCacheObjectBlo - (void)trimToDate:(NSDate *)date block:(nullable PINDiskCacheBlock)block { - [self trimToDateAsync:date completion:block]; + [self trimToDateAsync:date completion:^(id diskCache) { + if (block) { + block((PINDiskCache *)diskCache); + } + }]; } - (void)trimToSize:(NSUInteger)byteCount block:(nullable PINDiskCacheBlock)block { - [self trimToSizeAsync:byteCount completion:block]; + [self trimToSizeAsync:byteCount completion:^(id diskCache) { + if (block) { + block((PINDiskCache *)diskCache); + } + }]; } - (void)trimToSizeByDate:(NSUInteger)byteCount block:(nullable PINDiskCacheBlock)block { - [self trimToSizeAsync:byteCount completion:block]; + [self trimToSizeAsync:byteCount completion:^(id diskCache) { + if (block) { + block((PINDiskCache *)diskCache); + } + }]; } - (void)removeAllObjects:(nullable PINDiskCacheBlock)block { - [self removeAllObjectsAsync:block]; + [self removeAllObjectsAsync:^(id diskCache) { + if (block) { + block((PINDiskCache *)diskCache); + } + }]; } - (void)enumerateObjectsWithBlock:(PINDiskCacheFileURLBlock)block completionBlock:(nullable PINDiskCacheBlock)completionBlock { [self enumerateObjectsWithBlockAsync:^(NSString * _Nonnull key, NSURL * _Nullable fileURL, BOOL * _Nonnull stop) { block(key, fileURL); - } completionBlock:completionBlock]; + } completionBlock:^(id diskCache) { + if (completionBlock) { + completionBlock((PINDiskCache *)diskCache); + } + }]; +} + +- (void)setTtlCache:(BOOL)ttlCache +{ + [self.operationQueue scheduleOperation:^{ + [self lock]; + self->_ttlCache = ttlCache; + [self unlock]; + } withPriority:PINOperationQueuePriorityHigh]; } @end diff --git a/sample/UrlGet/Vendor/PINCache/Source/PINMemoryCache.h b/sample/UrlGet/Vendor/PINCache/Source/PINMemoryCache.h index 5eee26a9..1cf9ff88 100644 --- a/sample/UrlGet/Vendor/PINCache/Source/PINMemoryCache.h +++ b/sample/UrlGet/Vendor/PINCache/Source/PINMemoryCache.h @@ -4,9 +4,9 @@ #import -#import -#import -#import +#import "PINCacheMacros.h" +#import "PINCaching.h" +#import "PINCacheObjectSubscripting.h" NS_ASSUME_NONNULL_BEGIN @@ -61,8 +61,11 @@ PIN_SUBCLASSING_RESTRICTED - When attempting to access an object in the cache that has lived longer than self.ageLimit, the cache will behave as if the object does not exist + @note If an object-level age limit is set via one of the @c -setObject:forKey:withAgeLimit methods, + that age limit overrides self.ageLimit. The overridden object age limit could be greater or + less than self.agelimit but must be greater than zero. */ -@property (nonatomic, assign, getter=isTTLCache) BOOL ttlCache; +@property (nonatomic, readonly, getter=isTTLCache) BOOL ttlCache; /** When `YES` on iOS the cache will remove all objects when the app receives a memory warning. @@ -145,7 +148,9 @@ PIN_SUBCLASSING_RESTRICTED - (instancetype)initWithOperationQueue:(PINOperationQueue *)operationQueue; -- (instancetype)initWithName:(NSString *)name operationQueue:(PINOperationQueue *)operationQueue NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithName:(NSString *)name operationQueue:(PINOperationQueue *)operationQueue; + +- (instancetype)initWithName:(NSString *)name operationQueue:(PINOperationQueue *)operationQueue ttlCache:(BOOL)ttlCache NS_DESIGNATED_INITIALIZER; #pragma mark - Asynchronous Methods /// @name Asynchronous Methods @@ -234,6 +239,7 @@ typedef void (^PINMemoryCacheContainmentBlock)(BOOL containsObject); - (void)trimToCostByDate:(NSUInteger)cost block:(nullable PINMemoryCacheBlock)block __attribute__((deprecated)); - (void)removeAllObjects:(nullable PINMemoryCacheBlock)block __attribute__((deprecated)); - (void)enumerateObjectsWithBlock:(PINMemoryCacheObjectBlock)block completionBlock:(nullable PINMemoryCacheBlock)completionBlock __attribute__((deprecated)); +- (void)setTtlCache:(BOOL)ttlCache DEPRECATED_MSG_ATTRIBUTE("ttlCache is no longer a settable property and must now be set via initializer."); @end NS_ASSUME_NONNULL_END diff --git a/sample/UrlGet/Vendor/PINCache/Source/PINMemoryCache.m b/sample/UrlGet/Vendor/PINCache/Source/PINMemoryCache.m index 21e4a602..85c45f5f 100644 --- a/sample/UrlGet/Vendor/PINCache/Source/PINMemoryCache.m +++ b/sample/UrlGet/Vendor/PINCache/Source/PINMemoryCache.m @@ -5,7 +5,12 @@ #import "PINMemoryCache.h" #import + +#if SWIFT_PACKAGE +@import PINOperation; +#else #import +#endif #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0 #import @@ -19,8 +24,10 @@ @interface PINMemoryCache () @property (strong, nonatomic) PINOperationQueue *operationQueue; @property (assign, nonatomic) pthread_mutex_t mutex; @property (strong, nonatomic) NSMutableDictionary *dictionary; -@property (strong, nonatomic) NSMutableDictionary *dates; +@property (strong, nonatomic) NSMutableDictionary *createdDates; +@property (strong, nonatomic) NSMutableDictionary *accessDates; @property (strong, nonatomic) NSMutableDictionary *costs; +@property (strong, nonatomic) NSMutableDictionary *ageLimits; @end @implementation PINMemoryCache @@ -60,6 +67,11 @@ - (instancetype)initWithOperationQueue:(PINOperationQueue *)operationQueue } - (instancetype)initWithName:(NSString *)name operationQueue:(PINOperationQueue *)operationQueue +{ + return [self initWithName:name operationQueue:operationQueue ttlCache:NO]; +} + +- (instancetype)initWithName:(NSString *)name operationQueue:(PINOperationQueue *)operationQueue ttlCache:(BOOL)ttlCache { if (self = [super init]) { __unused int result = pthread_mutex_init(&_mutex, NULL); @@ -67,10 +79,13 @@ - (instancetype)initWithName:(NSString *)name operationQueue:(PINOperationQueue _name = [name copy]; _operationQueue = operationQueue; + _ttlCache = ttlCache; _dictionary = [[NSMutableDictionary alloc] init]; - _dates = [[NSMutableDictionary alloc] init]; + _createdDates = [[NSMutableDictionary alloc] init]; + _accessDates = [[NSMutableDictionary alloc] init]; _costs = [[NSMutableDictionary alloc] init]; + _ageLimits = [[NSMutableDictionary alloc] init]; _willAddObjectBlock = nil; _willRemoveObjectBlock = nil; @@ -120,8 +135,11 @@ + (PINMemoryCache *)sharedCache #pragma mark - Private Methods - - (void)didReceiveMemoryWarningNotification:(NSNotification *)notification { - if (self.removeAllObjectsOnMemoryWarning) + if (self.removeAllObjectsOnMemoryWarning) { [self removeAllObjectsAsync:nil]; + } else { + [self removeExpiredObjects]; + } [self.operationQueue scheduleOperation:^{ [self lock]; @@ -165,8 +183,10 @@ - (void)removeObjectAndExecuteBlocksForKey:(NSString *)key _totalCost -= [cost unsignedIntegerValue]; [_dictionary removeObjectForKey:key]; - [_dates removeObjectForKey:key]; + [_createdDates removeObjectForKey:key]; + [_accessDates removeObjectForKey:key]; [_costs removeObjectForKey:key]; + [_ageLimits removeObjectForKey:key]; [self unlock]; if (didRemoveObjectBlock) @@ -176,19 +196,39 @@ - (void)removeObjectAndExecuteBlocksForKey:(NSString *)key - (void)trimMemoryToDate:(NSDate *)trimDate { [self lock]; - NSArray *keysSortedByDate = [_dates keysSortedByValueUsingSelector:@selector(compare:)]; - NSDictionary *dates = [_dates copy]; + NSDictionary *createdDates = [_createdDates copy]; + NSDictionary *ageLimits = [_ageLimits copy]; [self unlock]; - for (NSString *key in keysSortedByDate) { // oldest objects first - NSDate *accessDate = dates[key]; - if (!accessDate) + [createdDates enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSDate * _Nonnull createdDate, BOOL * _Nonnull stop) { + NSTimeInterval ageLimit = [ageLimits[key] doubleValue]; + if (!createdDate || ageLimit > 0.0) { + return; + } + if ([createdDate compare:trimDate] == NSOrderedAscending) { // older than trim date + [self removeObjectAndExecuteBlocksForKey:key]; + } + }]; +} + +- (void)removeExpiredObjects +{ + [self lock]; + NSDictionary *createdDates = [_createdDates copy]; + NSDictionary *ageLimits = [_ageLimits copy]; + NSTimeInterval globalAgeLimit = self->_ageLimit; + [self unlock]; + + NSDate *now = [NSDate date]; + for (NSString *key in ageLimits) { + NSDate *createdDate = createdDates[key]; + NSTimeInterval ageLimit = [ageLimits[key] doubleValue] ?: globalAgeLimit; + if (!createdDate) continue; - - if ([accessDate compare:trimDate] == NSOrderedAscending) { // older than trim date + + NSDate *expirationDate = [createdDate dateByAddingTimeInterval:ageLimit]; + if ([expirationDate compare:now] == NSOrderedAscending) { // Expiration date has passed [self removeObjectAndExecuteBlocksForKey:key]; - } else { - break; } } } @@ -220,17 +260,21 @@ - (void)trimToCostLimit:(NSUInteger)limit - (void)trimToCostLimitByDate:(NSUInteger)limit { + if (self.isTTLCache) { + [self removeExpiredObjects]; + } + NSUInteger totalCost = 0; [self lock]; totalCost = _totalCost; - NSArray *keysSortedByDate = [_dates keysSortedByValueUsingSelector:@selector(compare:)]; + NSArray *keysSortedByAccessDate = [_accessDates keysSortedByValueUsingSelector:@selector(compare:)]; [self unlock]; if (totalCost <= limit) return; - for (NSString *key in keysSortedByDate) { // oldest objects first + for (NSString *key in keysSortedByAccessDate) { // oldest objects first [self removeObjectAndExecuteBlocksForKey:key]; [self lock]; @@ -256,9 +300,20 @@ - (void)trimToAgeLimitRecursively dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(ageLimit * NSEC_PER_SEC)); dispatch_after(time, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ - [self.operationQueue scheduleOperation:^{ - [self trimToAgeLimitRecursively]; - } withPriority:PINOperationQueuePriorityHigh]; + // Ensure that ageLimit is the same as when we were scheduled, otherwise, we've been + // rescheduled (another dispatch_after was issued) and should cancel. + BOOL shouldReschedule = YES; + [self lock]; + if (ageLimit != self->_ageLimit) { + shouldReschedule = NO; + } + [self unlock]; + + if (shouldReschedule) { + [self.operationQueue scheduleOperation:^{ + [self trimToAgeLimitRecursively]; + } withPriority:PINOperationQueuePriorityLow]; + } }); } @@ -294,10 +349,20 @@ - (void)setObjectAsync:(id)object forKey:(NSString *)key completion:(PINCacheObj [self setObjectAsync:object forKey:key withCost:0 completion:block]; } +- (void)setObjectAsync:(id)object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit completion:(PINCacheObjectBlock)block +{ + [self setObjectAsync:object forKey:key withCost:0 ageLimit:ageLimit completion:block]; +} + - (void)setObjectAsync:(id)object forKey:(NSString *)key withCost:(NSUInteger)cost completion:(PINCacheObjectBlock)block +{ + [self setObjectAsync:object forKey:key withCost:cost ageLimit:0.0 completion:block]; +} + +- (void)setObjectAsync:(id)object forKey:(NSString *)key withCost:(NSUInteger)cost ageLimit:(NSTimeInterval)ageLimit completion:(PINCacheObjectBlock)block { [self.operationQueue scheduleOperation:^{ - [self setObject:object forKey:key withCost:cost]; + [self setObject:object forKey:key withCost:cost ageLimit:ageLimit]; if (block) block(self, key, object); @@ -311,7 +376,7 @@ - (void)removeObjectForKeyAsync:(NSString *)key completion:(PINCacheObjectBlock) if (block) block(self, key, nil); - } withPriority:PINOperationQueuePriorityHigh]; + } withPriority:PINOperationQueuePriorityLow]; } - (void)trimToDateAsync:(NSDate *)trimDate completion:(PINCacheBlock)block @@ -321,7 +386,7 @@ - (void)trimToDateAsync:(NSDate *)trimDate completion:(PINCacheBlock)block if (block) block(self); - } withPriority:PINOperationQueuePriorityHigh]; + } withPriority:PINOperationQueuePriorityLow]; } - (void)trimToCostAsync:(NSUInteger)cost completion:(PINCacheBlock)block @@ -331,7 +396,7 @@ - (void)trimToCostAsync:(NSUInteger)cost completion:(PINCacheBlock)block if (block) block(self); - } withPriority:PINOperationQueuePriorityHigh]; + } withPriority:PINOperationQueuePriorityLow]; } - (void)trimToCostByDateAsync:(NSUInteger)cost completion:(PINCacheBlock)block @@ -341,7 +406,17 @@ - (void)trimToCostByDateAsync:(NSUInteger)cost completion:(PINCacheBlock)block if (block) block(self); - } withPriority:PINOperationQueuePriorityHigh]; + } withPriority:PINOperationQueuePriorityLow]; +} + +- (void)removeExpiredObjectsAsync:(PINCacheBlock)block +{ + [self.operationQueue scheduleOperation:^{ + [self removeExpiredObjects]; + + if (block) + block(self); + } withPriority:PINOperationQueuePriorityLow]; } - (void)removeAllObjectsAsync:(PINCacheBlock)block @@ -351,7 +426,7 @@ - (void)removeAllObjectsAsync:(PINCacheBlock)block if (block) block(self); - } withPriority:PINOperationQueuePriorityHigh]; + } withPriority:PINOperationQueuePriorityLow]; } - (void)enumerateObjectsWithBlockAsync:(PINCacheObjectEnumerationBlock)block completionBlock:(PINCacheBlock)completionBlock @@ -361,7 +436,7 @@ - (void)enumerateObjectsWithBlockAsync:(PINCacheObjectEnumerationBlock)block com if (completionBlock) completionBlock(self); - } withPriority:PINOperationQueuePriorityHigh]; + } withPriority:PINOperationQueuePriorityLow]; } #pragma mark - Public Synchronous Methods - @@ -382,18 +457,19 @@ - (nullable id)objectForKey:(NSString *)key if (!key) return nil; - NSDate *now = [[NSDate alloc] init]; + NSDate *now = [NSDate date]; [self lock]; id object = nil; // If the cache should behave like a TTL cache, then only fetch the object if there's a valid ageLimit and the object is still alive - if (!self->_ttlCache || self->_ageLimit <= 0 || fabs([[_dates objectForKey:key] timeIntervalSinceDate:now]) < self->_ageLimit) { + NSTimeInterval ageLimit = [_ageLimits[key] doubleValue] ?: self->_ageLimit; + if (!self->_ttlCache || ageLimit <= 0 || fabs([[_createdDates objectForKey:key] timeIntervalSinceDate:now]) < ageLimit) { object = _dictionary[key]; } [self unlock]; if (object) { [self lock]; - _dates[key] = now; + _accessDates[key] = now; [self unlock]; } @@ -410,6 +486,11 @@ - (void)setObject:(id)object forKey:(NSString *)key [self setObject:object forKey:key withCost:0]; } +- (void)setObject:(id)object forKey:(NSString *)key withAgeLimit:(NSTimeInterval)ageLimit +{ + [self setObject:object forKey:key withCost:0 ageLimit:ageLimit]; +} + - (void)setObject:(id)object forKeyedSubscript:(NSString *)key { if (object == nil) { @@ -421,6 +502,13 @@ - (void)setObject:(id)object forKeyedSubscript:(NSString *)key - (void)setObject:(id)object forKey:(NSString *)key withCost:(NSUInteger)cost { + [self setObject:object forKey:key withCost:cost ageLimit:0.0]; +} + +- (void)setObject:(id)object forKey:(NSString *)key withCost:(NSUInteger)cost ageLimit:(NSTimeInterval)ageLimit +{ + NSAssert(ageLimit <= 0.0 || (ageLimit > 0.0 && _ttlCache), @"ttlCache must be set to YES if setting an object-level age limit."); + if (!key || !object) return; @@ -438,10 +526,18 @@ - (void)setObject:(id)object forKey:(NSString *)key withCost:(NSUInteger)cost if (oldCost) _totalCost -= [oldCost unsignedIntegerValue]; + NSDate *now = [NSDate date]; _dictionary[key] = object; - _dates[key] = [[NSDate alloc] init]; + _createdDates[key] = now; + _accessDates[key] = now; _costs[key] = @(cost); - + + if (ageLimit > 0.0) { + _ageLimits[key] = @(ageLimit); + } else { + [_ageLimits removeObjectForKey:key]; + } + _totalCost += cost; [self unlock]; @@ -495,8 +591,10 @@ - (void)removeAllObjects [self lock]; [_dictionary removeAllObjects]; - [_dates removeAllObjects]; + [_createdDates removeAllObjects]; + [_accessDates removeAllObjects]; [_costs removeAllObjects]; + [_ageLimits removeAllObjects]; _totalCost = 0; [self unlock]; @@ -506,18 +604,19 @@ - (void)removeAllObjects } -- (void)enumerateObjectsWithBlock:(PINCacheObjectEnumerationBlock)block +- (void)enumerateObjectsWithBlock:(PIN_NOESCAPE PINCacheObjectEnumerationBlock)block { if (!block) return; [self lock]; - NSDate *now = [[NSDate alloc] init]; - NSArray *keysSortedByDate = [_dates keysSortedByValueUsingSelector:@selector(compare:)]; + NSDate *now = [NSDate date]; + NSArray *keysSortedByCreatedDate = [_createdDates keysSortedByValueUsingSelector:@selector(compare:)]; - for (NSString *key in keysSortedByDate) { + for (NSString *key in keysSortedByCreatedDate) { // If the cache should behave like a TTL cache, then only fetch the object if there's a valid ageLimit and the object is still alive - if (!self->_ttlCache || self->_ageLimit <= 0 || fabs([[_dates objectForKey:key] timeIntervalSinceDate:now]) < self->_ageLimit) { + NSTimeInterval ageLimit = [_ageLimits[key] doubleValue] ?: self->_ageLimit; + if (!self->_ttlCache || ageLimit <= 0 || fabs([[_createdDates objectForKey:key] timeIntervalSinceDate:now]) < ageLimit) { BOOL stop = NO; block(self, key, _dictionary[key], &stop); if (stop) @@ -713,13 +812,6 @@ - (BOOL)isTTLCache { return isTTLCache; } -- (void)setTtlCache:(BOOL)ttlCache { - [self lock]; - _ttlCache = ttlCache; - [self unlock]; -} - - - (void)lock { __unused int result = pthread_mutex_lock(&_mutex); @@ -746,42 +838,74 @@ - (void)containsObjectForKey:(NSString *)key block:(PINMemoryCacheContainmentBlo - (void)objectForKey:(NSString *)key block:(nullable PINMemoryCacheObjectBlock)block { - [self objectForKeyAsync:key completion:block]; + [self objectForKeyAsync:key completion:^(id memoryCache, NSString *memoryCacheKey, id memoryCacheObject) { + if (block) { + block((PINMemoryCache *)memoryCache, memoryCacheKey, memoryCacheObject); + } + }]; } - (void)setObject:(id)object forKey:(NSString *)key block:(nullable PINMemoryCacheObjectBlock)block { - [self setObjectAsync:object forKey:key completion:block]; + [self setObjectAsync:object forKey:key completion:^(id memoryCache, NSString *memoryCacheKey, id memoryCacheObject) { + if (block) { + block((PINMemoryCache *)memoryCache, memoryCacheKey, memoryCacheObject); + } + }]; } - (void)setObject:(id)object forKey:(NSString *)key withCost:(NSUInteger)cost block:(nullable PINMemoryCacheObjectBlock)block { - [self setObjectAsync:object forKey:key withCost:cost completion:block]; + [self setObjectAsync:object forKey:key withCost:cost completion:^(id memoryCache, NSString *memoryCacheKey, id memoryCacheObject) { + if (block) { + block((PINMemoryCache *)memoryCache, memoryCacheKey, memoryCacheObject); + } + }]; } - (void)removeObjectForKey:(NSString *)key block:(nullable PINMemoryCacheObjectBlock)block { - [self removeObjectForKeyAsync:key completion:block]; + [self removeObjectForKeyAsync:key completion:^(id memoryCache, NSString *memoryCacheKey, id memoryCacheObject) { + if (block) { + block((PINMemoryCache *)memoryCache, memoryCacheKey, memoryCacheObject); + } + }]; } - (void)trimToDate:(NSDate *)date block:(nullable PINMemoryCacheBlock)block { - [self trimToDateAsync:date completion:block]; + [self trimToDateAsync:date completion:^(id memoryCache) { + if (block) { + block((PINMemoryCache *)memoryCache); + } + }]; } - (void)trimToCost:(NSUInteger)cost block:(nullable PINMemoryCacheBlock)block { - [self trimToCostAsync:cost completion:block]; + [self trimToCostAsync:cost completion:^(id memoryCache) { + if (block) { + block((PINMemoryCache *)memoryCache); + } + }]; } - (void)trimToCostByDate:(NSUInteger)cost block:(nullable PINMemoryCacheBlock)block { - [self trimToCostByDateAsync:cost completion:block]; + [self trimToCostByDateAsync:cost completion:^(id memoryCache) { + if (block) { + block((PINMemoryCache *)memoryCache); + } + }]; } - (void)removeAllObjects:(nullable PINMemoryCacheBlock)block { - [self removeAllObjectsAsync:block]; + [self removeAllObjectsAsync:^(id memoryCache) { + if (block) { + block((PINMemoryCache *)memoryCache); + } + }]; } - (void)enumerateObjectsWithBlock:(PINMemoryCacheObjectBlock)block completionBlock:(nullable PINMemoryCacheBlock)completionBlock @@ -791,7 +915,18 @@ - (void)enumerateObjectsWithBlock:(PINMemoryCacheObjectBlock)block completionBlo PINMemoryCache *memoryCache = (PINMemoryCache *)cache; block(memoryCache, key, object); } - } completionBlock:completionBlock]; + } completionBlock:^(id memoryCache) { + if (completionBlock) { + completionBlock((PINMemoryCache *)memoryCache); + } + }]; +} + +- (void)setTtlCache:(BOOL)ttlCache +{ + [self lock]; + _ttlCache = ttlCache; + [self unlock]; } @end diff --git a/sample/UrlGet/Vendor/PINCache/Tests/NSDate+PINCacheTests.h b/sample/UrlGet/Vendor/PINCache/Tests/NSDate+PINCacheTests.h new file mode 100644 index 00000000..e11033d0 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Tests/NSDate+PINCacheTests.h @@ -0,0 +1,15 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSDate (PINCacheTests) + +/** Swizzles +[NSDate date] to always return the specified date. */ ++ (void)startMockingDateWithDate:(NSDate *)date; + +/** Stops swizzling +[NSDate date] and returns to original implementation */ ++ (void)stopMockingDate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sample/UrlGet/Vendor/PINCache/Tests/NSDate+PINCacheTests.m b/sample/UrlGet/Vendor/PINCache/Tests/NSDate+PINCacheTests.m new file mode 100644 index 00000000..1133c2b0 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Tests/NSDate+PINCacheTests.m @@ -0,0 +1,50 @@ +#import "NSDate+PINCacheTests.h" + +#import + +static NSDate *PINCacheTestsSwizzedDate = nil; + +@implementation NSDate (PINCacheTests) + ++ (void)startMockingDateWithDate:(NSDate *)date +{ + // If already swizzled, just replace the static date. + BOOL alreadySwizzled = (PINCacheTestsSwizzedDate != nil); + PINCacheTestsSwizzedDate = date; + if (alreadySwizzled) { return; } + + SEL originalSelector = @selector(date); + SEL swizzledSelector = @selector(swizzled_date); + + Method originalMethod = class_getClassMethod(self, originalSelector); + Method swizzledMethod = class_getClassMethod(self, swizzledSelector); + + Class class = object_getClass((id)self); + + if (class_addMethod(class, + originalSelector, + method_getImplementation(swizzledMethod), + method_getTypeEncoding(swizzledMethod))) { + class_replaceMethod(class, + swizzledSelector, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)); + } else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } +} + ++ (void)stopMockingDate +{ + Method originalMethod = class_getClassMethod(self, @selector(date)); + Method swizzledMethod = class_getClassMethod(self, @selector(swizzled_date)); + method_exchangeImplementations(swizzledMethod, originalMethod); + PINCacheTestsSwizzedDate = nil; +} + ++ (instancetype)swizzled_date +{ + return PINCacheTestsSwizzedDate; +} + +@end diff --git a/sample/UrlGet/Vendor/PINCache/Tests/PINCacheTests.m b/sample/UrlGet/Vendor/PINCache/Tests/PINCacheTests.m index d22ce2ed..0a79a3ed 100644 --- a/sample/UrlGet/Vendor/PINCache/Tests/PINCacheTests.m +++ b/sample/UrlGet/Vendor/PINCache/Tests/PINCacheTests.m @@ -2,9 +2,17 @@ // Modifications by Garrett Moon // Copyright (c) 2015 Pinterest. All rights reserved. -#import "PINCacheTests.h" +#if SWIFT_PACKAGE +@import PINCache; +@import PINOperation; +#else #import #import +#endif + +#import "PINCacheTests.h" +#import "NSDate+PINCacheTests.h" +#import "PINDiskCache+PINCacheTests.h" #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR @@ -19,8 +27,11 @@ @interface PINDiskCache() @property (assign, nonatomic) BOOL diskStateKnown; +@property (strong, nonatomic) NSDictionary *metadata; +@property (readonly) PINOperationQueue *operationQueue; + (dispatch_queue_t)sharedTrashQueue; ++ (NSURL *)sharedTrashURL; - (NSString *)encodedString:(NSString *)string; @end @@ -28,6 +39,7 @@ - (NSString *)encodedString:(NSString *)string; @interface PINMemoryCache () - (void)didReceiveEnterBackgroundNotification:(NSNotification *)notification; +- (void)setTtlCache:(BOOL)ttlCache; @end @@ -74,8 +86,14 @@ - (PINImage *)image static PINImage *image = nil; if (!image) { +#ifdef TEST_AS_SPM + NSBundle *bun = SWIFTPM_MODULE_BUNDLE; +#else + NSBundle *bun = [NSBundle bundleForClass:self.class]; + +#endif + NSURL *imageURL = [bun URLForResource:@"Default-568h@2x" withExtension:@"png"]; NSError *error = nil; - NSURL *imageURL = [[NSBundle bundleForClass:self.class] URLForResource:@"Default-568h@2x" withExtension:@"png"]; NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageURL options:NSDataReadingUncached error:&error]; @@ -110,14 +128,8 @@ - (void)testCoreProperties - (void)testDiskCacheURL { - // Wait for URL to be created - dispatch_group_t group = dispatch_group_create(); - dispatch_group_enter(group); - [self.cache objectForKeyAsync:@"" completion:^(PINCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { - dispatch_group_leave(group); - }]; - - dispatch_group_wait(group, DISPATCH_TIME_FOREVER); + // Wait for URL to be created. We use enumerateObjectsWithBlock because it waits for a known disk state. + [self.cache.diskCache enumerateObjectsWithBlock:^(NSString * _Nonnull key, NSURL * _Nullable fileURL, BOOL * _Nonnull stop) {}]; BOOL isDir = NO; BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:[self.cache.diskCache.cacheURL path] isDirectory:&isDir]; @@ -131,7 +143,7 @@ - (void)testObjectSet __block PINImage *image = nil; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); - [self.cache setObjectAsync:[self image] forKey:key completion:^(PINCache *cache, NSString *key, id object) { + [self.cache setObjectAsync:[self image] forKey:key completion:^(id cache, NSString *key, id object) { image = (PINImage *)object; dispatch_semaphore_signal(semaphore); }]; @@ -149,7 +161,7 @@ - (void)testObjectSetWithCost PINImage *srcImage = [self image]; NSUInteger cost = (NSUInteger)(srcImage.size.width * srcImage.size.height); - [self.cache setObjectAsync:srcImage forKey:key withCost:cost completion:^(PINCache *cache, NSString *key, id object) { + [self.cache setObjectAsync:srcImage forKey:key withCost:cost completion:^(id cache, NSString *key, id object) { image = (PINImage *)object; dispatch_semaphore_signal(semaphore); }]; @@ -171,7 +183,7 @@ - (void)testObjectSetWithDuplicateKey [self.cache setObject:value1 forKey:key]; [self.cache setObject:value2 forKey:key]; - [self.cache objectForKeyAsync:key completion:^(PINCache *cache, NSString *key, id object) { + [self.cache objectForKeyAsync:key completion:^(id cache, NSString *key, id object) { cachedValue = (NSString *)object; dispatch_semaphore_signal(semaphore); }]; @@ -234,7 +246,7 @@ - (void)testObjectGet self.cache[key] = [self image]; - [self.cache objectForKeyAsync:key completion:^(PINCache *cache, NSString *key, id object) { + [self.cache objectForKeyAsync:key completion:^(id cache, NSString *key, id object) { image = (PINImage *)object; dispatch_semaphore_signal(semaphore); }]; @@ -253,7 +265,7 @@ - (void)testObjectGetWithInvalidKey self.cache[key] = [self image]; - [self.cache objectForKeyAsync:invalidKey completion:^(PINCache *cache, NSString *key, id object) { + [self.cache objectForKeyAsync:invalidKey completion:^(id cache, NSString *key, id object) { image = (PINImage *)object; dispatch_semaphore_signal(semaphore); }]; @@ -266,41 +278,60 @@ - (void)testObjectGetWithInvalidKey - (void)testObjectRemove { NSString *key = @"key"; - dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); self.cache[key] = [self image]; + + __block BOOL willRemoveObjectBlockCalled = NO; + self.cache.diskCache.willRemoveObjectBlock = ^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { + willRemoveObjectBlockCalled = YES; + }; + + __block BOOL didRemoveObjectBlockCalled = NO; + self.cache.diskCache.didRemoveObjectBlock = ^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { + didRemoveObjectBlockCalled = YES; + }; - [self.cache removeObjectForKeyAsync:key completion:^(PINCache *cache, NSString *key, id object) { - dispatch_semaphore_signal(semaphore); - }]; - - dispatch_semaphore_wait(semaphore, [self timeout]); - + // Clear out operation queue to ensure blocks are set. + [self.cache.diskCache.operationQueue waitUntilAllOperationsAreFinished]; + + [self.cache removeObjectForKey:key]; + id object = self.cache[key]; - + XCTAssertNil(object, @"object was not removed"); + XCTAssertTrue(willRemoveObjectBlockCalled, @"willRemoveObjectBlock was not called"); + XCTAssertTrue(didRemoveObjectBlockCalled, @"didRemoveObjectBlock was not called"); } - (void)testObjectRemoveAll { NSString *key1 = @"key1"; NSString *key2 = @"key2"; - dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); self.cache[key1] = key1; self.cache[key2] = key2; + + __block BOOL willRemoveAllObjectsBlockCalled = NO; + self.cache.diskCache.willRemoveAllObjectsBlock = ^(id _Nonnull cache) { + willRemoveAllObjectsBlockCalled = YES; + }; + + __block BOOL didRemoveAllObjectsBlockCalled = NO; + self.cache.diskCache.didRemoveAllObjectsBlock = ^(id _Nonnull cache) { + didRemoveAllObjectsBlockCalled = YES; + }; - [self.cache removeAllObjectsAsync:^(PINCache *cache) { - dispatch_semaphore_signal(semaphore); - }]; - - dispatch_semaphore_wait(semaphore, [self timeout]); + [self.cache.diskCache.operationQueue waitUntilAllOperationsAreFinished]; + + [self.cache removeAllObjects]; id object1 = self.cache[key1]; id object2 = self.cache[key2]; XCTAssertNil(object1, @"not all objects were removed"); XCTAssertNil(object2, @"not all objects were removed"); + XCTAssertTrue(willRemoveAllObjectsBlockCalled, @"willRemoveAllObjectsBlock was not called"); + XCTAssertTrue(didRemoveAllObjectsBlockCalled, @"didRemoveAllObjectsBlock was not called"); XCTAssertTrue(self.cache.memoryCache.totalCost == 0, @"memory cache cost was not 0 after removing all objects"); XCTAssertTrue(self.cache.diskByteCount == 0, @"disk cache byte count was not 0 after removing all objects"); } @@ -354,6 +385,51 @@ - (void)testMemoryCostByDate XCTAssertTrue(self.cache.memoryCache.totalCost == 0, @"cache had an unexpected total cost"); } +- (void)testMemoryCostByDateWithObjectExpiration +{ + [self.cache.memoryCache setTtlCache:YES]; + [self.cache.memoryCache removeAllObjects]; + NSString * const key1 = @"key1"; + NSString * const key2 = @"key2"; + NSString * const key3 = @"key3"; + NSString * const key4 = @"key4"; + const NSUInteger cost = 1; + const NSTimeInterval oldAgeLimit = 60.0; + const NSTimeInterval notSoOldAgeLimit = 30.0; + + // Add the objects to the cache; set the age limit of one of them (key3) so it expires before the others. + [self.cache.memoryCache setObject:[self image] forKey:key1 withCost:cost ageLimit:oldAgeLimit]; + [self.cache.memoryCache setObject:[self image] forKey:key2 withCost:cost ageLimit:oldAgeLimit]; + [self.cache.memoryCache setObject:[self image] forKey:key3 withCost:cost ageLimit:notSoOldAgeLimit]; + [self.cache.memoryCache setObject:[self image] forKey:key4 withCost:cost ageLimit:oldAgeLimit]; + + // Make the order of recently used key3, key1, key4, key2 + [self.cache.memoryCache objectForKey:key2]; + [self.cache.memoryCache objectForKey:key4]; + [self.cache.memoryCache objectForKey:key1]; + [self.cache.memoryCache objectForKey:key3]; + + // Fast forward 45 seconds. This should expire key3. + [NSDate startMockingDateWithDate:[NSDate dateWithTimeIntervalSinceNow:45]]; + + // Trim the cache enough to evict two objects. + [self.cache.memoryCache trimToCostByDate:self.cache.memoryCache.totalCost - cost * 2]; + + // Go back to current time, so we can check if objects exist in cache. If we don't do this, the getters will return nil + // even if the objects are in the cache. + [NSDate stopMockingDate]; + + // The only objects left should be the last two that were accessed (key3 && key1), but since key3 is expired it will be + // removed first leaving key1 and key4 to remain. + NSMutableArray *keys = [NSMutableArray array]; + [self.cache.memoryCache enumerateObjectsWithBlock:^(id cache, NSString * key, id object, BOOL *stop) { + [keys addObject:key]; + }]; + XCTAssertTrue(keys.count == 2); + XCTAssertTrue([keys.firstObject isEqualToString:key1] || [keys.firstObject isEqualToString:key4]); + XCTAssertTrue([keys.lastObject isEqualToString:key1] || [keys.lastObject isEqualToString:key4]); +} + - (void)testDiskByteCount { self.cache[@"image"] = [self image]; @@ -374,6 +450,54 @@ - (void)testDiskByteCountWithExistingKey XCTAssertTrue(self.cache.diskByteCount > initialDiskByteCount, @"disk cache byte count should increase with new key and object added to disk cache"); } +- (void)testDiskSizeByDateWithObjectExpiration +{ + [self.cache.diskCache setTtlCacheSync:YES]; + [self.cache.diskCache removeAllObjects]; + NSString * const key1 = @"key1"; + NSString * const key2 = @"key2"; + NSString * const key3 = @"key3"; + NSString * const key4 = @"key4"; + const NSUInteger cost = 1; + const NSTimeInterval oldAgeLimit = 60.0; + const NSTimeInterval notSoOldAgeLimit = 30.0; + + // Add the objects to the cache; set the age limit of one of them (key3) so it expires before the others. + [self.cache.diskCache setObject:[self image] forKey:key1 withCost:cost ageLimit:oldAgeLimit]; + [self.cache.diskCache setObject:[self image] forKey:key2 withCost:cost ageLimit:oldAgeLimit]; + [self.cache.diskCache setObject:[self image] forKey:key3 withCost:cost ageLimit:notSoOldAgeLimit]; + NSUInteger sizeOfThreeObjects = self.cache.diskCache.byteCount; + [self.cache.diskCache setObject:[self image] forKey:key4 withCost:cost ageLimit:oldAgeLimit]; + + // Make the order of recently used key3, key1, key4, key2 + [self.cache.diskCache objectForKey:key2]; + [self.cache.diskCache objectForKey:key4]; + [self.cache.diskCache objectForKey:key1]; + [self.cache.diskCache objectForKey:key3]; + + // Fast forward 45 seconds. This should expire key3. + [NSDate startMockingDateWithDate:[NSDate dateWithTimeIntervalSinceNow:45]]; + + + // Trim the cache enough to evict two objects. + [self.cache.diskCache trimToSizeByDate:sizeOfThreeObjects - 1]; + + // Go back to current time, so we can check if objects exist in cache. If we don't do this, the getters will return nil + // even if the objects are in the cache. + [NSDate stopMockingDate]; + + // The only objects left should be the last two that were accessed (key3 && key1), but since key3 is expired it will be + // removed first leaving key1 and key4 to remain. + NSMutableArray *keys = [NSMutableArray array]; + [self.cache.diskCache enumerateObjectsWithBlock:^(NSString * _Nonnull key, NSURL * _Nullable fileURL, BOOL * _Nonnull stop) { + [keys addObject:key]; + }]; + + XCTAssertTrue(keys.count == 2); + XCTAssertTrue([keys.firstObject isEqualToString:key1] || [keys.firstObject isEqualToString:key4]); + XCTAssertTrue([keys.lastObject isEqualToString:key1] || [keys.lastObject isEqualToString:key4]); +} + - (void)testOneThousandAndOneWrites { NSUInteger max = 1001; @@ -389,9 +513,9 @@ - (void)testOneThousandAndOneWrites #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" dispatch_group_enter(group); - [self.cache setObjectAsync:obj forKey:key completion:^(PINCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { + [self.cache setObjectAsync:obj forKey:key completion:^(id _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { dispatch_async(queue, ^{ - [self.cache objectForKeyAsync:key completion:^(PINCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { + [self.cache objectForKeyAsync:key completion:^(id _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { NSString *obj = [[NSString alloc] initWithFormat:@"obj %lu", (unsigned long)i]; XCTAssertTrue([object isEqualToString:obj] == YES, @"object returned was not object set"); @synchronized (self) { @@ -419,7 +543,7 @@ - (void)testMemoryWarningBlock __block BOOL blockDidExecute = NO; - self.cache.memoryCache.didReceiveMemoryWarningBlock = ^(PINMemoryCache *cache) { + self.cache.memoryCache.didReceiveMemoryWarningBlock = ^(id cache) { blockDidExecute = YES; dispatch_semaphore_signal(semaphore); }; @@ -438,7 +562,7 @@ - (void)testBackgroundBlock __block BOOL blockDidExecute = NO; - self.cache.memoryCache.didEnterBackgroundBlock = ^(PINMemoryCache *cache) { + self.cache.memoryCache.didEnterBackgroundBlock = ^(id cache) { blockDidExecute = YES; dispatch_semaphore_signal(semaphore); }; @@ -475,8 +599,8 @@ - (void)testMemoryWarningProperty __block id object = nil; - self.cache.memoryCache.didReceiveMemoryWarningBlock = ^(PINMemoryCache *cache) { - object = cache[@"object"]; + self.cache.memoryCache.didReceiveMemoryWarningBlock = ^(id cache) { + object = [cache objectForKey:@"object"]; dispatch_semaphore_signal(semaphore); }; @@ -504,12 +628,13 @@ - (void)testMemoryCacheEnumerationWithWarning __block NSUInteger enumCount = 0; - self.cache.memoryCache.didReceiveMemoryWarningBlock = ^(PINMemoryCache *cache) { - [cache enumerateObjectsWithBlockAsync:^(PINMemoryCache *cache, NSString *key, id object, BOOL *stop) { + self.cache.memoryCache.didReceiveMemoryWarningBlock = ^(id cache) { + PINMemoryCache *memoryCache = (PINMemoryCache *)cache; + [memoryCache enumerateObjectsWithBlockAsync:^(id cache, NSString *key, id object, BOOL *stop) { @synchronized (self) { enumCount++; } - } completionBlock:^(PINMemoryCache *cache) { + } completionBlock:^(id cache) { dispatch_semaphore_signal(semaphore); }]; }; @@ -549,7 +674,7 @@ - (void)testDiskCacheEnumeration @synchronized (self) { enumCount++; } - } completionBlock:^(PINDiskCache *cache) { + } completionBlock:^(id cache) { dispatch_semaphore_signal(semaphore); }]; @@ -606,25 +731,25 @@ - (void)testAgeLimit __block id diskObj2 = nil; dispatch_group_enter(group); - [self.cache.memoryCache objectForKeyAsync:key1 completion:^(PINMemoryCache *cache, NSString *key, id object) { + [self.cache.memoryCache objectForKeyAsync:key1 completion:^(id cache, NSString *key, id object) { memObj1 = object; dispatch_group_leave(group); }]; dispatch_group_enter(group); - [self.cache.memoryCache objectForKeyAsync:key2 completion:^(PINMemoryCache *cache, NSString *key, id object) { + [self.cache.memoryCache objectForKeyAsync:key2 completion:^(id cache, NSString *key, id object) { memObj2 = object; dispatch_group_leave(group); }]; dispatch_group_enter(group); - [self.cache.diskCache objectForKeyAsync:key1 completion:^(PINDiskCache *cache, NSString *key, id object) { + [self.cache.diskCache objectForKeyAsync:key1 completion:^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { diskObj1 = object; dispatch_group_leave(group); }]; dispatch_group_enter(group); - [self.cache.diskCache objectForKeyAsync:key2 completion:^(PINDiskCache *cache, NSString *key, id object) { + [self.cache.diskCache objectForKeyAsync:key2 completion:^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { diskObj2 = object; dispatch_group_leave(group); }]; @@ -649,25 +774,25 @@ - (void)testAgeLimit sleep(1); dispatch_group_enter(group); - [self.cache.memoryCache objectForKeyAsync:key1 completion:^(PINMemoryCache *cache, NSString *key, id object) { + [self.cache.memoryCache objectForKeyAsync:key1 completion:^(id cache, NSString *key, id object) { memObj1 = object; dispatch_group_leave(group); }]; dispatch_group_enter(group); - [self.cache.memoryCache objectForKeyAsync:key2 completion:^(PINMemoryCache *cache, NSString *key, id object) { + [self.cache.memoryCache objectForKeyAsync:key2 completion:^(id cache, NSString *key, id object) { memObj2 = object; dispatch_group_leave(group); }]; dispatch_group_enter(group); - [self.cache.diskCache objectForKeyAsync:key1 completion:^(PINDiskCache *cache, NSString *key, id object) { + [self.cache.diskCache objectForKeyAsync:key1 completion:^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { diskObj1 = object; dispatch_group_leave(group); }]; dispatch_group_enter(group); - [self.cache.diskCache objectForKeyAsync:key2 completion:^(PINDiskCache *cache, NSString *key, id object) { + [self.cache.diskCache objectForKeyAsync:key2 completion:^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { diskObj2 = object; dispatch_group_leave(group); }]; @@ -717,8 +842,8 @@ - (void)testDiskReadingAfterCacheInit PINDiskCache *diskCache = [[PINDiskCache alloc] initWithName:cacheName]; [diskCache removeAllObjects]; - // store a bunch of objects - for (NSUInteger idx = 0; idx < 1000; idx++) { + // Store a bunch of objects so it will take a long time to initialize. + for (NSUInteger idx = 0; idx < 5000; idx++) { NSData *tmpData = [[@(idx) stringValue] dataUsingEncoding:NSUTF8StringEncoding]; [diskCache setObject:tmpData forKey:[@(idx) stringValue]]; } @@ -728,7 +853,7 @@ - (void)testDiskReadingAfterCacheInit diskCache = [[PINDiskCache alloc] initWithName:cacheName]; // Check to see if we can get an object before the disk state is known. - XCTAssertNotNil([diskCache objectForKey:[@(999) stringValue]]); + XCTAssertNotNil([diskCache objectForKey:[@(1) stringValue]]); XCTAssertFalse(diskCache.diskStateKnown); sleep(5); @@ -777,7 +902,7 @@ - (void)_testTTLCacheObjectAccess { // Wait until time 3 so that we know the object should be expired, the 1st cache clearing has happened, and the 2nd cache clearing hasn't happened yet sleep(2); - [self.cache.diskCache setTtlCache:YES]; + [self.cache.diskCache setTtlCacheSync:YES]; [self.cache.memoryCache setTtlCache:YES]; dispatch_group_t group = dispatch_group_create(); @@ -786,13 +911,13 @@ - (void)_testTTLCacheObjectAccess { __block id diskObj = nil; dispatch_group_enter(group); - [self.cache.memoryCache objectForKeyAsync:key completion:^(PINMemoryCache *cache, NSString *key, id object) { + [self.cache.memoryCache objectForKeyAsync:key completion:^(id cache, NSString *key, id object) { memObj = object; dispatch_group_leave(group); }]; dispatch_group_enter(group); - [self.cache.diskCache objectForKeyAsync:key completion:^(PINDiskCache *cache, NSString *key, id object) { + [self.cache.diskCache objectForKeyAsync:key completion:^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { diskObj = object; dispatch_group_leave(group); }]; @@ -803,20 +928,20 @@ - (void)_testTTLCacheObjectAccess { XCTAssertNil(memObj, @"should not be in memory cache"); XCTAssertNil(diskObj, @"should not be in disk cache"); - [self.cache.diskCache setTtlCache:NO]; + [self.cache.diskCache setTtlCacheSync:NO]; [self.cache.memoryCache setTtlCache:NO]; memObj = nil; diskObj = nil; dispatch_group_enter(group); - [self.cache.memoryCache objectForKeyAsync:key completion:^(PINMemoryCache *cache, NSString *key, id object) { + [self.cache.memoryCache objectForKeyAsync:key completion:^(id cache, NSString *key, id object) { memObj = object; dispatch_group_leave(group); }]; dispatch_group_enter(group); - [self.cache.diskCache objectForKeyAsync:key completion:^(PINDiskCache *cache, NSString *key, id object) { + [self.cache.diskCache objectForKeyAsync:key completion:^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) { diskObj = object; dispatch_group_leave(group); }]; @@ -842,7 +967,7 @@ - (void)_testTTLCacheObjectEnumeration { // Wait until time 3 so that we know the object should be expired, the 1st cache clearing has happened, and the 2nd cache clearing hasn't happened yet sleep(2); - [self.cache.diskCache setTtlCache:YES]; + [self.cache.diskCache setTtlCacheSync:YES]; [self.cache.memoryCache setTtlCache:YES]; // Wait for ttlCache to be set @@ -863,13 +988,13 @@ - (void)_testTTLCacheObjectEnumeration { XCTAssertEqual(objCount, expectedObjCount, @"Expected %lu objects in the cache", (unsigned long)expectedObjCount); objCount = 0; - [self.cache.memoryCache enumerateObjectsWithBlock:^(PINMemoryCache *cache, NSString *key, id _Nullable object, BOOL *stop) { + [self.cache.memoryCache enumerateObjectsWithBlock:^(id cache, NSString *key, id _Nullable object, BOOL *stop) { objCount++; }]; XCTAssertEqual(objCount, expectedObjCount, @"Expected %lu objects in the cache", (unsigned long)expectedObjCount); - [self.cache.diskCache setTtlCache:NO]; + [self.cache.diskCache setTtlCacheSync:NO]; [self.cache.memoryCache setTtlCache:NO]; // Wait for ttlCache to be set @@ -889,7 +1014,7 @@ - (void)_testTTLCacheObjectEnumeration { XCTAssertEqual(objCount, expectedObjCount, @"Expected %lu objects in the cache", (unsigned long)expectedObjCount); objCount = 0; - [self.cache.memoryCache enumerateObjectsWithBlock:^(PINMemoryCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object, BOOL *stop) { + [self.cache.memoryCache enumerateObjectsWithBlock:^(id _Nonnull cache, NSString * _Nonnull key, id _Nullable object, BOOL *stop) { objCount++; }]; @@ -923,7 +1048,7 @@ - (void)_testTTLCacheFileURLForKey { // Wait a moment to ensure that the file modification time can be changed to something different sleep(1); - [self.cache.diskCache setTtlCache:YES]; + [self.cache.diskCache setTtlCacheSync:YES]; // Wait for ttlCache to be set sleep(1); @@ -940,7 +1065,7 @@ - (void)_testTTLCacheFileURLForKey { XCTAssertEqualObjects(initialModificationDate, ttlCacheEnabledModificationDate, @"The modification date shouldn't change when accessing the file URL, when ttlCache is enabled"); - [self.cache.diskCache setTtlCache:NO]; + [self.cache.diskCache setTtlCacheSync:NO]; // Wait for ttlCache to be set sleep(1); @@ -959,6 +1084,205 @@ - (void)_testTTLCacheFileURLForKey { } +- (void)testObjectTTLObjectAccess +{ + [self.cache.memoryCache setTtlCache:YES]; + [self.cache.diskCache setTtlCacheSync:YES]; + [self.cache removeAllObjects]; + NSString *key1 = @"key1"; + NSString *key2 = @"key2"; + + [self.cache setObject:[self image] forKey:key1 withAgeLimit:60.0]; + [self.cache setObject:[self image] forKey:key2 withAgeLimit:120.0]; + + // Neither object should be expired at this point and should exist in both caches + + XCTestExpectation *memObjectForKey1Expectation = [self expectationWithDescription:@"memoryCache objectForKeyAsync - #1"]; + [self.cache.memoryCache objectForKeyAsync:key1 completion:^(id cache, NSString *key, id object) { + XCTAssertNotNil(object, @"should still be in memory cache"); + [memObjectForKey1Expectation fulfill]; + }]; + + XCTestExpectation *memObjectForKey2Expectation = [self expectationWithDescription:@"memoryCache objectForKeyAsync - #2"]; + [self.cache.memoryCache objectForKeyAsync:key2 completion:^(id cache, NSString *key, id object) { + XCTAssertNotNil(object, @"should still be in memory cache"); + [memObjectForKey2Expectation fulfill]; + }]; + + XCTestExpectation *diskObjectForKey1Expectation = [self expectationWithDescription:@"diskCache objectForKeyAsync - #1"]; + [self.cache.diskCache objectForKeyAsync:key1 completion:^(PINDiskCache *cache, NSString *key, id object) { + XCTAssertNotNil(object, @"should still be in disk cache"); + [diskObjectForKey1Expectation fulfill]; + }]; + + XCTestExpectation *diskObjectForKey2Expectation = [self expectationWithDescription:@"diskCache objectForKeyAsync - #2"]; + [self.cache.diskCache objectForKeyAsync:key2 completion:^(PINDiskCache *cache, NSString *key, id object) { + XCTAssertNotNil(object, @"should still be in disk cache"); + [diskObjectForKey2Expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:0.1 handler:nil]; + + // Fast forward 90 seconds. + [NSDate startMockingDateWithDate:[NSDate dateWithTimeIntervalSinceNow:90]]; + + // The first object has been expired for 30 seconds and should not exist in the cache anymore. + + memObjectForKey1Expectation = [self expectationWithDescription:@"memoryCache objectForKeyAsync - #1"]; + [self.cache.memoryCache objectForKeyAsync:key1 completion:^(id cache, NSString *key, id object) { + XCTAssertNil(object, @"should not be in memory cache"); + [memObjectForKey1Expectation fulfill]; + }]; + + memObjectForKey2Expectation = [self expectationWithDescription:@"memoryCache objectForKeyAsync - #2"]; + [self.cache.memoryCache objectForKeyAsync:key2 completion:^(id cache, NSString *key, id object) { + XCTAssertNotNil(object, @"should not be in memory cache"); + [memObjectForKey2Expectation fulfill]; + }]; + + diskObjectForKey1Expectation = [self expectationWithDescription:@"diskCache objectForKeyAsync - #1"]; + [self.cache.diskCache objectForKeyAsync:key1 completion:^(PINDiskCache *cache, NSString *key, id object) { + XCTAssertNil(object, @"should not be in disk cache"); + [diskObjectForKey1Expectation fulfill]; + }]; + + diskObjectForKey2Expectation = [self expectationWithDescription:@"diskCache objectForKeyAsync - #2"]; + [self.cache.diskCache objectForKeyAsync:key2 completion:^(PINDiskCache *cache, NSString *key, id object) { + XCTAssertNotNil(object, @"should not be in disk cache"); + [diskObjectForKey2Expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:0.1 handler:nil]; + + [NSDate stopMockingDate]; +} + +- (void)testObjectTTLObjectEnumeration +{ + [self.cache.memoryCache setTtlCache:YES]; + [self.cache.diskCache setTtlCacheSync:YES]; + [self.cache removeAllObjects]; + NSString *key1 = @"key1"; + NSString *key2 = @"key2"; + + [self.cache setObject:[self image] forKey:key1 withAgeLimit:60.0]; + [self.cache setObject:[self image] forKey:key2 withAgeLimit:120.0]; + + // Neither object should be expired at this point and should exist in both caches + + __block NSUInteger objCount = 0; + [self.cache.memoryCache enumerateObjectsWithBlock:^(id cache, NSString *key, id _Nullable object, BOOL *stop) { + objCount++; + }]; + XCTAssertEqual(objCount, 2, @"Expected 2 objects, got %tu.", objCount); + + objCount = 0; + [self.cache.diskCache enumerateObjectsWithBlock:^(NSString * _Nonnull key, NSURL * _Nullable fileURL, BOOL *stop) { + objCount++; + }]; + XCTAssertEqual(objCount, 2, @"Expected 2 objects, got %tu.", objCount); + + // Fast forward 90 seconds. + [NSDate startMockingDateWithDate:[NSDate dateWithTimeIntervalSinceNow:90]]; + + // The first object has been expired for 30 seconds and should not exist in the cache anymore. + + objCount = 0; + [self.cache.memoryCache enumerateObjectsWithBlock:^(id cache, NSString *key, id _Nullable object, BOOL *stop) { + objCount++; + }]; + XCTAssertEqual(objCount, 1, @"Expected 1 object, got %tu.", objCount); + + objCount = 0; + [self.cache.diskCache enumerateObjectsWithBlock:^(NSString * _Nonnull key, NSURL * _Nullable fileURL, BOOL *stop) { + objCount++; + }]; + XCTAssertEqual(objCount, 1, @"Expected 1 object, got %tu.", objCount); + + [NSDate stopMockingDate]; +} + +- (void)testRemoveExpiredObjects +{ + [self.cache.memoryCache setTtlCache:YES]; + [self.cache.diskCache setTtlCacheSync:YES]; + [self.cache removeAllObjects]; + NSString *key1 = @"key1"; + NSString *key2 = @"key2"; + + [self.cache setObject:[self image] forKey:key1 withAgeLimit:60.0]; + [self.cache setObject:[self image] forKey:key2 withAgeLimit:120.0]; + + // Fast forward 90 seconds. + [NSDate startMockingDateWithDate:[NSDate dateWithTimeIntervalSinceNow:90]]; + + // The first object has been expired for 30 seconds and should be cleared out. + [self.cache removeExpiredObjects]; + + // Go back to current time, so we can check if objects exist in cache. If we don't do this, the getters will return nil + // even if the objects are in the cache. + [NSDate stopMockingDate]; + + XCTestExpectation *memObjectForKey1Expectation = [self expectationWithDescription:@"memoryCache objectForKeyAsync - #1"]; + [self.cache.memoryCache objectForKeyAsync:key1 completion:^(id cache, NSString *key, id object) { + XCTAssertNil(object, @"should not be in memory cache"); + [memObjectForKey1Expectation fulfill]; + }]; + + XCTestExpectation *memObjectForKey2Expectation = [self expectationWithDescription:@"memoryCache objectForKeyAsync - #2"]; + [self.cache.memoryCache objectForKeyAsync:key2 completion:^(id cache, NSString *key, id object) { + XCTAssertNotNil(object, @"should not be in memory cache"); + [memObjectForKey2Expectation fulfill]; + }]; + + XCTestExpectation *diskObjectForKey1Expectation = [self expectationWithDescription:@"diskCache objectForKeyAsync - #1"]; + [self.cache.diskCache objectForKeyAsync:key1 completion:^(PINDiskCache *cache, NSString *key, id object) { + XCTAssertNil(object, @"should not be in disk cache"); + [diskObjectForKey1Expectation fulfill]; + }]; + + XCTestExpectation *diskObjectForKey2Expectation = [self expectationWithDescription:@"diskCache objectForKeyAsync - #2"]; + [self.cache.diskCache objectForKeyAsync:key2 completion:^(PINDiskCache *cache, NSString *key, id object) { + XCTAssertNotNil(object, @"should not be in disk cache"); + [diskObjectForKey2Expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:0.1 handler:nil]; +} + +- (void)testDiskRehydrationOfObjectAgeLimit +{ + NSString * const cacheName = @"testDiskRehydrationOfObjectAgeLimit"; + NSString * const key = @"key"; + const NSTimeInterval ageLimit = 60.0; + PINDiskCache *testCache = [[PINDiskCache alloc] initWithName:cacheName]; + [testCache setTtlCacheSync:YES]; + NSURL *testCacheURL = testCache.cacheURL; + NSError *error = nil; + + //Make sure the cache URL does not exist. + if ([[NSFileManager defaultManager] fileExistsAtPath:[testCacheURL path]]) { + [[NSFileManager defaultManager] removeItemAtURL:testCacheURL error:&error]; + XCTAssertNil(error); + } + + testCache = [[PINDiskCache alloc] initWithName:cacheName]; + [testCache setTtlCacheSync:YES]; + [testCache setObject:[self image] forKey:key withAgeLimit:ageLimit]; + + // The age limit is set asynchronously, *even* when we set the object synchronously. + sleep(1); + + // Re-initialize the cache, this should read the age limit for the object from the extended file system attributes. + testCache = [[PINDiskCache alloc] initWithName:cacheName]; + [testCache setTtlCacheSync:YES]; + + [testCache waitForKnownState]; + id object = testCache.metadata[key]; + id ageLimitFromDisk = [object valueForKey:@"ageLimit"]; + XCTAssertEqual([ageLimitFromDisk doubleValue], ageLimit); +} + - (void)testAsyncDiskInitialization { NSString * const cacheName = @"testAsyncDiskInitialization"; @@ -1018,12 +1342,12 @@ - (void)testDiskCacheEmptyTrash { const NSUInteger fileCount = 100; NSFileManager *fileManager = [NSFileManager defaultManager]; - NSString *tempDirPath = NSTemporaryDirectory(); + NSString *trashPath = [[PINDiskCache sharedTrashURL] path]; dispatch_group_t group = dispatch_group_create(); NSError *error = nil; - unsigned long long originalTempDirSize = [[fileManager attributesOfItemAtPath:tempDirPath error:&error] fileSize]; + unsigned long long originalTempDirSize = [[fileManager attributesOfItemAtPath:trashPath error:&error] fileSize]; XCTAssertNil(error); for (int i = 0; i < fileCount; i++) { @@ -1032,20 +1356,17 @@ - (void)testDiskCacheEmptyTrash } dispatch_group_enter(group); - [self.cache.diskCache removeAllObjectsAsync:^(PINDiskCache * _Nonnull cache) { + [self.cache.diskCache removeAllObjectsAsync:^(id _Nonnull cache) { // Temporary directory should be bigger now since the trash directory is still inside it NSError *error = nil; - unsigned long long tempDirSize = [[fileManager attributesOfItemAtPath:tempDirPath error:&error] fileSize]; + unsigned long long tempDirSize = [[fileManager attributesOfItemAtPath:trashPath error:&error] fileSize]; XCTAssertNil(error); XCTAssertLessThan(originalTempDirSize, tempDirSize); - // Temporary directory should get back to its original size at the end of the trash queue + // Temporary directory should be gone at the end of the trash queue. dispatch_group_enter(group); dispatch_async([PINDiskCache sharedTrashQueue], ^{ - NSError *error = nil; - unsigned long long tempDirSize = [[fileManager attributesOfItemAtPath:tempDirPath error:&error] fileSize]; - XCTAssertNil(error); - XCTAssertEqual(originalTempDirSize, tempDirSize); + XCTAssertFalse([fileManager fileExistsAtPath:trashPath isDirectory:NULL]); dispatch_group_leave(group); }); @@ -1082,4 +1403,10 @@ - (void)testCustomEncoderDecoder { } +- (void)testTTLCacheIsSet { + PINCache *cache = [[PINCache alloc] initWithName:@"test" rootPath:PINDiskCachePrefix serializer:nil deserializer:nil keyEncoder:nil keyDecoder:nil ttlCache:YES]; + XCTAssert(cache.diskCache.isTTLCache); + XCTAssert(cache.memoryCache.isTTLCache); +} + @end diff --git a/sample/UrlGet/Vendor/PINCache/Tests/PINDiskCache+PINCacheTests.h b/sample/UrlGet/Vendor/PINCache/Tests/PINDiskCache+PINCacheTests.h new file mode 100644 index 00000000..fc778cf4 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Tests/PINDiskCache+PINCacheTests.h @@ -0,0 +1,16 @@ +#import "PINCache.h" + +@interface PINDiskCache (PINCacheTests) + +/** + Sets `ttlCache` property synchronously. This is normally set asyncronously, but for testing purposes it is useful block until the + actual value has been set. + */ +- (void)setTtlCacheSync:(BOOL)ttlCache; + +/** + Waits until all metadata has been read off the disk + */ +- (void)waitForKnownState; + +@end diff --git a/sample/UrlGet/Vendor/PINCache/Tests/PINDiskCache+PINCacheTests.m b/sample/UrlGet/Vendor/PINCache/Tests/PINDiskCache+PINCacheTests.m new file mode 100644 index 00000000..fd8a164f --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/Tests/PINDiskCache+PINCacheTests.m @@ -0,0 +1,28 @@ +#import "PINDiskCache+PINCacheTests.h" + +@interface PINDiskCache () { + BOOL _ttlCache; +} + +- (void)lock; +- (void)lockAndWaitForKnownState; +- (void)unlock; + +@end + +@implementation PINDiskCache (PINCacheTests) + +- (void)setTtlCacheSync:(BOOL)ttlCache +{ + [self lock]; + [self setValue:@(ttlCache) forKey:@"_ttlCache"]; + [self unlock]; +} + +- (void)waitForKnownState +{ + [self lockAndWaitForKnownState]; + [self unlock]; +} + +@end diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Private/PINCache-prefix.pch b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Private/PINCache-prefix.pch new file mode 100644 index 00000000..e1338b37 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Private/PINCache-prefix.pch @@ -0,0 +1,3 @@ +#ifndef TARGET_OS_WATCH + #define TARGET_OS_WATCH 0 +#endif \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCache.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCache.h new file mode 120000 index 00000000..3ccab7af --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCache.h @@ -0,0 +1 @@ +../../../../Source/PINCache.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCacheMacros.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCacheMacros.h new file mode 120000 index 00000000..ce096842 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCacheMacros.h @@ -0,0 +1 @@ +../../../../Source/PINCacheMacros.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCacheObjectSubscripting.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCacheObjectSubscripting.h new file mode 120000 index 00000000..8efd77cb --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCacheObjectSubscripting.h @@ -0,0 +1 @@ +../../../../Source/PINCacheObjectSubscripting.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCaching.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCaching.h new file mode 120000 index 00000000..0f97185c --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINCaching.h @@ -0,0 +1 @@ +../../../../Source/PINCaching.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINDiskCache.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINDiskCache.h new file mode 120000 index 00000000..66f37322 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINDiskCache.h @@ -0,0 +1 @@ +../../../../Source/PINDiskCache.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINMemoryCache.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINMemoryCache.h new file mode 120000 index 00000000..dc5322e8 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Arc-exception-safe/PINMemoryCache.h @@ -0,0 +1 @@ +../../../../Source/PINMemoryCache.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCache.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCache.h new file mode 120000 index 00000000..3ccab7af --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCache.h @@ -0,0 +1 @@ +../../../../Source/PINCache.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCacheMacros.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCacheMacros.h new file mode 120000 index 00000000..ce096842 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCacheMacros.h @@ -0,0 +1 @@ +../../../../Source/PINCacheMacros.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCacheObjectSubscripting.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCacheObjectSubscripting.h new file mode 120000 index 00000000..8efd77cb --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCacheObjectSubscripting.h @@ -0,0 +1 @@ +../../../../Source/PINCacheObjectSubscripting.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCaching.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCaching.h new file mode 120000 index 00000000..0f97185c --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINCaching.h @@ -0,0 +1 @@ +../../../../Source/PINCaching.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINDiskCache.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINDiskCache.h new file mode 120000 index 00000000..66f37322 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINDiskCache.h @@ -0,0 +1 @@ +../../../../Source/PINDiskCache.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINMemoryCache.h b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINMemoryCache.h new file mode 120000 index 00000000..dc5322e8 --- /dev/null +++ b/sample/UrlGet/Vendor/PINCache/pod_support/Headers/Public/Core/PINMemoryCache.h @@ -0,0 +1 @@ +../../../../Source/PINMemoryCache.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINCache/pod_support_buildable/BUILD b/sample/UrlGet/Vendor/PINCache/pod_support_buildable/BUILD.bazel similarity index 100% rename from sample/UrlGet/Vendor/PINCache/pod_support_buildable/BUILD rename to sample/UrlGet/Vendor/PINCache/pod_support_buildable/BUILD.bazel diff --git a/sample/UrlGet/Vendor/PINOperation/.pod-version b/sample/UrlGet/Vendor/PINOperation/.pod-version index c7c0e07f..624eef19 100644 --- a/sample/UrlGet/Vendor/PINOperation/.pod-version +++ b/sample/UrlGet/Vendor/PINOperation/.pod-version @@ -1 +1 @@ --3247681909583964502-68700520133401961134256632320500583438 \ No newline at end of file +-48221774311147173615538367903342762533-4260907143073457835 \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINOperation/BUILD b/sample/UrlGet/Vendor/PINOperation/BUILD.bazel similarity index 59% rename from sample/UrlGet/Vendor/PINOperation/BUILD rename to sample/UrlGet/Vendor/PINOperation/BUILD.bazel index 84d58db1..4c50d348 100644 --- a/sample/UrlGet/Vendor/PINOperation/BUILD +++ b/sample/UrlGet/Vendor/PINOperation/BUILD.bazel @@ -1,9 +1,10 @@ + load( "//Vendor/rules_pods/BazelExtensions:extensions.bzl", - "pch_with_name_hint", "acknowledged_target", "gen_module_map", - "gen_includes" + "gen_includes", + "headermap" ) # Add a config setting release for compilation mode # Assume that people are using `opt` for release mode @@ -15,12 +16,68 @@ config_setting( "compilation_mode": "opt" } ) +config_setting( + name = "osxCase", + values = { + "apple_platform_type": "macos" + } +) +config_setting( + name = "tvosCase", + values = { + "apple_platform_type": "tvos" + } +) +config_setting( + name = "watchosCase", + values = { + "apple_platform_type": "watchos" + } +) +filegroup( + name = "PINOperation_package_hdrs", + srcs = [ + "PINOperation_cxx_direct_hdrs", + "PINOperation_direct_hdrs" + ], + visibility = [ + "//visibility:public" + ] +) +filegroup( + name = "PINOperation_cxx_direct_hdrs", + srcs = glob( + glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ) + glob( + [ + "Source/**/*.h" + ], + exclude_directories = 1 + ), + exclude_directories = 1 + ), + visibility = [ + "//visibility:public" + ] +) filegroup( name = "PINOperation_cxx_hdrs", srcs = glob( - [ - "Source/**/*.h" - ], + glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ) + glob( + [ + "Source/**/*.h" + ], + exclude_directories = 1 + ), exclude_directories = 1 ), visibility = [ @@ -37,6 +94,18 @@ filegroup( "//visibility:public" ] ) +headermap( + name = "PINOperation_cxx_hmap", + namespace = "PINOperation", + hdrs = [ + "PINOperation_package_hdrs", + ":PINOperation_cxx_union_hdrs" + ], + deps = [], + visibility = [ + "//visibility:public" + ] +) gen_includes( name = "PINOperation_cxx_includes", include = [ @@ -50,24 +119,18 @@ objc_library( [ "Source/**/*.mm" ], - exclude = [ - "Source/**/*.m" - ], + exclude = glob( + [ + "Source/**/*.m" + ], + exclude_directories = 1 + ), exclude_directories = 1 ), hdrs = [ - ":PINOperation_cxx_union_hdrs", - ":PINOperation_module_map_module_map_file" - ], - pch = pch_with_name_hint( - "PINOperation", - [ - "Source/**/*.pch" - ] - ), - includes = [ - "PINOperation_module_map" + ":PINOperation_cxx_hdrs" ], + pch = "pod_support/Headers/Private/PINOperation-prefix.pch", sdk_frameworks = [ "Foundation" ], @@ -75,6 +138,8 @@ objc_library( ":PINOperation_cxx_includes" ], copts = [ + "-std=c++14", + "-Wno-everything", "-Wnon-modular-include-in-framework-module", "-g", "-stdlib=libc++", @@ -100,7 +165,7 @@ objc_library( ) + [ "-IVendor/PINOperation/pod_support/Headers/Public/PINOperation/" ] + [ - "-fmodule-name=PINOperation_pod_module" + "-fmodule-name=PINOperation" ], visibility = [ "//visibility:public" @@ -112,16 +177,39 @@ acknowledged_target( value = "//Vendor/PINOperation/pod_support_buildable:acknowledgement_fragment" ) filegroup( - name = "PINOperation_hdrs", + name = "PINOperation_direct_hdrs", srcs = glob( - [ - "pod_support/Headers/Public/**/*" - ], + glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ) + glob( + [ + "Source/**/*.h" + ], + exclude_directories = 1 + ), exclude_directories = 1 - ) + glob( - [ - "Source/**/*.h" - ], + ), + visibility = [ + "//visibility:public" + ] +) +filegroup( + name = "PINOperation_hdrs", + srcs = glob( + glob( + [ + "pod_support/Headers/Public/**/*" + ], + exclude_directories = 1 + ) + glob( + [ + "Source/**/*.h" + ], + exclude_directories = 1 + ), exclude_directories = 1 ) + [ ":PINOperation_cxx_hdrs" @@ -130,20 +218,26 @@ filegroup( "//visibility:public" ] ) +headermap( + name = "PINOperation_hmap", + namespace = "PINOperation", + hdrs = [ + "PINOperation_package_hdrs", + ":PINOperation_hdrs" + ], + deps = [ + ":PINOperation_cxx" + ], + visibility = [ + "//visibility:public" + ] +) gen_includes( name = "PINOperation_includes", include = [ "Vendor/PINOperation/pod_support/Headers/Public/" ] ) -gen_module_map( - "PINOperation", - "PINOperation_module_map", - "PINOperation", - [ - "PINOperation_hdrs" - ] -) objc_library( name = "PINOperation", enable_modules = 1, @@ -154,18 +248,9 @@ objc_library( exclude_directories = 1 ), hdrs = [ - ":PINOperation_hdrs", - ":PINOperation_module_map_module_map_file" - ], - pch = pch_with_name_hint( - "PINOperation", - [ - "Source/**/*.pch" - ] - ), - includes = [ - "PINOperation_module_map" + ":PINOperation_hdrs" ], + pch = "pod_support/Headers/Private/PINOperation-prefix.pch", sdk_frameworks = [ "Foundation" ], @@ -174,6 +259,7 @@ objc_library( ":PINOperation_includes" ], copts = [ + "-Wno-everything", "-Wnon-modular-include-in-framework-module", "-g", "-stdlib=libc++", @@ -199,7 +285,7 @@ objc_library( ) + [ "-IVendor/PINOperation/pod_support/Headers/Public/PINOperation/" ] + [ - "-fmodule-name=PINOperation_pod_module" + "-fmodule-name=PINOperation" ], visibility = [ "//visibility:public" diff --git a/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Private/PINOperation-prefix.pch b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Private/PINOperation-prefix.pch new file mode 100644 index 00000000..e1338b37 --- /dev/null +++ b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Private/PINOperation-prefix.pch @@ -0,0 +1,3 @@ +#ifndef TARGET_OS_WATCH + #define TARGET_OS_WATCH 0 +#endif \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperation.h b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperation.h new file mode 120000 index 00000000..97aab0d3 --- /dev/null +++ b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperation.h @@ -0,0 +1 @@ +../../../../Source/PINOperation.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationGroup.h b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationGroup.h new file mode 120000 index 00000000..ab709ba3 --- /dev/null +++ b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationGroup.h @@ -0,0 +1 @@ +../../../../Source/PINOperationGroup.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationMacros.h b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationMacros.h new file mode 120000 index 00000000..7409fce8 --- /dev/null +++ b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationMacros.h @@ -0,0 +1 @@ +../../../../Source/PINOperationMacros.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationQueue.h b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationQueue.h new file mode 120000 index 00000000..faa7661c --- /dev/null +++ b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationQueue.h @@ -0,0 +1 @@ +../../../../Source/PINOperationQueue.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationTypes.h b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationTypes.h new file mode 120000 index 00000000..8b408fe8 --- /dev/null +++ b/sample/UrlGet/Vendor/PINOperation/pod_support/Headers/Public/PINOperation_cxx/PINOperationTypes.h @@ -0,0 +1 @@ +../../../../Source/PINOperationTypes.h \ No newline at end of file diff --git a/sample/UrlGet/Vendor/PINOperation/pod_support_buildable/BUILD b/sample/UrlGet/Vendor/PINOperation/pod_support_buildable/BUILD.bazel similarity index 100% rename from sample/UrlGet/Vendor/PINOperation/pod_support_buildable/BUILD rename to sample/UrlGet/Vendor/PINOperation/pod_support_buildable/BUILD.bazel diff --git a/sample/UrlGet/Vendor/rules_pods/BazelExtensions/BUILD b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/BUILD index d7883df0..484c3478 100644 --- a/sample/UrlGet/Vendor/rules_pods/BazelExtensions/BUILD +++ b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/BUILD @@ -21,3 +21,9 @@ sh_library( visibility = ["//visibility:public"] ) +py_binary( + name = "headermap_builder", + srcs = ["headermap_builder.py", "headermap_tool.py"], + visibility = ["//visibility:public"] +) + diff --git a/sample/UrlGet/Vendor/rules_pods/BazelExtensions/LLVM.LICENSE.TXT b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/LLVM.LICENSE.TXT new file mode 100644 index 00000000..b8d2c742 --- /dev/null +++ b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/LLVM.LICENSE.TXT @@ -0,0 +1,69 @@ +============================================================================== +LLVM Release License +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2003-2010 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== +Copyrights and Licenses for Third Party Software Distributed with LLVM: +============================================================================== +The LLVM software contains code written by third parties. Such software will +have its own individual LICENSE.TXT file in the directory in which it appears. +This file will describe the copyrights, license, and restrictions which apply +to that code. + +The disclaimer of warranty in the University of Illinois Open Source License +applies to all code in the LLVM Distribution, and nothing in any of the +other licenses gives permission to use the names of the LLVM Team or the +University of Illinois to endorse or promote products derived from this +Software. + +The following pieces of software have additional or alternate copyrights, +licenses, and/or restrictions: + +Program Directory +------- --------- +Autoconf llvm/autoconf + llvm/projects/ModuleMaker/autoconf + llvm/projects/sample/autoconf +CellSPU backend llvm/lib/Target/CellSPU/README.txt +Google Test llvm/utils/unittest/googletest +OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex} diff --git a/sample/UrlGet/Vendor/rules_pods/BazelExtensions/extensions.bzl b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/extensions.bzl index 4f537d2e..64663157 100644 --- a/sample/UrlGet/Vendor/rules_pods/BazelExtensions/extensions.bzl +++ b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/extensions.bzl @@ -20,7 +20,7 @@ def _acknowledgement_merger_impl(ctx): args.append(f.path) # Write the final output. Bazel only writes the file when required - ctx.action( + ctx.actions.run( inputs=concat, arguments=args, executable=ctx.attr.merger.files.to_list()[0], @@ -83,52 +83,25 @@ def acknowledged_target(name, visibility=["//visibility:public"] ) -# pch_with_name_hint -# -# Take in a name hint and return the PCH with that name -# -# Parameters -# -# hint - Suggestion of pch file name. If any part of this is in a PCH -# filename it will match -# -# sources - a list of source file patterns with pch extensions to search - - -def pch_with_name_hint(hint, sources): - # Recursive glob the sources directories and the root directory - candidates = native.glob(["*.pch", hint + "/*.pch"] + sources) - if len(candidates) == 0: - return None - - # We want to get the candidates in order of lowest to highest - for candidate in candidates: - if hint in candidate: - return candidate - # It is a convention in iOS/OSX development to use a PCH - # with the name of the target. - # This is a hack because, the recursive glob may find some - # arbitrary PCH. - return None - - -def _make_module_map(pod_name, module_name, hdr_providers): +def _make_module_map(pod_name, module_name, deps, is_system): # Up some dirs to the compilation root # bazel-out/ios_x86_64-fastbuild/genfiles/external/__Pod__ relative_path = "../../../../../../" - template = "module " + module_name + " {\n" + system_tag = " [system] " + template = "module " + module_name + (system_tag if is_system else "" ) + " {\n" template += " export * \n" - for provider in hdr_providers: + for provider in deps: for input_file in provider.files.to_list(): + if input_file.path.endswith(".hmap"): + continue hdr = input_file template += " header \"%s%s\"\n" % (relative_path, hdr.path) template += "}\n" return template def _gen_module_map_impl(ctx): - # We figure out how to build - out = _make_module_map(ctx.attr.pod_name, ctx.attr.module_name, ctx.attr.hdrs) + out = _make_module_map(ctx.attr.pod_name, ctx.attr.module_name, ctx.attr.hdrs, ctx.attr.is_system) ctx.actions.write( content=out, output=ctx.outputs.module_map @@ -152,6 +125,7 @@ _gen_module_map = rule( "module_name": attr.string(mandatory=True), "dir_name": attr.string(mandatory=True), "module_map_name": attr.string(mandatory=True), + "is_system": attr.bool(mandatory=True), }, outputs = { "module_map": "%{dir_name}/%{module_map_name}" } ) @@ -162,37 +136,141 @@ def gen_module_map(pod_name, dep_hdrs=[], module_map_name="module.modulemap", tags=["xchammer"], + is_system=True, visibility=["//visibility:public"]): """ Generate a module map based on a list of header file groups + + pod_name: the name of the pod + dir_name: the name of the output directory, this is generally included by the compiler + module_name: the name of the module + is_system: if the module is system module or not. This is useful for + PodToBUILD to ignore all pod warnings by default """ # TODO:Modules change the name to dir_name -> pod_name + # It's also kind of weird that the rule name is changed inside of here. _gen_module_map(name = dir_name + "_module_map_file", pod_name=pod_name, dir_name=dir_name, module_name=module_name, hdrs=dep_hdrs, module_map_name=module_map_name, + is_system=is_system, visibility=visibility, tags=tags) def _gen_includes_impl(ctx): + includes = [] + includes.extend(ctx.attr.include) + for target in ctx.attr.include_files: + for f in target.files.to_list(): + includes.append(f.path) + return apple_common.new_objc_provider( - include=depset(ctx.attr.include)) + include=depset(includes)) _gen_includes = rule( implementation=_gen_includes_impl, attrs = { "include": attr.string_list(mandatory=True), + "include_files": attr.label_list(mandatory=True), } ) def gen_includes(name, - include, + include=[], + include_files=[], tags=["xchammer"], visibility=["//visibility:public"]): _gen_includes(name=name, include=include, + include_files=include_files, tags=tags, visibility=visibility) + +def _make_headermap_json(namespace, hdrs): + mappings = {} + for provider in hdrs: + for input_file in provider.files.to_list(): + hdr = input_file + namespaced_key = namespace + "/" + hdr.basename + mappings[namespaced_key] = hdr.path + mappings[hdr.basename] = hdr.path + return struct(mappings=mappings).to_json() + + +def _make_headermap_impl(ctx): + # Write a JSON file for *this* headermap + json_f = ctx.actions.declare_file(ctx.label.name + "_internal.json") + out = _make_headermap_json(ctx.attr.namespace, ctx.attr.hdrs) + ctx.actions.write( + content=out, + output=json_f + ) + + # Add a list of headermaps in JSON or hmap format + args = [ctx.outputs.headermap.path, json_f.path] + inputs = [json_f] + + # Extract propagated headermaps + for hdr_provider in ctx.attr.deps: + if not hasattr(hdr_provider, "objc"): + continue + + hdrs = hdr_provider.objc.header.to_list() + for hdr in hdrs: + if hdr.path.endswith(".hmap"): + # Add headermaps + inputs.append(hdr) + args.append(hdr.path) + + ctx.actions.run( + inputs=inputs, + arguments=args, + executable=ctx.attr.headermap_builder.files.to_list()[0], + outputs=[ctx.outputs.headermap] + ) + + objc_provider = apple_common.new_objc_provider( + header=depset([ctx.outputs.headermap]), + ) + return struct( + files=depset([ctx.outputs.headermap]), + providers=[objc_provider], + objc=objc_provider, + headers=depset([ctx.outputs.headermap]), + ) + +def headermap( + tags=["xchammer"],**kwargs): + _headermap(tags=tags, **kwargs) + +# Derive a headermap from transitive headermaps +# hdrs: a file group containing headers for this rule +# namespace: the Apple style namespace these header should be under +# deps: rules providing headers. i.e. an `objc_library` +# Note: this intententionally does not propgate the include. We don't want to +# end up with O(N) includes. +# The pattern in PodToBUILD is: +# - Add all deps to a headermap +# - Include the headermap +# TODO(Add the ability to disallow propagation of "internal" includes ) +# e.g. "MyLib.h" instead of +_headermap = rule( + implementation=_make_headermap_impl, + output_to_genfiles=True, + attrs={ + "namespace": attr.string(mandatory=True), + "hdrs": attr.label_list(mandatory=True), + "deps": attr.label_list(mandatory=False), + "headermap_builder": attr.label( + executable=True, + cfg="host", + default=Label( + "//Vendor/rules_pods/BazelExtensions:headermap_builder"), + ) + }, + outputs={"headermap": "%{name}.hmap"} +) + diff --git a/sample/UrlGet/Vendor/rules_pods/BazelExtensions/headermap_builder.py b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/headermap_builder.py new file mode 100755 index 00000000..6457cd18 --- /dev/null +++ b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/headermap_builder.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +from __future__ import print_function + +import json +import optparse +import os +import struct +import sys +import headermap_tool +import tempfile + +# The data structure that LLVM uses is { mappings: { name: path } } + +def main(): + """ Helper program for headermap rule""" + output_path = sys.argv[1] + json_path = sys.argv[2] + + if len(sys.argv) == 3: + headermap_tool.action_write("write", [json_path, output_path]) + return + + # We write an intermediate JSON file, which represents the trans hmap + fd, merge_file = tempfile.mkstemp() + with open(json_path, "r") as f: + input_data = json.load(f) + # For every additional headermap, read it in and merge + for path in sys.argv[3:]: + add_hmap = headermap_tool.HeaderMap.frompath(path) + for mapping in add_hmap.mappings: + input_data["mappings"][mapping[0]] = mapping[1] + + with open(merge_file, "w") as f: + json.dump(input_data, f, indent=2) + + headermap_tool.action_write("write", [merge_file, output_path]) + +if __name__ == '__main__': + main() diff --git a/sample/UrlGet/Vendor/rules_pods/BazelExtensions/headermap_tool.py b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/headermap_tool.py new file mode 100755 index 00000000..0b5c6017 --- /dev/null +++ b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/headermap_tool.py @@ -0,0 +1,301 @@ +#!/usr/bin/env python +# This file is part of The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See BazelExtensions/LLVM.LICENSE.TXT for details. + +from __future__ import print_function + +import json +import optparse +import os +import struct +import sys + +### + +k_header_magic_LE = 'pamh' +k_header_magic_BE = 'hmap' + +def hmap_hash(str): + """hash(str) -> int + + Apply the "well-known" headermap hash function. + """ + + return sum((ord(c.lower()) * 13 + for c in str), 0) + +class HeaderMap(object): + @staticmethod + def frompath(path): + with open(path, 'rb') as f: + magic = f.read(4) + if magic == k_header_magic_LE: + endian_code = '<' + elif magic == k_header_magic_BE: + endian_code = '>' + else: + raise SystemExit("error: %s: not a headermap" % ( + path,)) + + # Read the header information. + header_fmt = endian_code + 'HHIIII' + header_size = struct.calcsize(header_fmt) + data = f.read(header_size) + if len(data) != header_size: + raise SystemExit("error: %s: truncated headermap header" % ( + path,)) + + (version, reserved, strtable_offset, num_entries, + num_buckets, max_value_len) = struct.unpack(header_fmt, data) + + if version != 1: + raise SystemExit("error: %s: unknown headermap version: %r" % ( + path, version)) + if reserved != 0: + raise SystemExit("error: %s: invalid reserved value in header" % ( + path,)) + + # The number of buckets must be a power of two. + if num_buckets == 0 or (num_buckets & num_buckets - 1) != 0: + raise SystemExit("error: %s: invalid number of buckets" % ( + path,)) + + # Read all of the buckets. + bucket_fmt = endian_code + 'III' + bucket_size = struct.calcsize(bucket_fmt) + buckets_data = f.read(num_buckets * bucket_size) + if len(buckets_data) != num_buckets * bucket_size: + raise SystemExit("error: %s: truncated headermap buckets" % ( + path,)) + buckets = [struct.unpack(bucket_fmt, + buckets_data[i*bucket_size:(i+1)*bucket_size]) + for i in range(num_buckets)] + + # Read the string table; the format doesn't explicitly communicate the + # size of the string table (which is dumb), so assume it is the rest of + # the file. + f.seek(0, 2) + strtable_size = f.tell() - strtable_offset + f.seek(strtable_offset) + + if strtable_size == 0: + raise SystemExit("error: %s: unable to read zero-sized string table"%( + path,)) + strtable = f.read(strtable_size) + + if len(strtable) != strtable_size: + raise SystemExit("error: %s: unable to read complete string table"%( + path,)) + if strtable[-1] != '\0': + raise SystemExit("error: %s: invalid string table in headermap" % ( + path,)) + + return HeaderMap(num_entries, buckets, strtable) + + def __init__(self, num_entries, buckets, strtable): + self.num_entries = num_entries + self.buckets = buckets + self.strtable = strtable + + def get_string(self, idx): + if idx >= len(self.strtable): + raise SystemExit("error: %s: invalid string index" % ( + path,)) + end_idx = self.strtable.index('\0', idx) + return self.strtable[idx:end_idx] + + @property + def mappings(self): + for key_idx,prefix_idx,suffix_idx in self.buckets: + if key_idx == 0: + continue + yield (self.get_string(key_idx), + self.get_string(prefix_idx) + self.get_string(suffix_idx)) + +### + +def action_dump(name, args): + "dump a headermap file" + + parser = optparse.OptionParser("%%prog %s [options] " % ( + name,)) + parser.add_option("-v", "--verbose", dest="verbose", + help="show more verbose output [%default]", + action="store_true", default=False) + (opts, args) = parser.parse_args(args) + + if len(args) != 1: + parser.error("invalid number of arguments") + + path, = args + + hmap = HeaderMap.frompath(path) + + # Dump all of the buckets. + print ('Header Map: %s' % (path,)) + if opts.verbose: + print ('headermap: %r' % (path,)) + print (' num entries: %d' % (hmap.num_entries,)) + print (' num buckets: %d' % (len(hmap.buckets),)) + print (' string table size: %d' % (len(hmap.strtable),)) + for i,bucket in enumerate(hmap.buckets): + key_idx,prefix_idx,suffix_idx = bucket + + if key_idx == 0: + continue + + # Get the strings. + key = hmap.get_string(key_idx) + prefix = hmap.get_string(prefix_idx) + suffix = hmap.get_string(suffix_idx) + + print (" bucket[%d]: %r -> (%r, %r) -- %d" % ( + i, key, prefix, suffix, (hmap_hash(key) & (num_buckets - 1)))) + else: + mappings = sorted(hmap.mappings) + for key,value in mappings: + print ("%s -> %s" % (key, value)) + print () + +def next_power_of_two(value): + if value < 0: + raise ArgumentError + return 1 if value == 0 else 2**(value - 1).bit_length() + +def action_write(name, args): + "write a headermap file from a JSON definition" + + parser = optparse.OptionParser("%%prog %s [options] " % ( + name,)) + (opts, args) = parser.parse_args(args) + + if len(args) != 2: + parser.error("invalid number of arguments") + + input_path,output_path = args + + with open(input_path, "r") as f: + input_data = json.load(f) + + # Compute the headermap contents, we make a table that is 1/3 full. + mappings = input_data['mappings'] + num_buckets = next_power_of_two(len(mappings) * 3) + + table = [(0, 0, 0) + for i in range(num_buckets)] + max_value_len = 0 + strtable = "\0" + for key,value in mappings.items(): + if not isinstance(key, str): + key = key.decode('utf-8') + if not isinstance(value, str): + value = value.decode('utf-8') + max_value_len = max(max_value_len, len(value)) + + key_idx = len(strtable) + strtable += key + '\0' + prefix = os.path.dirname(value) + '/' + suffix = os.path.basename(value) + prefix_idx = len(strtable) + strtable += prefix + '\0' + suffix_idx = len(strtable) + strtable += suffix + '\0' + + hash = hmap_hash(key) + for i in range(num_buckets): + idx = (hash + i) % num_buckets + if table[idx][0] == 0: + table[idx] = (key_idx, prefix_idx, suffix_idx) + break + else: + raise RuntimeError + + endian_code = '<' + magic = k_header_magic_LE + magic_size = 4 + header_fmt = endian_code + 'HHIIII' + header_size = struct.calcsize(header_fmt) + bucket_fmt = endian_code + 'III' + bucket_size = struct.calcsize(bucket_fmt) + strtable_offset = magic_size + header_size + num_buckets * bucket_size + header = (1, 0, strtable_offset, len(mappings), + num_buckets, max_value_len) + + # Write out the headermap. + with open(output_path, 'wb') as f: + f.write(magic.encode()) + f.write(struct.pack(header_fmt, *header)) + for bucket in table: + f.write(struct.pack(bucket_fmt, *bucket)) + f.write(strtable.encode()) + +def action_tovfs(name, args): + "convert a headermap to a VFS layout" + + parser = optparse.OptionParser("%%prog %s [options] " % ( + name,)) + parser.add_option("", "--build-path", dest="build_path", + help="build path prefix", + action="store", type=str) + (opts, args) = parser.parse_args(args) + + if len(args) != 2: + parser.error("invalid number of arguments") + if opts.build_path is None: + parser.error("--build-path is required") + + input_path,output_path = args + + hmap = HeaderMap.frompath(input_path) + + # Create the table for all the objects. + vfs = {} + vfs['version'] = 0 + build_dir_contents = [] + vfs['roots'] = [{ + 'name' : opts.build_path, + 'type' : 'directory', + 'contents' : build_dir_contents }] + + # We assume we are mapping framework paths, so a key of "Foo/Bar.h" maps to + # "/Foo.framework/Headers/Bar.h". + for key,value in hmap.mappings: + # If this isn't a framework style mapping, ignore it. + components = key.split('/') + if len(components) != 2: + continue + framework_name,header_name = components + build_dir_contents.append({ + 'name' : '%s.framework/Headers/%s' % (framework_name, + header_name), + 'type' : 'file', + 'external-contents' : value }) + + with open(output_path, 'w') as f: + json.dump(vfs, f, indent=2) + +commands = dict((name[7:].replace("_","-"), f) + for name,f in locals().items() + if name.startswith('action_')) + +def usage(): + print ("Usage: %s command [options]" % ( + os.path.basename(sys.argv[0])), file=sys.stderr) + print (file=sys.stderr) + print ("Available commands:", file=sys.stderr) + cmds_width = max(map(len, commands)) + for name,func in sorted(commands.items()): + print (" %-*s - %s" % (cmds_width, name, func.__doc__), file=sys.stderr) + sys.exit(1) + +def main(): + if len(sys.argv) < 2 or sys.argv[1] not in commands: + usage() + + cmd = sys.argv[1] + commands[cmd](cmd, sys.argv[2:]) + +if __name__ == '__main__': + main() diff --git a/sample/UrlGet/Vendor/rules_pods/BazelExtensions/workspace.bzl b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/workspace.bzl index b8afc640..ef12c1d1 100644 --- a/sample/UrlGet/Vendor/rules_pods/BazelExtensions/workspace.bzl +++ b/sample/UrlGet/Vendor/rules_pods/BazelExtensions/workspace.bzl @@ -53,6 +53,10 @@ def _fetch_remote_repo(repository_ctx, repo_tool_bin, target_name, url): def _link_local_repo(repository_ctx, target_name, url): cd = _exec(repository_ctx, ["pwd"]).stdout.split("\n")[0] + if url.startswith("/"): + url = url + else: + url = cd + "/" + url from_dir = url + "/" to_dir = cd + "/" all_files = _exec(repository_ctx, ["ls", url]).stdout.split("\n") @@ -82,6 +86,7 @@ def _impl(repository_ctx): # No-op on non-mac platforms, since they won't be able to run the RepoTool binary. # While the dependencies/targets inside this pod won't exist or be available on these # platforms, you will still at least be able to run things like `bazel query //...` + print('No-op on non-macOS platform, repository ' + repository_ctx.attr.target_name + ' will be empty!') return if repository_ctx.attr.trace: @@ -154,11 +159,28 @@ def _impl(repository_ctx): # Build up the script script = "" - # For now, we curl the podspec url before the script runs if repository_ctx.attr.podspec_url: - script += "curl -O " + repository_ctx.attr.podspec_url + # For now, we curl the podspec url before the script runs + if repository_ctx.attr.podspec_url.startswith("http"): + script += "curl -O " + repository_ctx.attr.podspec_url + script += "\n" + else: + # Dump a podspec into this directory + if repository_ctx.attr.podspec_url.startswith("/"): + script += "ditto " + repository_ctx.attr.podspec_url + " ." + script += "\n" + else: + workspace_dir = _exec(repository_ctx, ["pwd"]).stdout.split("\n")[0] + script += "ditto " + workspace_dir + "/" + repository_ctx.attr.podspec_url + " ." + script += "\n" + elif repository_ctx.attr.podspec_file: + # Note that we can't re-use the podspec_url attribute for this since + # that would require being able to determine the root of the main + # workspace (to resolve relative paths) which isn't possible in this context. + if repository_ctx.attr.podspec_url: + fail("Cannot specify both podspec_url and podspec_file") + script += "ditto " + str(repository_ctx.path(repository_ctx.attr.podspec_file)) + " ." script += "\n" - if repository_ctx.attr.install_script_tpl: for sub in substitutions: install_script_tpl = install_script_tpl.replace(sub, substitutions[sub]) @@ -176,6 +198,7 @@ pod_repo_ = repository_rule( "target_name": attr.string(mandatory=True), "url": attr.string(mandatory=True), "podspec_url": attr.string(), + "podspec_file": attr.label(), "strip_prefix": attr.string(), "user_options": attr.string_list(), "repo_tools_labels": attr.label_list(), @@ -183,8 +206,8 @@ pod_repo_ = repository_rule( "install_script_tpl": attr.string(), "inhibit_warnings": attr.bool(default=False, mandatory=True), "trace": attr.bool(default=False, mandatory=True), - "enable_modules": attr.bool(default=True, mandatory=True), - "generate_module_map": attr.bool(default=True, mandatory=True), + "enable_modules": attr.bool(default=False, mandatory=True), + "generate_module_map": attr.bool(default=False, mandatory=True), "header_visibility": attr.string(), } ) @@ -211,10 +234,12 @@ def new_pod_repository(name, url: the url of this repo - podspec_url: the podspec url. By default, we will look in the root of - the repository, and read a .podspec file. This requires having - CocoaPods installed on build nodes. If a JSON podspec is provided here, - then it is not required to run CocoaPods. + podspec_url: an override podspec file. Can be either a URL or a Bazel + label. + + By default, we will look in the root of the repository, and read a .podspec file. + This requires having CocoaPods installed on build nodes. If a JSON podspec is + provided here, then it is not required to run CocoaPods. owner: the owner of this dependency @@ -268,6 +293,11 @@ def new_pod_repository(name, if generate_module_map == None: generate_module_map = enable_modules + podspec_file = None + if podspec_url and not podspec_url.startswith("http"): + podspec_file = podspec_url + podspec_url = None + tool_labels = [] for tool in repo_tools: tool_labels.append(tool) @@ -276,6 +306,7 @@ def new_pod_repository(name, target_name=name, url=url, podspec_url=podspec_url, + podspec_file=podspec_file, user_options=user_options, strip_prefix=strip_prefix, install_script_tpl=install_script,