diff --git a/Example/JXIAPManager.xcodeproj/project.pbxproj b/Example/JXIAPManager.xcodeproj/project.pbxproj new file mode 100644 index 0000000..040fe89 --- /dev/null +++ b/Example/JXIAPManager.xcodeproj/project.pbxproj @@ -0,0 +1,388 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + F3B859C12EF242E30095A9CC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3B859B72EF242E30095A9CC /* AppDelegate.swift */; }; + F3B859C22EF242E30095A9CC /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3B859BE2EF242E30095A9CC /* SceneDelegate.swift */; }; + F3B859C32EF242E30095A9CC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3B859BF2EF242E30095A9CC /* ViewController.swift */; }; + F3B859C42EF242E30095A9CC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F3B859B82EF242E30095A9CC /* Assets.xcassets */; }; + F3B859C62EF242E30095A9CC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F3B859BB2EF242E30095A9CC /* LaunchScreen.storyboard */; }; + F3B859C72EF242E30095A9CC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F3B859BD2EF242E30095A9CC /* Main.storyboard */; }; + F3B859CA2EF248000095A9CC /* JXIAPManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3B859C82EF248000095A9CC /* JXIAPManager.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + F3B8599F2EF242DA0095A9CC /* JXIAPManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JXIAPManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; + F3B859B72EF242E30095A9CC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + F3B859B82EF242E30095A9CC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + F3B859B92EF242E30095A9CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F3B859BA2EF242E30095A9CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + F3B859BC2EF242E30095A9CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + F3B859BE2EF242E30095A9CC /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + F3B859BF2EF242E30095A9CC /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + F3B859C82EF248000095A9CC /* JXIAPManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JXIAPManager.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F3B8599C2EF242DA0095A9CC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + F3B859962EF242DA0095A9CC = { + isa = PBXGroup; + children = ( + F3B859C02EF242E30095A9CC /* JXIAPManager */, + F3B859A02EF242DA0095A9CC /* Products */, + ); + sourceTree = ""; + }; + F3B859A02EF242DA0095A9CC /* Products */ = { + isa = PBXGroup; + children = ( + F3B8599F2EF242DA0095A9CC /* JXIAPManager.app */, + ); + name = Products; + sourceTree = ""; + }; + F3B859C02EF242E30095A9CC /* JXIAPManager */ = { + isa = PBXGroup; + children = ( + F3B859C92EF248000095A9CC /* Sources */, + F3B859B72EF242E30095A9CC /* AppDelegate.swift */, + F3B859B82EF242E30095A9CC /* Assets.xcassets */, + F3B859B92EF242E30095A9CC /* Info.plist */, + F3B859BB2EF242E30095A9CC /* LaunchScreen.storyboard */, + F3B859BD2EF242E30095A9CC /* Main.storyboard */, + F3B859BE2EF242E30095A9CC /* SceneDelegate.swift */, + F3B859BF2EF242E30095A9CC /* ViewController.swift */, + ); + path = JXIAPManager; + sourceTree = ""; + }; + F3B859C92EF248000095A9CC /* Sources */ = { + isa = PBXGroup; + children = ( + F3B859C82EF248000095A9CC /* JXIAPManager.swift */, + ); + name = Sources; + path = ../Sources; + sourceTree = SOURCE_ROOT; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + F3B8599E2EF242DA0095A9CC /* JXIAPManager */ = { + isa = PBXNativeTarget; + buildConfigurationList = F3B859B22EF242DC0095A9CC /* Build configuration list for PBXNativeTarget "JXIAPManager" */; + buildPhases = ( + F3B8599B2EF242DA0095A9CC /* Sources */, + F3B8599C2EF242DA0095A9CC /* Frameworks */, + F3B8599D2EF242DA0095A9CC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = JXIAPManager; + packageProductDependencies = ( + ); + productName = JXIAPManager; + productReference = F3B8599F2EF242DA0095A9CC /* JXIAPManager.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F3B859972EF242DA0095A9CC /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1640; + LastUpgradeCheck = 1640; + TargetAttributes = { + F3B8599E2EF242DA0095A9CC = { + CreatedOnToolsVersion = 16.4; + }; + }; + }; + buildConfigurationList = F3B8599A2EF242DA0095A9CC /* Build configuration list for PBXProject "JXIAPManager" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = F3B859962EF242DA0095A9CC; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; + productRefGroup = F3B859A02EF242DA0095A9CC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F3B8599E2EF242DA0095A9CC /* JXIAPManager */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + F3B8599D2EF242DA0095A9CC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F3B859C42EF242E30095A9CC /* Assets.xcassets in Resources */, + F3B859C62EF242E30095A9CC /* LaunchScreen.storyboard in Resources */, + F3B859C72EF242E30095A9CC /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + F3B8599B2EF242DA0095A9CC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F3B859CA2EF248000095A9CC /* JXIAPManager.swift in Sources */, + F3B859C12EF242E30095A9CC /* AppDelegate.swift in Sources */, + F3B859C22EF242E30095A9CC /* SceneDelegate.swift in Sources */, + F3B859C32EF242E30095A9CC /* ViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + F3B859BB2EF242E30095A9CC /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + F3B859BA2EF242E30095A9CC /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; + F3B859BD2EF242E30095A9CC /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + F3B859BC2EF242E30095A9CC /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + F3B859B32EF242DC0095A9CC /* 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_TEAM = 8NNUR9HPV3; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = JXIAPManager/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = aaaaaa.JXIAPManager; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + F3B859B42EF242DC0095A9CC /* 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_TEAM = 8NNUR9HPV3; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = JXIAPManager/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = aaaaaa.JXIAPManager; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + F3B859B52EF242DC0095A9CC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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; + DEVELOPMENT_TEAM = 8NNUR9HPV3; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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 = 18.5; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + F3B859B62EF242DC0095A9CC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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"; + DEVELOPMENT_TEAM = 8NNUR9HPV3; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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 = 18.5; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F3B8599A2EF242DA0095A9CC /* Build configuration list for PBXProject "JXIAPManager" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F3B859B52EF242DC0095A9CC /* Debug */, + F3B859B62EF242DC0095A9CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F3B859B22EF242DC0095A9CC /* Build configuration list for PBXNativeTarget "JXIAPManager" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F3B859B32EF242DC0095A9CC /* Debug */, + F3B859B42EF242DC0095A9CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = F3B859972EF242DA0095A9CC /* Project object */; +} diff --git a/Example/JXIAPManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/JXIAPManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Example/JXIAPManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Example/JXIAPManager/AppDelegate.swift b/Example/JXIAPManager/AppDelegate.swift new file mode 100644 index 0000000..054edc7 --- /dev/null +++ b/Example/JXIAPManager/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// JXIAPManager +// +// Created by 长沙鸿瑶 on 2025/12/17. +// + +import UIKit + +@main +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/JXIAPManager/Assets.xcassets/AccentColor.colorset/Contents.json b/Example/JXIAPManager/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Example/JXIAPManager/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/JXIAPManager/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/JXIAPManager/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2305880 --- /dev/null +++ b/Example/JXIAPManager/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,35 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/JXIAPManager/Assets.xcassets/Contents.json b/Example/JXIAPManager/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Example/JXIAPManager/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/JXIAPManager/Base.lproj/LaunchScreen.storyboard b/Example/JXIAPManager/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Example/JXIAPManager/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/JXIAPManager/Base.lproj/Main.storyboard b/Example/JXIAPManager/Base.lproj/Main.storyboard new file mode 100644 index 0000000..25a7638 --- /dev/null +++ b/Example/JXIAPManager/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/JXIAPManager/Info.plist b/Example/JXIAPManager/Info.plist new file mode 100644 index 0000000..dd3c9af --- /dev/null +++ b/Example/JXIAPManager/Info.plist @@ -0,0 +1,25 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/Example/JXIAPManager/SceneDelegate.swift b/Example/JXIAPManager/SceneDelegate.swift new file mode 100644 index 0000000..a9cd713 --- /dev/null +++ b/Example/JXIAPManager/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// JXIAPManager +// +// Created by 长沙鸿瑶 on 2025/12/17. +// + +import UIKit + +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). + guard let _ = (scene as? UIWindowScene) else { return } + } + + 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 necessarily 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/Example/JXIAPManager/ViewController.swift b/Example/JXIAPManager/ViewController.swift new file mode 100644 index 0000000..5d6b5b6 --- /dev/null +++ b/Example/JXIAPManager/ViewController.swift @@ -0,0 +1,19 @@ +// +// ViewController.swift +// JXIAPManager +// +// Created by 长沙鸿瑶 on 2025/12/17. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + +} + diff --git a/JXIAPManager.podspec b/JXIAPManager.podspec new file mode 100644 index 0000000..19fd1aa --- /dev/null +++ b/JXIAPManager.podspec @@ -0,0 +1,31 @@ + + +Pod::Spec.new do |spec| + + spec.name = "JXIAPManager" + spec.version = "0.0.1" + spec.summary = "JXIAPManager内购小工具" + + spec.description = <<-DESC + JXIAPManager这是一个内购小工具 + DESC + + spec.homepage = "https://git.qinjiu8.com/zengjx/JXIAPManager" + + + spec.license = { :type => "MIT", :file => "LICENSE" } + + + spec.author = { "zeng" => "zengjx@qinjiu8.com" } + + + spec.source = { :git => "https://git.qinjiu8.com/zengjx/JXIAPManager.git", :tag => spec.version.to_s } + + + spec.ios.deployment_target = '13.0' + spec.swift_version = '5.0' + spec.source_files = "Sources", "Sources/**/*.{h,m,swift}" + # spec.exclude_files = "Classes/Exclude" + + +end diff --git a/Sources/JXIAPManager.swift b/Sources/JXIAPManager.swift new file mode 100644 index 0000000..422aab7 --- /dev/null +++ b/Sources/JXIAPManager.swift @@ -0,0 +1,216 @@ +import UIKit +import StoreKit + +@objc public protocol JXIAPManagerDelegate { + /// 购买成功 + @objc optional func jx_iapPaySuccess(productId: String, receipt: String, transactionIdentifier: String) + /// 购买失败 + @objc optional func jx_iapPayFailed(productId: String, code: JXIAPManagerCode, msg: String?) + /// 恢复商品(仅限永久有效商品) + @objc optional func iapPayRestore(productIds: [String], transactionIds: [String]) +// /// 加载 +// @objc optional func iapPayShowHud() +// /// 系统错误 +// @objc optional func iapSysWrong() +// /// 验证成功 +// @objc optional func verifySuccess() +// /// 验证失败 +// @objc optional func verifyFailed() +} + +@objc public enum JXIAPManagerCode: Int { + ///未知错误 + case unknown + ///取消交易 + case cancelled + ///没有商品 + case noProduct +} + +public class JXIAPManager: NSObject { + + + public static let manager: JXIAPManager = JXIAPManager() + + public weak var delegate: JXIAPManagerDelegate? + + private var payment: SKPayment? + + private var product: SKProduct? + private var productId: String? + + private var discount: SKPaymentDiscount? + private var orderId: String? + private var applicationUsername: String? + + private var receiptCompletion: ((URL?) -> Void)? + + override init() { + super.init() + SKPaymentQueue.default().add(self) + } + + + public func start(productId: String, orderId: String, applicationUsername: String?, discount: SKPaymentDiscount? = nil) { + self.product = nil + self.productId = productId + self.orderId = orderId + self.discount = discount + self.applicationUsername = applicationUsername + + let set = Set([productId]) + let productsRequest = SKProductsRequest(productIdentifiers: set) + productsRequest.delegate = self + productsRequest.start() + } + + /// 购买商品 + private func buyProduct() { + guard let product = self.product else { return } + + // 要购买商品,开个小票 + let payment = SKMutablePayment(product: product) + payment.applicationUsername = self.applicationUsername + if let discount = self.discount { + payment.paymentDiscount = discount + self.discount = nil + } + + self.payment = payment + + // 去收银台排队,准备购买 + SKPaymentQueue.default().add(payment) + } + +} + +//MARK: -------------- SKProductsRequestDelegate -------------- +extension JXIAPManager: SKProductsRequestDelegate { + public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) { + guard let product = response.products.first else { + DispatchQueue.main.async { + if let productId = self.productId { + self.productId = nil + self.delegate?.jx_iapPayFailed?(productId: productId, code: .noProduct, msg: nil) + } + } + return + } + self.product = product + + self.buyProduct() + + } +} + +//MARK: -------------- SKPaymentTransactionObserver -------------- +extension JXIAPManager: SKPaymentTransactionObserver { + ///购买回调 + public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) { + + for transaction in transactions { + switch transaction.transactionState { + case .purchased: + DispatchQueue.main.async { + self.completeTransaction(transaction: transaction) + } + SKPaymentQueue.default().finishTransaction(transaction) + + case .failed: + DispatchQueue.main.async { + self.failedTransaction(transaction: transaction) + } + SKPaymentQueue.default().finishTransaction(transaction) +// case .restored: +// self.restoreTransaction(transaction: transaction) + + case .purchasing: + break + default: + SKPaymentQueue.default().finishTransaction(transaction) + break + } + + + } + } + +// func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool { +// return true +// } + + /// 恢复购买回调 + public func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) { + + } + +} + +extension JXIAPManager { + + + private func completeTransaction(transaction: SKPaymentTransaction) { + guard let encodeStr = getAppStoreReceipt() else { return } + guard let transactionIdentifier = transaction.transactionIdentifier else { return } + + guard let productId = self.productId, productId == transaction.payment.productIdentifier else { return } + self.productId = nil + self.delegate?.jx_iapPaySuccess?(productId: productId, receipt: encodeStr, transactionIdentifier: transactionIdentifier) + + } + + private func failedTransaction(transaction: SKPaymentTransaction) { + let error = transaction.error as? SKError + guard let productId = self.productId else { return } + self.productId = nil + + switch error?.code { + case SKError.paymentCancelled: + self.delegate?.jx_iapPayFailed?(productId: productId, code: .cancelled, msg: error?.localizedDescription) + default: + self.delegate?.jx_iapPayFailed?(productId: productId, code: .unknown, msg: error?.localizedDescription) + } + + } + + + +} + +extension JXIAPManager: SKRequestDelegate { + + public func getAppStoreReceipt() -> String? { + guard let receiptURL = Bundle.main.appStoreReceiptURL else { return nil } + let receiptData = NSData(contentsOf: receiptURL) + return receiptData?.base64EncodedString(options: .endLineWithLineFeed) + } + + ///获取凭证 + public func fetchReceipt(completion: @escaping (URL?) -> Void) { + let receiptURL = Bundle.main.appStoreReceiptURL + if let url = receiptURL, FileManager.default.fileExists(atPath: url.path) { + completion(url) + return + } + + let request = SKReceiptRefreshRequest() + request.delegate = self + request.start() + // 在 delegate 回调里处理 + self.receiptCompletion = completion + } + + public func requestDidFinish(_ request: SKRequest) { + let receiptURL = Bundle.main.appStoreReceiptURL + if let url = receiptURL, FileManager.default.fileExists(atPath: url.path) { + receiptCompletion?(url) + } else { + receiptCompletion?(nil) + } + } + + public func request(_ request: SKRequest, didFailWithError error: Error) { + print("Receipt request failed: \(error)") + receiptCompletion?(nil) + } +}