diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3b29812
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+.DS_Store
+/.build
+/Packages
+/*.xcodeproj
+xcuserdata/
+DerivedData/
+.swiftpm/config/registries.json
+.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
+.netrc
diff --git a/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Demo/NFC Read-Write.xcodeproj/project.pbxproj b/Demo/NFC Read-Write.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..a903845
--- /dev/null
+++ b/Demo/NFC Read-Write.xcodeproj/project.pbxproj
@@ -0,0 +1,397 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 53;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 3A7CA69729616DAB00363E59 /* NFC_Read_WriteApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A7CA69629616DAB00363E59 /* NFC_Read_WriteApp.swift */; };
+ 3A7CA69929616DAB00363E59 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A7CA69829616DAB00363E59 /* ContentView.swift */; };
+ 3A7CA69B29616DAC00363E59 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3A7CA69A29616DAC00363E59 /* Assets.xcassets */; };
+ 3A7CA69F29616DAC00363E59 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3A7CA69E29616DAC00363E59 /* Preview Assets.xcassets */; };
+ 3ADDA132296B35640096CC30 /* SwiftNFC in Frameworks */ = {isa = PBXBuildFile; productRef = 3ADDA131296B35640096CC30 /* SwiftNFC */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 3A7CA69329616DAB00363E59 /* NFC Read-Write.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "NFC Read-Write.app"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 3A7CA69629616DAB00363E59 /* NFC_Read_WriteApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NFC_Read_WriteApp.swift; sourceTree = ""; };
+ 3A7CA69829616DAB00363E59 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; };
+ 3A7CA69A29616DAC00363E59 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
+ 3A7CA69C29616DAC00363E59 /* NFC_Read_Write.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NFC_Read_Write.entitlements; sourceTree = ""; };
+ 3A7CA69E29616DAC00363E59 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; };
+ 3ADDA12F296B35430096CC30 /* SwiftNFC */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SwiftNFC; path = ..; sourceTree = ""; };
+ 3AFEBDBB2969B836005BEFED /* NFC-Read-Write-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "NFC-Read-Write-Info.plist"; sourceTree = SOURCE_ROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 3A7CA69029616DAB00363E59 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 3ADDA132296B35640096CC30 /* SwiftNFC in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 3A7CA68A29616DAB00363E59 = {
+ isa = PBXGroup;
+ children = (
+ 3ADDA12D296B35100096CC30 /* Packages */,
+ 3A7CA69529616DAB00363E59 /* NFC Read-Write */,
+ 3A7CA69429616DAB00363E59 /* Products */,
+ 3ADDA130296B35640096CC30 /* Frameworks */,
+ );
+ sourceTree = "";
+ };
+ 3A7CA69429616DAB00363E59 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 3A7CA69329616DAB00363E59 /* NFC Read-Write.app */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 3A7CA69529616DAB00363E59 /* NFC Read-Write */ = {
+ isa = PBXGroup;
+ children = (
+ 3AFEBDBB2969B836005BEFED /* NFC-Read-Write-Info.plist */,
+ 3A7CA69629616DAB00363E59 /* NFC_Read_WriteApp.swift */,
+ 3A7CA69829616DAB00363E59 /* ContentView.swift */,
+ 3A7CA69A29616DAC00363E59 /* Assets.xcassets */,
+ 3A7CA69C29616DAC00363E59 /* NFC_Read_Write.entitlements */,
+ 3A7CA69D29616DAC00363E59 /* Preview Content */,
+ );
+ path = "NFC Read-Write";
+ sourceTree = "";
+ };
+ 3A7CA69D29616DAC00363E59 /* Preview Content */ = {
+ isa = PBXGroup;
+ children = (
+ 3A7CA69E29616DAC00363E59 /* Preview Assets.xcassets */,
+ );
+ path = "Preview Content";
+ sourceTree = "";
+ };
+ 3ADDA12D296B35100096CC30 /* Packages */ = {
+ isa = PBXGroup;
+ children = (
+ 3ADDA12F296B35430096CC30 /* SwiftNFC */,
+ );
+ name = Packages;
+ sourceTree = "";
+ };
+ 3ADDA130296B35640096CC30 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 3A7CA69229616DAB00363E59 /* NFC Read-Write */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 3A7CA6A229616DAC00363E59 /* Build configuration list for PBXNativeTarget "NFC Read-Write" */;
+ buildPhases = (
+ 3A7CA68F29616DAB00363E59 /* Sources */,
+ 3A7CA69029616DAB00363E59 /* Frameworks */,
+ 3A7CA69129616DAB00363E59 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "NFC Read-Write";
+ packageProductDependencies = (
+ 3ADDA131296B35640096CC30 /* SwiftNFC */,
+ );
+ productName = "NFC Read-Write";
+ productReference = 3A7CA69329616DAB00363E59 /* NFC Read-Write.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 3A7CA68B29616DAB00363E59 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ BuildIndependentTargetsInParallel = 1;
+ LastSwiftUpdateCheck = 1420;
+ LastUpgradeCheck = 1420;
+ TargetAttributes = {
+ 3A7CA69229616DAB00363E59 = {
+ CreatedOnToolsVersion = 14.2;
+ };
+ };
+ };
+ buildConfigurationList = 3A7CA68E29616DAB00363E59 /* Build configuration list for PBXProject "NFC Read-Write" */;
+ compatibilityVersion = "Xcode 8.0";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 3A7CA68A29616DAB00363E59;
+ packageReferences = (
+ );
+ productRefGroup = 3A7CA69429616DAB00363E59 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 3A7CA69229616DAB00363E59 /* NFC Read-Write */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 3A7CA69129616DAB00363E59 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 3A7CA69F29616DAC00363E59 /* Preview Assets.xcassets in Resources */,
+ 3A7CA69B29616DAC00363E59 /* Assets.xcassets in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 3A7CA68F29616DAB00363E59 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 3A7CA69929616DAB00363E59 /* ContentView.swift in Sources */,
+ 3A7CA69729616DAB00363E59 /* NFC_Read_WriteApp.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 3A7CA6A029616DAC00363E59 /* 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++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;
+ 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;
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
+ MTL_FAST_MATH = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ };
+ name = Debug;
+ };
+ 3A7CA6A129616DAC00363E59 /* 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++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";
+ 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;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ MTL_FAST_MATH = YES;
+ SWIFT_COMPILATION_MODE = wholemodule;
+ SWIFT_OPTIMIZATION_LEVEL = "-O";
+ };
+ name = Release;
+ };
+ 3A7CA6A329616DAC00363E59 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
+ CODE_SIGN_ENTITLEMENTS = "NFC Read-Write/NFC_Read_Write.entitlements";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_ASSET_PATHS = "\"NFC Read-Write/Preview Content\"";
+ DEVELOPMENT_TEAM = 9PAHLTG8AD;
+ ENABLE_HARDENED_RUNTIME = YES;
+ ENABLE_PREVIEWS = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = "NFC-Read-Write-Info.plist";
+ INFOPLIST_KEY_NFCReaderUsageDescription = "Use NFC to read to write data.";
+ "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
+ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
+ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
+ "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 11.0;
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = "sample.NFC-Read-Write";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = auto;
+ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 3A7CA6A429616DAC00363E59 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
+ CODE_SIGN_ENTITLEMENTS = "NFC Read-Write/NFC_Read_Write.entitlements";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_ASSET_PATHS = "\"NFC Read-Write/Preview Content\"";
+ DEVELOPMENT_TEAM = 9PAHLTG8AD;
+ ENABLE_HARDENED_RUNTIME = YES;
+ ENABLE_PREVIEWS = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = "NFC-Read-Write-Info.plist";
+ INFOPLIST_KEY_NFCReaderUsageDescription = "Use NFC to read to write data.";
+ "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
+ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
+ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
+ "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 11.0;
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = "sample.NFC-Read-Write";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = auto;
+ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 3A7CA68E29616DAB00363E59 /* Build configuration list for PBXProject "NFC Read-Write" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 3A7CA6A029616DAC00363E59 /* Debug */,
+ 3A7CA6A129616DAC00363E59 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 3A7CA6A229616DAC00363E59 /* Build configuration list for PBXNativeTarget "NFC Read-Write" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 3A7CA6A329616DAC00363E59 /* Debug */,
+ 3A7CA6A429616DAC00363E59 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+
+/* Begin XCSwiftPackageProductDependency section */
+ 3ADDA131296B35640096CC30 /* SwiftNFC */ = {
+ isa = XCSwiftPackageProductDependency;
+ productName = SwiftNFC;
+ };
+/* End XCSwiftPackageProductDependency section */
+ };
+ rootObject = 3A7CA68B29616DAB00363E59 /* Project object */;
+}
diff --git a/Demo/NFC Read-Write.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Demo/NFC Read-Write.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/Demo/NFC Read-Write.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/Demo/NFC Read-Write.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Demo/NFC Read-Write.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/Demo/NFC Read-Write.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Demo/NFC Read-Write/Assets.xcassets/AccentColor.colorset/Contents.json b/Demo/NFC Read-Write/Assets.xcassets/AccentColor.colorset/Contents.json
new file mode 100644
index 0000000..70fa21e
--- /dev/null
+++ b/Demo/NFC Read-Write/Assets.xcassets/AccentColor.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "colors" : [
+ {
+ "color" : {
+ "color-space" : "display-p3",
+ "components" : {
+ "alpha" : "1.000",
+ "blue" : "0.292",
+ "green" : "0.342",
+ "red" : "0.136"
+ }
+ },
+ "idiom" : "universal"
+ },
+ {
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "display-p3",
+ "components" : {
+ "alpha" : "1.000",
+ "blue" : "0.432",
+ "green" : "0.845",
+ "red" : "0.136"
+ }
+ },
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Demo/NFC Read-Write/Assets.xcassets/AppIcon.appiconset/Contents.json b/Demo/NFC Read-Write/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 0000000..532cd72
--- /dev/null
+++ b/Demo/NFC Read-Write/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,63 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "platform" : "ios",
+ "size" : "1024x1024"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "16x16"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "16x16"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "32x32"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "32x32"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "128x128"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "128x128"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "256x256"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "256x256"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "512x512"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "512x512"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Demo/NFC Read-Write/Assets.xcassets/Contents.json b/Demo/NFC Read-Write/Assets.xcassets/Contents.json
new file mode 100644
index 0000000..73c0059
--- /dev/null
+++ b/Demo/NFC Read-Write/Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Demo/NFC Read-Write/ContentView.swift b/Demo/NFC Read-Write/ContentView.swift
new file mode 100644
index 0000000..47b8c05
--- /dev/null
+++ b/Demo/NFC Read-Write/ContentView.swift
@@ -0,0 +1,105 @@
+//
+// ContentView.swift
+// NFC Read-Write
+//
+// Created by Ming on 1/1/2023.
+//
+
+import SwiftUI
+import SwiftNFC
+
+struct ContentView: View {
+ @ObservedObject var NFCR = NFCReader()
+ @ObservedObject var NFCW = NFCWriter()
+
+ var editor: some View {
+ TextEditor(text: $NFCR.msg)
+ .font(.title)
+ .padding(.top, 50)
+ .padding(15)
+ .background(Color.accentColor.opacity(0.5))
+ }
+ var editorRaw: some View {
+ TextEditor(text: $NFCR.raw)
+ .padding(15)
+ .background(Color.red.opacity(0.5))
+ }
+
+ var body: some View {
+ VStack(spacing: 0) {
+ VStack(spacing: 0) {
+ if #available(iOS 16.0, *) {
+ editor
+ .scrollContentBackground(.hidden)
+ option
+ editorRaw
+ .scrollContentBackground(.hidden)
+ } else {
+ // Fallback on earlier versions
+ editor
+ option
+ editorRaw
+ }
+ }
+ action
+ .frame(height: 75)
+ }
+ .ignoresSafeArea(.all)
+ .onTapGesture(count: 2) {
+ UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
+ }
+ }
+
+ var option: some View {
+ HStack {
+ Picker(selection: $NFCW.type, label: Text("Type Picker")) {
+ Text("Text").tag("T")
+ Text("Link").tag("U")
+ }
+ Spacer()
+ Button(action: {
+ UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
+ }) {
+ Text("Close Keyboard")
+ }
+ }.padding(.horizontal)
+ }
+
+ var action: some View {
+ HStack(spacing: 0) {
+ Button (action: { read() }) {
+ ZStack {
+ Color.blue.opacity(0.85)
+ Label("Read NFC", systemImage: "wave.3.left.circle.fill")
+ .foregroundColor(.white)
+ .padding(.top, 15)
+ .padding(.bottom, 35)
+ }
+ }
+ Button (action: { write() }) {
+ ZStack {
+ Color.accentColor.opacity(0.85)
+ Label("Write NFC", systemImage: "wave.3.left.circle.fill")
+ .foregroundColor(.white)
+ .padding(.top, 15)
+ .padding(.bottom, 35)
+ }
+ }
+ }
+ }
+
+ func read() {
+ NFCR.read()
+ }
+
+ func write() {
+ NFCW.msg = NFCR.msg
+ NFCW.write()
+ }
+}
+
+struct ContentView_Previews: PreviewProvider {
+ static var previews: some View {
+ ContentView()
+ }
+}
diff --git a/Demo/NFC Read-Write/NFC_Read_Write.entitlements b/Demo/NFC Read-Write/NFC_Read_Write.entitlements
new file mode 100644
index 0000000..894a161
--- /dev/null
+++ b/Demo/NFC Read-Write/NFC_Read_Write.entitlements
@@ -0,0 +1,14 @@
+
+
+
+
+ com.apple.developer.nfc.readersession.formats
+
+ TAG
+
+ com.apple.security.app-sandbox
+
+ com.apple.security.files.user-selected.read-only
+
+
+
diff --git a/Demo/NFC Read-Write/NFC_Read_WriteApp.swift b/Demo/NFC Read-Write/NFC_Read_WriteApp.swift
new file mode 100644
index 0000000..dfa5df1
--- /dev/null
+++ b/Demo/NFC Read-Write/NFC_Read_WriteApp.swift
@@ -0,0 +1,39 @@
+//
+// NFC_Read_WriteApp.swift
+// NFC Read-Write
+//
+// Created by Ming on 1/1/2023.
+//
+
+import SwiftUI
+
+@main
+struct NFC_Read_WriteApp: App {
+ @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
+ var body: some Scene {
+ WindowGroup {
+ ContentView()
+ }
+ }
+}
+
+class AppDelegate: UIResponder, UIApplicationDelegate {
+ var window: UIWindow?
+
+ func application(_ application: UIApplication,
+ continue userActivity: NSUserActivity,
+ restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
+ guard userActivity.activityType == NSUserActivityTypeBrowsingWeb else {
+ return false
+ }
+
+ // Confirm that the NSUserActivity object contains a valid NDEF message.
+ let ndefMessage = userActivity.ndefMessagePayload
+ guard !ndefMessage.records.isEmpty,
+ ndefMessage.records[0].typeNameFormat != .empty else {
+ return false
+ }
+
+ return true
+ }
+}
diff --git a/Demo/NFC Read-Write/Preview Content/Preview Assets.xcassets/Contents.json b/Demo/NFC Read-Write/Preview Content/Preview Assets.xcassets/Contents.json
new file mode 100644
index 0000000..73c0059
--- /dev/null
+++ b/Demo/NFC Read-Write/Preview Content/Preview Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Demo/NFC-Read-Write-Info.plist b/Demo/NFC-Read-Write-Info.plist
new file mode 100644
index 0000000..547f996
--- /dev/null
+++ b/Demo/NFC-Read-Write-Info.plist
@@ -0,0 +1,10 @@
+
+
+
+
+ UIBackgroundModes
+
+ nearby-interaction
+
+
+
diff --git a/Package.swift b/Package.swift
new file mode 100644
index 0000000..ab712f9
--- /dev/null
+++ b/Package.swift
@@ -0,0 +1,26 @@
+// swift-tools-version: 5.4
+// The swift-tools-version declares the minimum version of Swift required to build this package.
+//
+// Created by Ming on 9/1/2023.
+//
+
+import PackageDescription
+
+let package = Package(
+ name: "SwiftNFC",
+ platforms: [
+ .iOS(.v13)
+ ],
+ products: [
+ .library(
+ name: "SwiftNFC",
+ targets: ["SwiftNFC"]),
+ ],
+ dependencies: [
+ ],
+ targets: [
+ .target(
+ name: "SwiftNFC",
+ dependencies: [])
+ ]
+)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4a610e9
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# SwiftNFC - Powerful Read+Write in few lines of Coding
diff --git a/Sources/SwiftNFC/SwiftNFC.swift b/Sources/SwiftNFC/SwiftNFC.swift
new file mode 100644
index 0000000..bf47efe
--- /dev/null
+++ b/Sources/SwiftNFC/SwiftNFC.swift
@@ -0,0 +1,131 @@
+import SwiftUI
+import CoreNFC
+
+@available(iOS 13.0, *)
+public class NFCReader: NSObject, ObservableObject, NFCNDEFReaderSessionDelegate {
+
+ public var startAlert = "Hold your iPhone near the tag."
+ public var endAlert = ""
+ public var msg = "Scan to read or Edit here to write..."
+ public var raw = "Raw Data available after scan."
+
+ public var session: NFCNDEFReaderSession?
+
+ public func read() {
+ guard NFCNDEFReaderSession.readingAvailable else {
+ print("Error")
+ return
+ }
+ session = NFCNDEFReaderSession(delegate: self, queue: nil, invalidateAfterFirstRead: true)
+ session?.alertMessage = self.startAlert
+ session?.begin()
+ }
+
+ public func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
+ DispatchQueue.main.async {
+ self.msg = messages.map {
+ $0.records.map {
+ String(decoding: $0.payload, as: UTF8.self)
+ }.joined(separator: "\n")
+ }.joined(separator: " ")
+
+ self.raw = messages.map {
+ $0.records.map {
+ "\($0.typeNameFormat) \(String(decoding:$0.type, as: UTF8.self)) \(String(decoding:$0.identifier, as: UTF8.self)) \(String(decoding: $0.payload, as: UTF8.self))"
+ }.joined(separator: "\n")
+ }.joined(separator: " ")
+
+
+ session.alertMessage = self.endAlert != "" ? self.endAlert : "Read \(messages.count) NDEF Messages, and \(messages[0].records.count) Records."
+ }
+ }
+
+ public func readerSessionDidBecomeActive(_ session: NFCNDEFReaderSession) {
+ }
+
+ public func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
+ print("Session did invalidate with error: \(error)")
+ self.session = nil
+ }
+}
+
+public class NFCWriter: NSObject, ObservableObject, NFCNDEFReaderSessionDelegate {
+
+ public var startAlert = "Hold your iPhone near the tag."
+ public var endAlert = ""
+ public var msg = ""
+ public var type = "T"
+
+ public var session: NFCNDEFReaderSession?
+
+ public func write() {
+ guard NFCNDEFReaderSession.readingAvailable else {
+ print("Error")
+ return
+ }
+ session = NFCNDEFReaderSession(delegate: self, queue: nil, invalidateAfterFirstRead: true)
+ session?.alertMessage = self.startAlert
+ session?.begin()
+ }
+
+ public func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
+ }
+
+ public func readerSession(_ session: NFCNDEFReaderSession, didDetect tags: [NFCNDEFTag]) {
+ if tags.count > 1 {
+ let retryInterval = DispatchTimeInterval.milliseconds(500)
+ session.alertMessage = "Detected more than 1 tag. Please try again."
+ DispatchQueue.global().asyncAfter(deadline: .now() + retryInterval, execute: {
+ session.restartPolling()
+ })
+ return
+ }
+
+ let tag = tags.first!
+ session.connect(to: tag, completionHandler: { (error: Error?) in
+ if nil != error {
+ session.alertMessage = "Unable to connect to tag."
+ session.invalidate()
+ return
+ }
+
+ tag.queryNDEFStatus(completionHandler: { (ndefStatus: NFCNDEFStatus, capacity: Int, error: Error?) in
+ guard error == nil else {
+ session.alertMessage = "Unable to query the status of tag."
+ session.invalidate()
+ return
+ }
+
+ switch ndefStatus {
+ case .notSupported:
+ session.alertMessage = "Tag is not NDEF compliant."
+ session.invalidate()
+ case .readOnly:
+ session.alertMessage = "Read only tag detected."
+ session.invalidate()
+ case .readWrite:
+ let message = NFCNDEFMessage(records: [NFCNDEFPayload(format: .nfcWellKnown, type: Data("\(self.type)".utf8), identifier: Data(), payload: Data("\(self.msg)".utf8))])
+ tag.writeNDEF(message, completionHandler: { (error: Error?) in
+ if nil != error {
+ session.alertMessage = "Write to tag fail: \(error!)"
+ } else {
+ session.alertMessage = self.endAlert != "" ? self.endAlert : "Write \(self.msg) to tag successful."
+ }
+ session.invalidate()
+ })
+ @unknown default:
+ session.alertMessage = "Unknown tag status."
+ session.invalidate()
+ }
+ })
+ })
+ }
+
+ public func readerSessionDidBecomeActive(_ session: NFCNDEFReaderSession) {
+ }
+
+ public func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
+ print("Session did invalidate with error: \(error)")
+ self.session = nil
+ }
+}
diff --git a/Tests/SwiftNFCTests/SwiftNFCTests.swift b/Tests/SwiftNFCTests/SwiftNFCTests.swift
new file mode 100644
index 0000000..3bd728a
--- /dev/null
+++ b/Tests/SwiftNFCTests/SwiftNFCTests.swift
@@ -0,0 +1,11 @@
+import XCTest
+@testable import SwiftNFC
+
+final class SwiftNFCTests: XCTestCase {
+ func testExample() throws {
+ // This is an example of a functional test case.
+ // Use XCTAssert and related functions to verify your tests produce the correct
+ // results.
+ XCTAssertEqual(SwiftNFC().text, "Hello, World!")
+ }
+}