From 86d98ce2a16401428572228c20de6c2cd0f4014b Mon Sep 17 00:00:00 2001 From: Oliver Drobnik Date: Tue, 7 Jul 2015 12:09:55 +0200 Subject: [PATCH 1/6] Fixed incorrect public header path --- DTLoupe.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DTLoupe.xcodeproj/project.pbxproj b/DTLoupe.xcodeproj/project.pbxproj index d5a0949..3ff5205 100644 --- a/DTLoupe.xcodeproj/project.pbxproj +++ b/DTLoupe.xcodeproj/project.pbxproj @@ -582,7 +582,7 @@ ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = DTLoupe; - PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupeView; + PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupe; SKIP_INSTALL = YES; }; name = Debug; @@ -605,7 +605,7 @@ ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = DTLoupe; - PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupeView; + PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupe; SKIP_INSTALL = YES; VALIDATE_PRODUCT = YES; }; From f494d7714d0bb7761d022868b46896ea4737b8fa Mon Sep 17 00:00:00 2001 From: Oliver Drobnik Date: Thu, 23 Jul 2015 10:34:05 +0200 Subject: [PATCH 2/6] Adjusted build settings for Coverage, should that ever be needed --- DTLoupe.xcodeproj/project.pbxproj | 103 +++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 9 deletions(-) diff --git a/DTLoupe.xcodeproj/project.pbxproj b/DTLoupe.xcodeproj/project.pbxproj index 3ff5205..c3f2926 100644 --- a/DTLoupe.xcodeproj/project.pbxproj +++ b/DTLoupe.xcodeproj/project.pbxproj @@ -504,7 +504,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = DEBUG; + GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -559,7 +559,41 @@ }; name = Release; }; - A7D8FEED14E1693300BF8CCD /* Debug */ = { + A79C2FE41B60DC7700E5491A /* Coverage */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_GENERATE_TEST_COVERAGE_FILES = YES; + GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = "COVERAGE=1"; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Coverage; + }; + A79C2FE51B60DC7700E5491A /* Coverage */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Demo/Demo-Prefix.pch"; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + INFOPLIST_FILE = "Demo/Demo-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Coverage; + }; + A79C2FE61B60DC7700E5491A /* Coverage */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -573,10 +607,60 @@ GCC_DYNAMIC_NO_PIC = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Core/DTLoupe-Prefix.pch"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", + GCC_THUMB_SUPPORT = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = DTLoupe; + PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupe; + SKIP_INSTALL = YES; + }; + name = Coverage; + }; + A79C2FE71B60DC7700E5491A /* Coverage */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Resource Bundle/Resource Bundle-Prefix.pch"; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + INFOPLIST_FILE = "Core/Resources/ResourceBundle-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + MACOSX_DEPLOYMENT_TARGET = 10.7; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = DTLoupe; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + WRAPPER_EXTENSION = bundle; + }; + name = Coverage; + }; + A79C2FE81B60DC7700E5491A /* Coverage */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Coverage; + }; + A7D8FEED14E1693300BF8CCD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = ( + "$(ARCHS_STANDARD)", + armv7s, ); + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = NO; + DSTROOT = /tmp/Static_Library.dst; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Core/DTLoupe-Prefix.pch"; GCC_THUMB_SUPPORT = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; ONLY_ACTIVE_ARCH = NO; @@ -621,10 +705,6 @@ GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Resource Bundle/Resource Bundle-Prefix.pch"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; INFOPLIST_FILE = "Core/Resources/ResourceBundle-Info.plist"; @@ -681,6 +761,7 @@ isa = XCConfigurationList; buildConfigurations = ( 0F01D8B113B248CB00419BD7 /* Debug */, + A79C2FE41B60DC7700E5491A /* Coverage */, 0F01D8B213B248CB00419BD7 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -690,6 +771,7 @@ isa = XCConfigurationList; buildConfigurations = ( 0F01D8B413B248CB00419BD7 /* Debug */, + A79C2FE51B60DC7700E5491A /* Coverage */, 0F01D8B513B248CB00419BD7 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -699,6 +781,7 @@ isa = XCConfigurationList; buildConfigurations = ( A7D8FEED14E1693300BF8CCD /* Debug */, + A79C2FE61B60DC7700E5491A /* Coverage */, A7D8FEEE14E1693300BF8CCD /* Release */, ); defaultConfigurationIsVisible = 0; @@ -708,6 +791,7 @@ isa = XCConfigurationList; buildConfigurations = ( A7D8FF6514E17A6600BF8CCD /* Debug */, + A79C2FE71B60DC7700E5491A /* Coverage */, A7D8FF6614E17A6600BF8CCD /* Release */, ); defaultConfigurationIsVisible = 0; @@ -717,6 +801,7 @@ isa = XCConfigurationList; buildConfigurations = ( A7DF6EF0173A9646004F623B /* Debug */, + A79C2FE81B60DC7700E5491A /* Coverage */, A7DF6EF1173A9646004F623B /* Release */, ); defaultConfigurationIsVisible = 0; From a73644f16ea3e40c68f8a6531d01b6fef6821a0d Mon Sep 17 00:00:00 2001 From: Oliver Drobnik Date: Thu, 23 Jul 2015 11:22:40 +0200 Subject: [PATCH 3/6] Try better public header dir --- DTLoupe.xcodeproj/project.pbxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DTLoupe.xcodeproj/project.pbxproj b/DTLoupe.xcodeproj/project.pbxproj index c3f2926..45e9314 100644 --- a/DTLoupe.xcodeproj/project.pbxproj +++ b/DTLoupe.xcodeproj/project.pbxproj @@ -511,6 +511,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 7.0; ONLY_ACTIVE_ARCH = YES; + PUBLIC_HEADERS_FOLDER_PATH = DTLoupe; SDKROOT = iphoneos; }; name = Debug; @@ -525,6 +526,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 7.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + PUBLIC_HEADERS_FOLDER_PATH = DTLoupe; SDKROOT = iphoneos; }; name = Release; @@ -574,6 +576,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 7.0; ONLY_ACTIVE_ARCH = YES; + PUBLIC_HEADERS_FOLDER_PATH = DTLoupe; SDKROOT = iphoneos; }; name = Coverage; @@ -612,7 +615,6 @@ ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = DTLoupe; - PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupe; SKIP_INSTALL = YES; }; name = Coverage; @@ -666,7 +668,6 @@ ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = DTLoupe; - PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupe; SKIP_INSTALL = YES; }; name = Debug; @@ -689,7 +690,6 @@ ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = DTLoupe; - PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupe; SKIP_INSTALL = YES; VALIDATE_PRODUCT = YES; }; From 5463f8e01d37c348d042b04ee60a0249230aa63c Mon Sep 17 00:00:00 2001 From: Oliver Drobnik Date: Mon, 27 Jul 2015 12:34:44 +0200 Subject: [PATCH 4/6] ADDED: Ability to load resource bundle either from bundle where DTLoupeView class is located in, or main bundle --- Core/Source/DTLoupeView.m | 61 ++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/Core/Source/DTLoupeView.m b/Core/Source/DTLoupeView.m index 20c892b..fb5f16b 100644 --- a/Core/Source/DTLoupeView.m +++ b/Core/Source/DTLoupeView.m @@ -69,6 +69,9 @@ @implementation DTLoupeView // Draws cross hairs for debugging BOOL _drawDebugCrossHairs; + + // the resource bundle + NSBundle *_resourceBundle; } @@ -110,14 +113,6 @@ - (id)init if (self) { - // make sure that resource bundle is present - NSString *resourceBundlePath = [[NSBundle mainBundle] pathForResource:@"DTLoupe" ofType:@"bundle"]; - - if (!resourceBundlePath) - { - NSLog(@"DTLoupe.bundle is missing from app bundle. Please make sure that you include it in your app's resources"); - }; - self.contentMode = UIViewContentModeCenter; self.backgroundColor = [UIColor clearColor]; self.opaque = NO; @@ -364,32 +359,64 @@ - (void)adjustBaseViewIfNecessary } } +- (NSBundle *)_resourceBundle +{ + if (!_resourceBundle) + { + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSString *resourceBundlePath = [bundle pathForResource:@"DTLoupe" ofType:@"bundle"]; + + if (!resourceBundlePath) + { + // try to find it in main bundle instead + bundle = [NSBundle mainBundle]; + resourceBundlePath = [bundle pathForResource:@"DTLoupe" ofType:@"bundle"]; + } + + NSAssert(resourceBundlePath, @"DTLoupe.bundle is missing from app bundle. Please make sure that you include it in your app's resources or embed the DTRichTextEditor.framework"); + + _resourceBundle = [NSBundle bundleWithPath:resourceBundlePath]; + } + + return _resourceBundle; +} + +- (UIImage *)_imageNamedFromResourceBundle:(NSString *)name +{ + NSBundle *resourceBundle = [self _resourceBundle]; + + NSString *imagePath = [resourceBundle pathForResource:name ofType:@"png"]; + UIImage *image = [UIImage imageWithContentsOfFile:imagePath]; + + return image; +} + - (void)setImagesForStyle:(DTLoupeStyle)style { switch (style) { case DTLoupeStyleCircle: { - self.loupeFrameBackgroundImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-loupe-lo.png"]; - self.loupeFrameMaskImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-loupe-mask.png"]; - self.loupeFrameImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-loupe-hi.png"]; + self.loupeFrameBackgroundImage = [self _imageNamedFromResourceBundle:@"kb-loupe-lo"]; + self.loupeFrameMaskImage = [self _imageNamedFromResourceBundle:@"kb-loupe-mask"]; + self.loupeFrameImage = [self _imageNamedFromResourceBundle:@"kb-loupe-hi"]; break; } case DTLoupeStyleRectangle: { - self.loupeFrameBackgroundImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-lo-stemless.png"]; - self.loupeFrameMaskImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-mask.png"]; - self.loupeFrameImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-hi.png"]; + self.loupeFrameBackgroundImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-lo-stemless"]; + self.loupeFrameMaskImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-mask"]; + self.loupeFrameImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-hi"]; break; } case DTLoupeStyleRectangleWithArrow: { - self.loupeFrameBackgroundImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-lo.png"]; - self.loupeFrameMaskImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-mask.png"]; - self.loupeFrameImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-hi.png"]; + self.loupeFrameBackgroundImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-lo"]; + self.loupeFrameMaskImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-mask"]; + self.loupeFrameImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-hi"]; break; } From b2d2ea420dee9d75699a2aa208ee104ac250c81b Mon Sep 17 00:00:00 2001 From: Oliver Drobnik Date: Mon, 27 Jul 2015 12:45:04 +0200 Subject: [PATCH 5/6] Added better iOS 8 method for retrieving images from resource bundles --- Core/Source/DTLoupeView.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Core/Source/DTLoupeView.m b/Core/Source/DTLoupeView.m index fb5f16b..998a755 100644 --- a/Core/Source/DTLoupeView.m +++ b/Core/Source/DTLoupeView.m @@ -384,9 +384,15 @@ - (NSBundle *)_resourceBundle - (UIImage *)_imageNamedFromResourceBundle:(NSString *)name { NSBundle *resourceBundle = [self _resourceBundle]; - + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000 + // this method works >= iOS 8 and is the preferred way to get images from bundles + UIImage *image = [UIImage imageNamed:name inBundle:resourceBundle compatibleWithTraitCollection:nil]; +#else + // classic method to get images from bundles NSString *imagePath = [resourceBundle pathForResource:name ofType:@"png"]; UIImage *image = [UIImage imageWithContentsOfFile:imagePath]; +#endif return image; } From 1987c4117857a8a4cf4aea6761998c7437ab4a8d Mon Sep 17 00:00:00 2001 From: Oliver Drobnik Date: Mon, 27 Jul 2015 16:02:48 +0200 Subject: [PATCH 6/6] Updated podspec and change log --- DTLoupe.podspec | 2 +- Documentation/Change Log-template.markdown | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DTLoupe.podspec b/DTLoupe.podspec index b092826..e50e87d 100644 --- a/DTLoupe.podspec +++ b/DTLoupe.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'DTLoupe' - spec.version = '1.5.6' + spec.version = '1.5.7' spec.platform = :ios, '4.3' spec.license = 'BSD' spec.source = { :git => 'https://github.com/Cocoanetics/DTLoupe.git', :tag => spec.version.to_s } diff --git a/Documentation/Change Log-template.markdown b/Documentation/Change Log-template.markdown index 38f9416..d43b034 100644 --- a/Documentation/Change Log-template.markdown +++ b/Documentation/Change Log-template.markdown @@ -3,6 +3,10 @@ Change Log This is the history of version updates. +Version 1.5.7 + +- ADDED: DTLoupe resource bundle can now also be in framework resources + Version 1.5.6 - FIXED: Invalid layer geometry might cause crash