Skip to content

Commit 810f1d7

Browse files
committed
分离出定位功能
使用完整功能: pod 'TZImagePickerController' 不包含定位代码: pod 'TZImagePickerController/Basic'
1 parent 36cce2b commit 810f1d7

File tree

8 files changed

+35
-16
lines changed

8 files changed

+35
-16
lines changed

TZImagePickerController.podspec

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ Pod::Spec.new do |s|
99
s.ios.deployment_target = "8.0"
1010
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "3.8.1" }
1111
s.requires_arc = true
12-
s.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}"
13-
s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"
12+
13+
s.subspec 'Basic' do |b|
14+
b.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}"
15+
b.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"
16+
end
17+
18+
s.subspec 'Location' do |l|
19+
l.source_files = 'TZImagePickerController/Location/*.{h,m}'
20+
end
21+
1422
s.frameworks = "Photos", "PhotosUI"
1523
end

TZImagePickerController.xcodeproj/project.pbxproj

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
901CC3FC21CB758500C55443 /* TZImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 901CC3F921CB757500C55443 /* TZImageRequestOperation.m */; };
4444
901F2295215CABD600F604ED /* FLAnimatedImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 901F2291215CABD600F604ED /* FLAnimatedImage.m */; };
4545
901F2296215CABD600F604ED /* FLAnimatedImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 901F2293215CABD600F604ED /* FLAnimatedImageView.m */; };
46-
902938D81EE2D02C000F2F8F /* TZLocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 902938D71EE2D02C000F2F8F /* TZLocationManager.m */; };
4746
9038D5911C3974F0007DE549 /* TZTestCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9038D5901C3974F0007DE549 /* TZTestCell.m */; };
4847
903996931F447604005E77C2 /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 903996921F447604005E77C2 /* Photos.framework */; };
4948
90A74B85203287C200D84C2A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 90A74B83203287C200D84C2A /* Localizable.strings */; };
@@ -60,7 +59,6 @@
6059
9F763A601FA072E500D9E526 /* TZProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DD0502A1DF659ED0057C78D /* TZProgressView.m */; };
6160
9F763A621FA072E500D9E526 /* TZImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 90CE84AD1C3A89EF003D0779 /* TZImageManager.m */; };
6261
9F763A641FA072E500D9E526 /* TZImageCropManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DC84D091DF5358500A107A9 /* TZImageCropManager.m */; };
63-
9F763A661FA072E500D9E526 /* TZLocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 902938D71EE2D02C000F2F8F /* TZLocationManager.m */; };
6462
9F763A6A1FA072E500D9E526 /* NSBundle+TZImagePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D5358CC1D64600F00928CC6 /* NSBundle+TZImagePicker.m */; };
6563
9F763A6B1FA0731E00D9E526 /* TZImagePickerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 900EEFF61C2BBF9500EA709B /* TZImagePickerController.h */; settings = {ATTRIBUTES = (Public, ); }; };
6664
9F763A6C1FA0733100D9E526 /* TZAssetModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 900EF00D1C2C0B1100EA709B /* TZAssetModel.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -75,7 +73,6 @@
7573
9F763A751FA0741D00D9E526 /* TZProgressView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DD050291DF659ED0057C78D /* TZProgressView.h */; };
7674
9F763A761FA0741D00D9E526 /* TZImageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 90CE84AC1C3A89EF003D0779 /* TZImageManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
7775
9F763A771FA0741D00D9E526 /* TZImageCropManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DC84D081DF5358500A107A9 /* TZImageCropManager.h */; };
78-
9F763A781FA0741D00D9E526 /* TZLocationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 902938D61EE2D02C000F2F8F /* TZLocationManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
7976
B606A9C4265FD53200F5493E /* TZVideoCropController.m in Sources */ = {isa = PBXBuildFile; fileRef = B606A9C2265FD53200F5493E /* TZVideoCropController.m */; };
8077
B606A9CE265FD5F700F5493E /* TZVideoPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 90CE84B61C3BABB6003D0779 /* TZVideoPlayerController.m */; };
8178
B662C36F2662914D006A672A /* TZVideoEditedPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B662C36E2662914D006A672A /* TZVideoEditedPreviewController.m */; };
@@ -180,8 +177,6 @@
180177
901F2291215CABD600F604ED /* FLAnimatedImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLAnimatedImage.m; sourceTree = "<group>"; };
181178
901F2292215CABD600F604ED /* FLAnimatedImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLAnimatedImageView.h; sourceTree = "<group>"; };
182179
901F2293215CABD600F604ED /* FLAnimatedImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLAnimatedImageView.m; sourceTree = "<group>"; };
183-
902938D61EE2D02C000F2F8F /* TZLocationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZLocationManager.h; sourceTree = "<group>"; };
184-
902938D71EE2D02C000F2F8F /* TZLocationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZLocationManager.m; sourceTree = "<group>"; };
185180
9038D58F1C3974F0007DE549 /* TZTestCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZTestCell.h; sourceTree = "<group>"; };
186181
9038D5901C3974F0007DE549 /* TZTestCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZTestCell.m; sourceTree = "<group>"; };
187182
903996921F447604005E77C2 /* Photos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Photos.framework; path = System/Library/Frameworks/Photos.framework; sourceTree = SDKROOT; };
@@ -238,6 +233,13 @@
238233
/* End PBXFrameworksBuildPhase section */
239234

240235
/* Begin PBXGroup section */
236+
5B7A0D4F288691E7002B2603 /* Location */ = {
237+
isa = PBXGroup;
238+
children = (
239+
);
240+
path = Location;
241+
sourceTree = "<group>";
242+
};
241243
6DC358641CC8BAE300898D29 /* Resources */ = {
242244
isa = PBXGroup;
243245
children = (
@@ -272,6 +274,7 @@
272274
900E657E1C2BB8D5003D9A9E /* TZImagePickerController */ = {
273275
isa = PBXGroup;
274276
children = (
277+
5B7A0D4F288691E7002B2603 /* Location */,
275278
901F228F215CABD600F604ED /* FLAnimatedImage */,
276279
900EEFF51C2BBF7600EA709B /* TZImagePickerController */,
277280
900E65821C2BB8D5003D9A9E /* AppDelegate.h */,
@@ -355,8 +358,6 @@
355358
901CC3F921CB757500C55443 /* TZImageRequestOperation.m */,
356359
6DC84D081DF5358500A107A9 /* TZImageCropManager.h */,
357360
6DC84D091DF5358500A107A9 /* TZImageCropManager.m */,
358-
902938D61EE2D02C000F2F8F /* TZLocationManager.h */,
359-
902938D71EE2D02C000F2F8F /* TZLocationManager.m */,
360361
9005E2B2257A462E002A8682 /* UIView+TZLayout.h */,
361362
9005E2B1257A462E002A8682 /* UIView+TZLayout.m */,
362363
6D5358CB1D64600F00928CC6 /* NSBundle+TZImagePicker.h */,
@@ -420,7 +421,6 @@
420421
9F763A741FA0741D00D9E526 /* TZGifPhotoPreviewController.h in Headers */,
421422
9005E2B5257A462E002A8682 /* UIView+TZLayout.h in Headers */,
422423
9F763A761FA0741D00D9E526 /* TZImageManager.h in Headers */,
423-
9F763A781FA0741D00D9E526 /* TZLocationManager.h in Headers */,
424424
9F763A711FA0741D00D9E526 /* TZPhotoPreviewController.h in Headers */,
425425
9F763A721FA0741D00D9E526 /* TZPhotoPreviewCell.h in Headers */,
426426
9F763A701FA0741D00D9E526 /* TZAssetCell.h in Headers */,
@@ -627,7 +627,6 @@
627627
901CC3FC21CB758500C55443 /* TZImageRequestOperation.m in Sources */,
628628
6D5358CD1D64600F00928CC6 /* NSBundle+TZImagePicker.m in Sources */,
629629
900EEFF81C2BBF9500EA709B /* TZImagePickerController.m in Sources */,
630-
902938D81EE2D02C000F2F8F /* TZLocationManager.m in Sources */,
631630
6DC84D0A1DF5358500A107A9 /* TZImageCropManager.m in Sources */,
632631
);
633632
runOnlyForDeploymentPostprocessing = 0;
@@ -668,7 +667,6 @@
668667
9F763A601FA072E500D9E526 /* TZProgressView.m in Sources */,
669668
9F763A621FA072E500D9E526 /* TZImageManager.m in Sources */,
670669
9F763A641FA072E500D9E526 /* TZImageCropManager.m in Sources */,
671-
9F763A661FA072E500D9E526 /* TZLocationManager.m in Sources */,
672670
9F763A6A1FA072E500D9E526 /* NSBundle+TZImagePicker.m in Sources */,
673671
);
674672
runOnlyForDeploymentPostprocessing = 0;

TZImagePickerController/TZImagePickerController/TZImagePickerController.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@
2222
#import "TZImageManager.h"
2323
#import "TZVideoPlayerController.h"
2424
#import "TZGifPhotoPreviewController.h"
25-
#import "TZLocationManager.h"
2625
#import "TZPhotoPreviewController.h"
2726
#import "TZPhotoPreviewCell.h"
2827

28+
#if __has_include("TZLocationManager.h")
29+
#define TZ_HAVE_LOCATION_CODE 1
30+
#import "TZLocationManager.h"
31+
#else
32+
#undef TZ_HAVE_LOCATION_CODE
33+
#endif
34+
2935
#define CURRENT_SYSTEM_VERSION [[UIDevice currentDevice] systemVersion]
3036
#define SYSTEM_VERSION_GREATER_THAN_15 ([CURRENT_SYSTEM_VERSION floatValue] >= 15.0)
3137

@@ -112,7 +118,10 @@
112118
/// Default is YES, if set NO, user can't take picture.
113119
/// 默认为YES,如果设置为NO, 用户将不能拍摄照片
114120
@property (nonatomic, assign) BOOL allowTakePicture;
121+
122+
#ifdef TZ_HAVE_LOCATION_CODE
115123
@property (nonatomic, assign) BOOL allowCameraLocation;
124+
#endif
116125

117126
/// Default is YES, if set NO, user can't take video.
118127
/// 默认为YES,如果设置为NO, 用户将不能拍摄视频

TZImagePickerController/TZImagePickerController/TZImagePickerController.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ - (void)configDefaultSetting {
303303
self.needFixComposition = NO;
304304
self.statusBarStyle = UIStatusBarStyleLightContent;
305305
self.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
306+
#ifdef TZ_HAVE_LOCATION_CODE
306307
self.allowCameraLocation = YES;
308+
#endif
307309
self.presetName = AVAssetExportPresetMediumQuality;
308310
self.maxCropVideoDuration = 30;
309311

TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#import "TZImageManager.h"
1616
#import "TZVideoPlayerController.h"
1717
#import "TZGifPhotoPreviewController.h"
18-
#import "TZLocationManager.h"
1918
#import <MobileCoreServices/MobileCoreServices.h>
2019
#import "TZImageRequestOperation.h"
2120
#import "TZAuthLimitedFooterTipView.h"
@@ -826,6 +825,7 @@ - (void)addMorePhoto {
826825
- (void)pushImagePickerController {
827826
// 提前定位
828827
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
828+
#ifdef TZ_HAVE_LOCATION_CODE
829829
if (tzImagePickerVc.allowCameraLocation) {
830830
__weak typeof(self) weakSelf = self;
831831
[[TZLocationManager manager] startLocationWithSuccessBlock:^(NSArray<CLLocation *> *locations) {
@@ -836,6 +836,7 @@ - (void)pushImagePickerController {
836836
strongSelf.location = nil;
837837
}];
838838
}
839+
#endif
839840

840841
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
841842
if ([UIImagePickerController isSourceTypeAvailable: sourceType]) {

TZImagePickerController/ViewController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#import "TZVideoPlayerController.h"
1717
#import "TZPhotoPreviewController.h"
1818
#import "TZGifPhotoPreviewController.h"
19-
#import "TZLocationManager.h"
2019
#import "TZAssetCell.h"
2120
#import <MobileCoreServices/MobileCoreServices.h>
2221
#import "FLAnimatedImage.h"
@@ -481,6 +480,7 @@ - (void)takePhoto {
481480

482481
// 调用相机
483482
- (void)pushImagePickerController {
483+
#ifdef TZ_HAVE_LOCATION_CODE
484484
// 提前定位
485485
__weak typeof(self) weakSelf = self;
486486
[[TZLocationManager manager] startLocationWithSuccessBlock:^(NSArray<CLLocation *> *locations) {
@@ -490,7 +490,8 @@ - (void)pushImagePickerController {
490490
__strong typeof(weakSelf) strongSelf = weakSelf;
491491
strongSelf.location = nil;
492492
}];
493-
493+
#endif
494+
494495
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
495496
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
496497
self.imagePickerVc.sourceType = sourceType;

0 commit comments

Comments
 (0)