diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata similarity index 100% rename from Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata diff --git a/Example/ImaginaryDemo/ImaginaryDemo.xcodeproj/project.pbxproj b/Example/ImaginaryDemo/ImaginaryDemo.xcodeproj/project.pbxproj index 507a6ce..e58179d 100644 --- a/Example/ImaginaryDemo/ImaginaryDemo.xcodeproj/project.pbxproj +++ b/Example/ImaginaryDemo/ImaginaryDemo.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 295D77431C07122700C43B07 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 295D77411C07122700C43B07 /* LaunchScreen.storyboard */; }; 29FC0C2B1C07268100B66E11 /* FeedTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FC0C2A1C07268100B66E11 /* FeedTableViewCell.swift */; }; 938EF94E073488BB7B5AE1F1 /* Pods_ImaginaryDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C16C258DB463D5FFF1DD607 /* Pods_ImaginaryDemo.framework */; }; + F560478A28621EC1008ED0AC /* SwiftUIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F560478928621EC1008ED0AC /* SwiftUIViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -27,6 +28,7 @@ 311B2CD8C66C552F516784F2 /* Pods-ImaginaryDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImaginaryDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-ImaginaryDemo/Pods-ImaginaryDemo.release.xcconfig"; sourceTree = ""; }; 46273A36A5534213CB1EF279 /* Pods-ImaginaryDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImaginaryDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ImaginaryDemo/Pods-ImaginaryDemo.debug.xcconfig"; sourceTree = ""; }; F0A3FBC34DFEEC7A04F84F11 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F560478928621EC1008ED0AC /* SwiftUIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -68,6 +70,7 @@ 295D773F1C07122700C43B07 /* Assets.xcassets */, 295D77411C07122700C43B07 /* LaunchScreen.storyboard */, 295D77441C07122700C43B07 /* Info.plist */, + F560478928621EC1008ED0AC /* SwiftUIViewController.swift */, ); path = ImaginaryDemo; sourceTree = ""; @@ -203,6 +206,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + F560478A28621EC1008ED0AC /* SwiftUIViewController.swift in Sources */, 295D773B1C07122700C43B07 /* ViewController.swift in Sources */, 29FC0C2B1C07268100B66E11 /* FeedTableViewCell.swift in Sources */, 295D77391C07122700C43B07 /* AppDelegate.swift in Sources */, diff --git a/Example/ImaginaryDemo/ImaginaryDemo/AppDelegate.swift b/Example/ImaginaryDemo/ImaginaryDemo/AppDelegate.swift index f8aec57..b0cf00c 100644 --- a/Example/ImaginaryDemo/ImaginaryDemo/AppDelegate.swift +++ b/Example/ImaginaryDemo/ImaginaryDemo/AppDelegate.swift @@ -2,19 +2,21 @@ import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { - - lazy var viewController: ViewController = ViewController() - - var window: UIWindow? - + lazy var viewController: ViewController = ViewController() + lazy var swiftUIViewController: SwiftUIViewController = SwiftUIViewController() + + var window: UIWindow? + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - let navigationController = UINavigationController(rootViewController: viewController) - viewController.title = "Imaginary".uppercased() - - window = UIWindow() - window?.rootViewController = navigationController - window?.makeKeyAndVisible() - - return true - } + let tabVC = UITabBarController() + viewController.tabBarItem.title = "UIKit" + swiftUIViewController.tabBarItem.title = "SwiftUI" + tabVC.setViewControllers([viewController, swiftUIViewController], animated: true) + + window = UIWindow() + window?.rootViewController = tabVC + window?.makeKeyAndVisible() + + return true + } } diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/ContentView.swift b/Example/ImaginaryDemo/ImaginaryDemo/SwiftUIViewController.swift similarity index 67% rename from Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/ContentView.swift rename to Example/ImaginaryDemo/ImaginaryDemo/SwiftUIViewController.swift index cf1db2a..6a4a6cf 100644 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/ContentView.swift +++ b/Example/ImaginaryDemo/ImaginaryDemo/SwiftUIViewController.swift @@ -1,15 +1,16 @@ // -// ContentView.swift -// ImaginarySwiftUIDemo +// SwiftUIViewController.swift +// ImaginaryDemo // // Created by Arslan Rafique on 2022-06-21. +// Copyright © 2022 Ramon Gilabert Llop. All rights reserved. // import SwiftUI import Imaginary struct ContentView: SwiftUI.View { - + struct Constants { static let imageWidth = 500 static let imageHeight = 500 @@ -28,7 +29,7 @@ struct ContentView: SwiftUI.View { return array }() - + var body: some SwiftUI.View { ScrollView { VStack { @@ -41,8 +42,11 @@ struct ContentView: SwiftUI.View { } } -struct ContentView_Previews: PreviewProvider { - static var previews: some SwiftUI.View { - ContentView() +class SwiftUIViewController: UITableViewController { + override func viewDidLoad() { + let hosting = UIHostingController(rootView: ContentView()) + self.addChild(hosting) + self.view.addSubview(hosting.view) + hosting.view.frame = UIScreen.main.bounds } } diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.pbxproj b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.pbxproj deleted file mode 100644 index 8368aa0..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.pbxproj +++ /dev/null @@ -1,380 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 55; - objects = { - -/* Begin PBXBuildFile section */ - F5776AD32861EF9100181B1E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5776AD22861EF9100181B1E /* ContentView.swift */; }; - F5776AD52861EF9100181B1E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F5776AD42861EF9100181B1E /* Assets.xcassets */; }; - F5776AD82861EF9100181B1E /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F5776AD72861EF9100181B1E /* Preview Assets.xcassets */; }; - F5776ADF2861F11C00181B1E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5776ADE2861F11C00181B1E /* AppDelegate.swift */; }; - F5776AE22861F31C00181B1E /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5776AE12861F31C00181B1E /* SceneDelegate.swift */; }; - F5C1C0622861F93B00BD5BB6 /* Imaginary in Frameworks */ = {isa = PBXBuildFile; productRef = F5C1C0612861F93B00BD5BB6 /* Imaginary */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - F5776ACD2861EF9100181B1E /* ImaginarySwiftUIDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImaginarySwiftUIDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; - F5776AD22861EF9100181B1E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; - F5776AD42861EF9100181B1E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - F5776AD72861EF9100181B1E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - F5776ADE2861F11C00181B1E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - F5776AE02861F25000181B1E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; - F5776AE12861F31C00181B1E /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - F5C1C05F2861F80C00BD5BB6 /* Imaginary */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Imaginary; path = ../..; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - F5776ACA2861EF9100181B1E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - F5C1C0622861F93B00BD5BB6 /* Imaginary in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - F5776AC42861EF9100181B1E = { - isa = PBXGroup; - children = ( - F5C1C05E2861F80C00BD5BB6 /* Packages */, - F5776ACF2861EF9100181B1E /* ImaginarySwiftUIDemo */, - F5776ACE2861EF9100181B1E /* Products */, - F5C1C0602861F93B00BD5BB6 /* Frameworks */, - ); - sourceTree = ""; - }; - F5776ACE2861EF9100181B1E /* Products */ = { - isa = PBXGroup; - children = ( - F5776ACD2861EF9100181B1E /* ImaginarySwiftUIDemo.app */, - ); - name = Products; - sourceTree = ""; - }; - F5776ACF2861EF9100181B1E /* ImaginarySwiftUIDemo */ = { - isa = PBXGroup; - children = ( - F5776AE02861F25000181B1E /* Info.plist */, - F5776AD22861EF9100181B1E /* ContentView.swift */, - F5776AD42861EF9100181B1E /* Assets.xcassets */, - F5776AD62861EF9100181B1E /* Preview Content */, - F5776ADE2861F11C00181B1E /* AppDelegate.swift */, - F5776AE12861F31C00181B1E /* SceneDelegate.swift */, - ); - path = ImaginarySwiftUIDemo; - sourceTree = ""; - }; - F5776AD62861EF9100181B1E /* Preview Content */ = { - isa = PBXGroup; - children = ( - F5776AD72861EF9100181B1E /* Preview Assets.xcassets */, - ); - path = "Preview Content"; - sourceTree = ""; - }; - F5C1C05E2861F80C00BD5BB6 /* Packages */ = { - isa = PBXGroup; - children = ( - F5C1C05F2861F80C00BD5BB6 /* Imaginary */, - ); - name = Packages; - sourceTree = ""; - }; - F5C1C0602861F93B00BD5BB6 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - F5776ACC2861EF9100181B1E /* ImaginarySwiftUIDemo */ = { - isa = PBXNativeTarget; - buildConfigurationList = F5776ADB2861EF9100181B1E /* Build configuration list for PBXNativeTarget "ImaginarySwiftUIDemo" */; - buildPhases = ( - F5776AC92861EF9100181B1E /* Sources */, - F5776ACA2861EF9100181B1E /* Frameworks */, - F5776ACB2861EF9100181B1E /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = ImaginarySwiftUIDemo; - packageProductDependencies = ( - F5C1C0612861F93B00BD5BB6 /* Imaginary */, - ); - productName = ImaginarySwiftUIDemo; - productReference = F5776ACD2861EF9100181B1E /* ImaginarySwiftUIDemo.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - F5776AC52861EF9100181B1E /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1340; - LastUpgradeCheck = 1340; - TargetAttributes = { - F5776ACC2861EF9100181B1E = { - CreatedOnToolsVersion = 13.4.1; - }; - }; - }; - buildConfigurationList = F5776AC82861EF9100181B1E /* Build configuration list for PBXProject "ImaginarySwiftUIDemo" */; - compatibilityVersion = "Xcode 13.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = F5776AC42861EF9100181B1E; - productRefGroup = F5776ACE2861EF9100181B1E /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - F5776ACC2861EF9100181B1E /* ImaginarySwiftUIDemo */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - F5776ACB2861EF9100181B1E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - F5776AD82861EF9100181B1E /* Preview Assets.xcassets in Resources */, - F5776AD52861EF9100181B1E /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - F5776AC92861EF9100181B1E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - F5776ADF2861F11C00181B1E /* AppDelegate.swift in Sources */, - F5776AD32861EF9100181B1E /* ContentView.swift in Sources */, - F5776AE22861F31C00181B1E /* SceneDelegate.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - F5776AD92861EF9100181B1E /* 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++17"; - 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - 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.0; - 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; - }; - F5776ADA2861EF9100181B1E /* 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++17"; - 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - 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.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - F5776ADC2861EF9100181B1E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"ImaginarySwiftUIDemo/Preview Content\""; - DEVELOPMENT_TEAM = 29L6WT62Z8; - ENABLE_PREVIEWS = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = ImaginarySwiftUIDemo/Info.plist; - INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; - INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = arlsanrafique.ImaginarySwiftUIDemo; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - F5776ADD2861EF9100181B1E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"ImaginarySwiftUIDemo/Preview Content\""; - DEVELOPMENT_TEAM = 29L6WT62Z8; - ENABLE_PREVIEWS = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = ImaginarySwiftUIDemo/Info.plist; - INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; - INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = arlsanrafique.ImaginarySwiftUIDemo; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - F5776AC82861EF9100181B1E /* Build configuration list for PBXProject "ImaginarySwiftUIDemo" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - F5776AD92861EF9100181B1E /* Debug */, - F5776ADA2861EF9100181B1E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - F5776ADB2861EF9100181B1E /* Build configuration list for PBXNativeTarget "ImaginarySwiftUIDemo" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - F5776ADC2861EF9100181B1E /* Debug */, - F5776ADD2861EF9100181B1E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - -/* Begin XCSwiftPackageProductDependency section */ - F5C1C0612861F93B00BD5BB6 /* Imaginary */ = { - isa = XCSwiftPackageProductDependency; - productName = Imaginary; - }; -/* End XCSwiftPackageProductDependency section */ - }; - rootObject = F5776AC52861EF9100181B1E /* Project object */; -} diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index aece6c2..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,16 +0,0 @@ -{ - "object": { - "pins": [ - { - "package": "Cache", - "repositoryURL": "https://github.com/hyperoslo/Cache", - "state": { - "branch": null, - "revision": "c7f4d633049c3bd649a353bad36f6c17e9df085f", - "version": "6.0.0" - } - } - ] - }, - "version": 1 -} diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/xcshareddata/xcschemes/ImaginarySwiftUIDemo.xcscheme b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/xcshareddata/xcschemes/ImaginarySwiftUIDemo.xcscheme deleted file mode 100644 index c4c8295..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo.xcodeproj/xcshareddata/xcschemes/ImaginarySwiftUIDemo.xcscheme +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/AppDelegate.swift b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/AppDelegate.swift deleted file mode 100644 index 770146f..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/AppDelegate.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// AppDelegate.swift -// ImaginarySwiftUIDemo -// -// Created by Arslan Rafique on 2022-06-21. -// - -import UIKit -import SwiftUI - -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - return true - } - - - // MARK: UISceneSession Lifecycle - - func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { - // Called when a new scene session is being created. - // Use this method to select a configuration to create the new scene with. - return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) - } - - func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { - // Called when the user discards a scene session. - // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. - // Use this method to release any resources that were specific to the discarded scenes, as they will not return. - } -} diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Assets.xcassets/AccentColor.colorset/Contents.json b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Assets.xcassets/AccentColor.colorset/Contents.json deleted file mode 100644 index eb87897..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Assets.xcassets/AccentColor.colorset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "colors" : [ - { - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 9221b9b..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "20x20" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "20x20" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "40x40" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "40x40" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "60x60" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "60x60" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "20x20" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "20x20" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "29x29" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "29x29" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "40x40" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "40x40" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "76x76" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "76x76" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "83.5x83.5" - }, - { - "idiom" : "ios-marketing", - "scale" : "1x", - "size" : "1024x1024" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Assets.xcassets/Contents.json b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Assets.xcassets/Contents.json deleted file mode 100644 index 73c0059..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Info.plist b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Info.plist deleted file mode 100644 index 9fe1fde..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Info.plist +++ /dev/null @@ -1,25 +0,0 @@ - - - - - UIApplicationSceneManifest - - UIApplicationSupportsMultipleScenes - - UISceneConfigurations - - UIWindowSceneSessionRoleApplication - - - UISceneClassName - - UISceneConfigurationName - - UISceneDelegateClassName - $(PRODUCT_MODULE_NAME).SceneDelegate - - - - - - diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Preview Content/Preview Assets.xcassets/Contents.json b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Preview Content/Preview Assets.xcassets/Contents.json deleted file mode 100644 index 73c0059..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/Preview Content/Preview Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/SceneDelegate.swift b/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/SceneDelegate.swift deleted file mode 100644 index 284c12b..0000000 --- a/Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/SceneDelegate.swift +++ /dev/null @@ -1,61 +0,0 @@ -// -// SceneDelegate.swift -// ImaginarySwiftUIDemo -// -// Created by Arslan Rafique on 2022-06-21. -// - -import Foundation -import SwiftUI - -class SceneDelegate: UIResponder, UIWindowSceneDelegate { - - var window: UIWindow? - - - func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { - // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. - // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. - // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). - - // Create the SwiftUI view that provides the window contents. - let contentView = ContentView() - - // Use a UIHostingController as window root view controller. - if let windowScene = scene as? UIWindowScene { - let window = UIWindow(windowScene: windowScene) - window.rootViewController = UIHostingController(rootView: contentView) - self.window = window - window.makeKeyAndVisible() - } - } - - func sceneDidDisconnect(_ scene: UIScene) { - // Called as the scene is being released by the system. - // This occurs shortly after the scene enters the background, or when its session is discarded. - // Release any resources associated with this scene that can be re-created the next time the scene connects. - // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). - } - - func sceneDidBecomeActive(_ scene: UIScene) { - // Called when the scene has moved from an inactive state to an active state. - // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. - } - - func sceneWillResignActive(_ scene: UIScene) { - // Called when the scene will move from an active state to an inactive state. - // This may occur due to temporary interruptions (ex. an incoming phone call). - - } - - func sceneWillEnterForeground(_ scene: UIScene) { - // Called as the scene transitions from the background to the foreground. - // Use this method to undo the changes made on entering the background. - } - - func sceneDidEnterBackground(_ scene: UIScene) { - // Called as the scene transitions from the foreground to the background. - // Use this method to save data, release shared resources, and store enough scene-specific state information - // to restore the scene back to its current state. - } -} diff --git a/Imaginary.xcodeproj/project.pbxproj b/Imaginary.xcodeproj/project.pbxproj index 98ecd6a..a7975d0 100644 --- a/Imaginary.xcodeproj/project.pbxproj +++ b/Imaginary.xcodeproj/project.pbxproj @@ -126,6 +126,7 @@ D5DF75911C403D8200BF1AB6 /* Imaginary.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Imaginary.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D5DF759E1C403E1000BF1AB6 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D5DF75B11C403FBF00BF1AB6 /* Cache.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cache.framework; path = Carthage/Build/iOS/Cache.framework; sourceTree = ""; }; + F560478B2862217B008ED0AC /* SwiftUI */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = folder; path = SwiftUI; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -244,6 +245,7 @@ D2E8C8051F7252C300D2B8EF /* Shared */ = { isa = PBXGroup; children = ( + F560478B2862217B008ED0AC /* SwiftUI */, D2E8C8071F7252C300D2B8EF /* Extensions */, D2E8C8091F7252C300D2B8EF /* Fetcher */, D2E8C80D1F7252C300D2B8EF /* Library */, diff --git a/README.md b/README.md index cb7ab01..b9d6bf4 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,16 @@ imageView.setImage(url: imageUrl) { result in `result` is an enum `Result` that let you know if the operation succeeded or failed. The possible error is of `ImaginaryError`. +## SwiftUI + +#### Set image with URL + +Simply pass `URL` to `ImageViewAdapter`. + +```swift +ImageViewAdapter(url: "https://avatars2.githubusercontent.com/u/1340892?v=3&s=200") +``` + ## Advanced ### Passing option @@ -99,7 +109,6 @@ public protocol ImageProcessor { This is how you apply tint color before setting images. - ```swift let option = Option(imagePreprocessor: TintImageProcessor(tintColor: .orange)) imageView.setImage(url: imageUrl, option: option) @@ -142,15 +151,15 @@ These are the buit in displayers. You need to supply the correct displayer for y ### Downloading -`Imaginary` uses `ImageFetcher` under the hood, which has downloader and storage. You can specify your own `ImageDownloader` together with a `modifyRequest` closure, there you can change request body or add more HTTP headers. +`Imaginary` uses `ImageFetcher` under the hood, which has downloader and storage. You can specify your own `ImageDownloader` together with a `modifyRequest` closure, there you can change request body or add more HTTP headers. ```swift var option = Option() option.downloaderMaker = { - return ImageDownloader(modifyRequest: { + return ImageDownloader(modifyRequest: { var request = $0 request.addValue("Bearer 123", forHTTPHeaderField: "Authorization") - return request + return request }) } @@ -220,7 +229,6 @@ multipleFetcher.fetch(urls: imageUrls, each: { result in This is ideal for the new [prefetching mode in UICollectionView](https://developer.apple.com/documentation/uikit/uicollectionview/1771771-prefetchingenabled) - ## Installation **Imaginary** is available through [CocoaPods](http://cocoapods.org). To install