Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support swift package manager #338

Merged
merged 17 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## `develop`

Changes for users of the library currently on `develop`:
- fixed a NaN when setting `zoomScale` in `NYTScalingImageView` when `ANIMATED_GIF_SUPPORT=1`
- support Swift Package Manager (thanks @mattpolzin!)
- fixed a NaN when setting `zoomScale` in `NYTScalingImageView` when `ANIMATED_GIF_SUPPORT=1`

## [5.0.5](https://github.com/nytimes/NYTPhotoViewer/releases/tag/5.0.5)

Expand Down
42 changes: 26 additions & 16 deletions Examples/NYTPhotoViewer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
CD7B24632576A7DE00290A00 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD7B24422576A56A00290A00 /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
D623A69F259D4D3E00FA047F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 111083FD1C875B4F00699670 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 111084691C876A2B00699670;
remoteInfo = Example;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
1110849C1C876DDE00699670 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
Expand Down Expand Up @@ -93,25 +103,17 @@
11FBDADC1C877BD600018169 /* Example-Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example-Swift.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1AB2A8221AD0A76EF91690C1 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1AFC4D311FE01EFA00FDF949 /* NYTPhotoViewerSinglePhotoDataSourceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NYTPhotoViewerSinglePhotoDataSourceTests.m; sourceTree = "<group>"; };
201BF2BF68388BE5A1B5EEBF /* Pods-NYTPhotoViewerCore.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NYTPhotoViewerCore.release.xcconfig"; path = "Target Support Files/Pods-NYTPhotoViewerCore/Pods-NYTPhotoViewerCore.release.xcconfig"; sourceTree = "<group>"; };
23C5E8A78D476C4BCB3F3AA8 /* Pods-NYTPhotoViewer-NYTPhotoViewerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NYTPhotoViewer-NYTPhotoViewerTests.release.xcconfig"; path = "Target Support Files/Pods-NYTPhotoViewer-NYTPhotoViewerTests/Pods-NYTPhotoViewer-NYTPhotoViewerTests.release.xcconfig"; sourceTree = "<group>"; };
27DCB5B006C2124393100C4B /* Pods-Test1.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Test1.release.xcconfig"; path = "Target Support Files/Pods-Test1/Pods-Test1.release.xcconfig"; sourceTree = "<group>"; };
2F254884E30D7F66912DEC4D /* Pods-NYTPhotoViewer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NYTPhotoViewer.debug.xcconfig"; path = "Target Support Files/Pods-NYTPhotoViewer/Pods-NYTPhotoViewer.debug.xcconfig"; sourceTree = "<group>"; };
450471655D8BF1D99A756EEC /* Pods_NYTPhotoViewer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NYTPhotoViewer.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4C44DB22C9C84667B2DF2E01 /* Pods_NYTPhotoViewerCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NYTPhotoViewerCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
54C29C2860B777AA3F96E298 /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = "<group>"; };
5B17B0B47082173CD37D7087 /* Pods-NYTPhotoViewerCore.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NYTPhotoViewerCore.debug.xcconfig"; path = "Target Support Files/Pods-NYTPhotoViewerCore/Pods-NYTPhotoViewerCore.debug.xcconfig"; sourceTree = "<group>"; };
5CF82EC06EA14A76921C747B /* Pods-Test1.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Test1.debug.xcconfig"; path = "Target Support Files/Pods-Test1/Pods-Test1.debug.xcconfig"; sourceTree = "<group>"; };
79EE98D2AFED2473F0D152EA /* Pods-UnitTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTest.debug.xcconfig"; path = "Target Support Files/Pods-UnitTest/Pods-UnitTest.debug.xcconfig"; sourceTree = "<group>"; };
887B54E2F5A2B29979C1750B /* Pods_UnitTest.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_UnitTest.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CD7B24412576A56A00290A00 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
CD7B24422576A56A00290A00 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
CD7B24482576A58200290A00 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
CF0E881D90E20E65A43C6398 /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
D7D5ED9071C683B8C95D634A /* Pods-Example-Swift.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example-Swift.debug.xcconfig"; path = "Target Support Files/Pods-Example-Swift/Pods-Example-Swift.debug.xcconfig"; sourceTree = "<group>"; };
E95307A1443F61BFE500D1A3 /* Pods-NYTPhotoViewer-NYTPhotoViewerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NYTPhotoViewer-NYTPhotoViewerTests.debug.xcconfig"; path = "Target Support Files/Pods-NYTPhotoViewer-NYTPhotoViewerTests/Pods-NYTPhotoViewer-NYTPhotoViewerTests.debug.xcconfig"; sourceTree = "<group>"; };
EC3AE0BFDE41DA38639FC422 /* Pods_Example_Swift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example_Swift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FF29D7E46E96A5A3774A556E /* Pods-NYTPhotoViewer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NYTPhotoViewer.release.xcconfig"; path = "Target Support Files/Pods-NYTPhotoViewer/Pods-NYTPhotoViewer.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -242,14 +244,6 @@
CF0E881D90E20E65A43C6398 /* Pods-Example.release.xcconfig */,
D7D5ED9071C683B8C95D634A /* Pods-Example-Swift.debug.xcconfig */,
0EAFCA0D14C64E7A15FFE321 /* Pods-Example-Swift.release.xcconfig */,
2F254884E30D7F66912DEC4D /* Pods-NYTPhotoViewer.debug.xcconfig */,
FF29D7E46E96A5A3774A556E /* Pods-NYTPhotoViewer.release.xcconfig */,
E95307A1443F61BFE500D1A3 /* Pods-NYTPhotoViewer-NYTPhotoViewerTests.debug.xcconfig */,
23C5E8A78D476C4BCB3F3AA8 /* Pods-NYTPhotoViewer-NYTPhotoViewerTests.release.xcconfig */,
5B17B0B47082173CD37D7087 /* Pods-NYTPhotoViewerCore.debug.xcconfig */,
201BF2BF68388BE5A1B5EEBF /* Pods-NYTPhotoViewerCore.release.xcconfig */,
5CF82EC06EA14A76921C747B /* Pods-Test1.debug.xcconfig */,
27DCB5B006C2124393100C4B /* Pods-Test1.release.xcconfig */,
79EE98D2AFED2473F0D152EA /* Pods-UnitTest.debug.xcconfig */,
0D4B65DD93482E62FA8A32D0 /* Pods-UnitTest.release.xcconfig */,
);
Expand All @@ -272,6 +266,7 @@
buildRules = (
);
dependencies = (
D623A6A0259D4D3E00FA047F /* PBXTargetDependency */,
);
name = UnitTest;
productName = Test1;
Expand Down Expand Up @@ -332,6 +327,7 @@
CreatedOnToolsVersion = 12.2;
DevelopmentTeam = 9HE4ZM4NVA;
ProvisioningStyle = Automatic;
TestTargetID = 111084691C876A2B00699670;
};
111084691C876A2B00699670 = {
CreatedOnToolsVersion = 7.2.1;
Expand Down Expand Up @@ -561,6 +557,14 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
D623A6A0259D4D3E00FA047F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 111084691C876A2B00699670 /* Example */;
targetProxy = D623A69F259D4D3E00FA047F /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
07B3E753257189EE00387CDF /* Debug */ = {
isa = XCBuildConfiguration;
Expand All @@ -575,6 +579,10 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 9HE4ZM4NVA;
GCC_C_LANGUAGE_STANDARD = gnu11;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Examples/Sources/ObjC,
);
INFOPLIST_FILE = ../UnitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand All @@ -583,6 +591,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.nytimes.photoviewer.example.tests;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Debug;
};
Expand All @@ -606,6 +615,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.nytimes.photoviewer.example.tests;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Examples/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ EXTERNAL SOURCES:
:path: ".."

SPEC CHECKSUMS:
NYTPhotoViewer: c5f145fb5e047837c8766e02a45b549fb4843c9b
NYTPhotoViewer: 2ef4018c309d04b010f492b42f6a2e517071895a
OCMock: 75fbeaa46a9b11f8c182bbb1d1f7e9a35ccc9955
PINCache: 7a8fc1a691173d21dbddbf86cd515de6efa55086
PINOperation: 00c935935f1e8cf0d1e2d6b542e75b88fc3e5e20
Expand Down
2 changes: 1 addition & 1 deletion NYTPhotoViewer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.requires_arc = true

s.subspec 'Core' do |ss|
ss.ios.resource_bundle = { s.name => ['NYTPhotoViewer/NYTPhotoViewer.bundle/*'] }
ss.ios.resource_bundle = { s.name => ['NYTPhotoViewer/Media.xcassets'] }
ss.source_files = 'NYTPhotoViewer/**/*.{h,m,swift}'
ss.frameworks = 'UIKit', 'Foundation'
end
Expand Down
6 changes: 6 additions & 0 deletions NYTPhotoViewer/Media.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "NYTPhotoViewerCloseButtonX.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "NYTPhotoViewerCloseButtonXLandscape.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
File renamed without changes
File renamed without changes
3 changes: 3 additions & 0 deletions NYTPhotoViewer/Resource Loading/NSBundle+NYTPhotoViewer.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
@implementation NSBundle (NYTPhotoViewer)

+ (instancetype)nyt_photoViewerResourceBundle {
#if SWIFT_PACKAGE
return SWIFTPM_MODULE_BUNDLE;
#endif
static NSBundle *resourceBundle = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the name used below still accurate given the change from NYTPhotoView.bundle to Media.xcasssets in the podspec?

Copy link
Contributor Author

@mr-fixit mr-fixit Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, because the contents of Media.xcassets are copied into NYTPhotoViewer.bundle/Assets.car

tested with BP:

po [UIImage imageNamed:@"NYTPhotoViewerCloseButtonX" inBundle:resourceBundle compatibleWithTraitCollection:nil]
<UIImage:0x600002a24c60 named(org.cocoapods.NYTPhotoViewer: NYTPhotoViewerCloseButtonX) {15, 15}>

tested visually:

Copy link
Contributor Author

@mr-fixit mr-fixit Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test with actool:
(ha, i wish i could figure out how to get actool to list or extract contents!)

but we can see the names in the file...

$ strings  $B/Assets.car | grep -i closebutton 
NYTPhotoViewerCloseButtonX
NYTPhotoViewerCloseButtonXLandscape
[email protected]
[email protected]

Expand Down
File renamed without changes.
29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version:5.3
import PackageDescription

let package = Package(
name: "NYTPhotoViewer",
platforms: [
.iOS(.v9)
],
products: [
.library(
name: "NYTPhotoViewer",
targets: ["NYTPhotoViewer"]),
],
dependencies: [
.package(url: "https://github.com/pinterest/PINRemoteImage.git", from: "3.0.1")
],
targets: [
.target(
name: "NYTPhotoViewer",
dependencies: ["PINRemoteImage"],
path: "NYTPhotoViewer",
exclude: [
"Info.plist"
mr-fixit marked this conversation as resolved.
Show resolved Hide resolved
],
cSettings: [
.headerSearchPath("./include"),
mr-fixit marked this conversation as resolved.
Show resolved Hide resolved
]),
]
)
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ Clone this locally, then in your local workspace of the `NYTPhotoViewer` repo, r

## Installation

### Swift Package Manager

NYTPhotoViewer may be installed via SPM, by pointing at this repo's URL and.. (more TK)
mr-fixit marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"more TK"


### Cocoapods

NYTPhotoViewer is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your `Podfile`:

```ruby
pod 'NYTPhotoViewer'
```

### Carthage

NYTPhotoViewer may be installed via [Carthage](https://github.com/Carthage/Carthage). To install it, simply add the following line to your `Cartfile`:
Expand All @@ -35,14 +47,6 @@ Then, following the instructions for [integrating Carthage frameworks into your

If you don't want support for animated GIFs, you may instead link against only the `NYTPhotoViewerCore` framework.

### Cocoapods

NYTPhotoViewer is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your `Podfile`:

```
pod 'NYTPhotoViewer'
```

## Requirements

This library requires a deployment target of iOS 9.0 or greater.
Expand Down