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

Code refresh + SPM support #848

Merged
merged 15 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ playground.xcworkspace

Carthage/Build

.swift-version
.swift-version
.swiftpm/xcode
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to XLPagerTabStrip will be documented in this file.

### [9.1.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/9.1.0)

* SPM support.

### [9.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/9.0.0)

* Xcode 10.2 and Swift 5.0 support.
Expand Down
4 changes: 2 additions & 2 deletions Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = "$(SRCROOT)/Example/Example/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -580,7 +580,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = "$(SRCROOT)/Example/Example/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
6 changes: 3 additions & 3 deletions Example/Example/Helpers/PostCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import UIKit

class PostCell: UITableViewCell {

@IBOutlet weak var userImage: UIImageView!
@IBOutlet weak var postName: UILabel!
@IBOutlet weak var postText: UILabel!
@IBOutlet var userImage: UIImageView!
@IBOutlet var postName: UILabel!
@IBOutlet var postText: UILabel!
Copy link
Member

Choose a reason for hiding this comment

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

Regarding making the IBOutlets strong, could you point me to documentation stating that weak is not recommended? I read the opposite in this doc.
Also connecting an Outlet from Xcode defines it as weak by default

Copy link
Contributor Author

@Climbatize Climbatize Jul 26, 2023

Choose a reason for hiding this comment

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

I admit Apple documentation is confusing. So I remade the IBOutlets from XCode just to confirm. Also, doc specifies The strong outlets are frequently specified by framework classes (for example, UIViewController’s view outlet, or NSWindowController’s window outlet), that's why I did this change. I honestly think it's more dangerous to have it as weak than strong, as I already experienced crashes related to weak outlets in production, but I can revert if you think it's better.

Screen.Recording.2023-07-26.at.9.07.59.mov

Copy link
Member

Choose a reason for hiding this comment

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

I have seen both happen by default. For example when you build a UIViewController and want to connect its view to the controller class it defaults to strong (as that view should be strong). But for other views which are subviews of the main view it will default to weak (because subviews will be strongly referenced by their parent). This means as long as a view is in the view hierarchy it should not be deallocated and you should have no issue. However if you plan to remove the view you will have to strongly reference it if you plan to continue using it afterwards.

I think it is best to revert unless there are reproducible crashes which I would rather think could be linked to how the views are used. It might make sense to switch some of the outlets to strong if the use cases require it (rather than just switching everything)


override func awakeFromNib() {
super.awakeFromNib()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import XLPagerTabStrip

class InstagramExampleViewController: ButtonBarPagerTabStripViewController {

@IBOutlet weak var shadowView: UIView!
@IBOutlet var shadowView: UIView!
let blueInstagramColor = UIColor(red: 37/255.0, green: 111/255.0, blue: 206/255.0, alpha: 1.0)

override func viewDidLoad() {
Expand Down
2 changes: 1 addition & 1 deletion Example/Example/Spotify/SpotifyExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import XLPagerTabStrip

class SpotifyExampleViewController: ButtonBarPagerTabStripViewController {

@IBOutlet weak var shadowView: UIView!
@IBOutlet var shadowView: UIView!

let graySpotifyColor = UIColor(red: 21/255.0, green: 21/255.0, blue: 24/255.0, alpha: 1.0)
let darkGraySpotifyColor = UIColor(red: 19/255.0, green: 20/255.0, blue: 20/255.0, alpha: 1.0)
Expand Down
2 changes: 1 addition & 1 deletion Example/Example/Youtube/YoutubeIconCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ import UIKit

class YoutubeIconCell: UICollectionViewCell {

@IBOutlet weak var iconImage: UIImageView!
@IBOutlet var iconImage: UIImageView!

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import UIKit

class YoutubeIconWithLabelCell: UICollectionViewCell {

@IBOutlet weak var iconImage: UIImageView!
@IBOutlet weak var iconLabel: UILabel!
@IBOutlet var iconImage: UIImageView!
@IBOutlet var iconLabel: UILabel!

}
41 changes: 21 additions & 20 deletions Sources/FXPageControl.h → ObjC/FXPageControl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FXPageControl.h
//
// Version 1.4
// Version 1.5
Copy link
Member

Choose a reason for hiding this comment

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

Moving this file out of the Sources folder will make it not be included in the library when installed through Cocoapods and it is also not marked as dependency. Please either revert or add FXPageControl as dependency in the podspec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a big mistake from my side! I ran a pod spec lint XLPagerTabStrip.podspec instead of pod lib lint XLPagerTabStrip.podspec. Fix is on the way

//
// Created by Nick Lockwood on 07/01/2010.
// Copyright 2010 Charcoal Design
Expand Down Expand Up @@ -31,18 +31,12 @@
//


#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-missing-property-synthesis"
#import <UIKit/UIKit.h>


#import <Availability.h>
#undef weak_delegate
#if __has_feature(objc_arc_weak)
#define weak_delegate weak
#else
#define weak_delegate unsafe_unretained
#endif
NS_ASSUME_NONNULL_BEGIN


extern const CGPathRef FXPageControlDotShapeCircle;
Expand All @@ -59,7 +53,7 @@ IB_DESIGNABLE @interface FXPageControl : UIControl
- (CGSize)sizeForNumberOfPages:(NSInteger)pageCount;
- (void)updateCurrentPageDisplay;

@property (nonatomic, weak_delegate) IBOutlet id <FXPageControlDelegate> delegate;
@property (nonatomic, weak) IBOutlet id <FXPageControlDelegate> delegate;

@property (nonatomic, assign) IBInspectable NSInteger currentPage;
@property (nonatomic, assign) IBInspectable NSInteger numberOfPages;
Expand All @@ -68,21 +62,25 @@ IB_DESIGNABLE @interface FXPageControl : UIControl
@property (nonatomic, assign, getter = isWrapEnabled) IBInspectable BOOL wrapEnabled;
@property (nonatomic, assign, getter = isVertical) IBInspectable BOOL vertical;

@property (nonatomic, strong) IBInspectable UIImage *dotImage;
@property (nonatomic, assign) IBInspectable CGPathRef dotShape;
@property (nonatomic, assign) IBInspectable CGFloat dotSize;
@property (nonatomic, strong) IBInspectable UIColor *dotColor;
@property (nonatomic, strong) IBInspectable UIColor *dotShadowColor;
@property (nonatomic, assign) IBInspectable CGFloat dotShadowBlur;
@property (nonatomic, assign) IBInspectable CGSize dotShadowOffset;
@property (nonatomic, assign) IBInspectable CGFloat dotBorderWidth;
@property (nonatomic, strong, nullable) IBInspectable UIImage *dotImage;
@property (nonatomic, strong, nullable) IBInspectable UIColor *dotColor;
@property (nonatomic, strong, nullable) IBInspectable UIColor *dotShadowColor;
@property (nonatomic, strong, nullable) IBInspectable UIColor *dotBorderColor;

@property (nonatomic, strong) IBInspectable UIImage *selectedDotImage;
@property (nonatomic, assign) IBInspectable CGPathRef selectedDotShape;
@property (nonatomic, assign) IBInspectable CGFloat selectedDotSize;
@property (nonatomic, strong) IBInspectable UIColor *selectedDotColor;
@property (nonatomic, strong) IBInspectable UIColor *selectedDotShadowColor;
@property (nonatomic, assign) IBInspectable CGFloat selectedDotShadowBlur;
@property (nonatomic, assign) IBInspectable CGSize selectedDotShadowOffset;
@property (nonatomic, assign) IBInspectable CGFloat selectedDotBorderWidth;
@property (nonatomic, strong, nullable) IBInspectable UIImage *selectedDotImage;
@property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotColor;
@property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotShadowColor;
@property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotBorderColor;

@property (nonatomic, assign) IBInspectable CGFloat dotSpacing;

Expand All @@ -92,15 +90,18 @@ IB_DESIGNABLE @interface FXPageControl : UIControl
@protocol FXPageControlDelegate <NSObject>
@optional

- (UIImage *)pageControl:(FXPageControl *)pageControl imageForDotAtIndex:(NSInteger)index;
- (nullable UIImage *)pageControl:(FXPageControl *)pageControl imageForDotAtIndex:(NSInteger)index;
- (CGPathRef)pageControl:(FXPageControl *)pageControl shapeForDotAtIndex:(NSInteger)index;
- (UIColor *)pageControl:(FXPageControl *)pageControl colorForDotAtIndex:(NSInteger)index;

- (UIImage *)pageControl:(FXPageControl *)pageControl selectedImageForDotAtIndex:(NSInteger)index;
- (nullable UIImage *)pageControl:(FXPageControl *)pageControl selectedImageForDotAtIndex:(NSInteger)index;
- (CGPathRef)pageControl:(FXPageControl *)pageControl selectedShapeForDotAtIndex:(NSInteger)index;
- (UIColor *)pageControl:(FXPageControl *)pageControl selectedColorForDotAtIndex:(NSInteger)index;

@end


#pragma GCC diagnostic pop
NS_ASSUME_NONNULL_END


#pragma clang diagnostic pop
Loading