Building NFC extension for iOS

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
trevix
Posts: 1070
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Building NFC extension for iOS

Post by trevix » Wed Jul 30, 2025 6:02 pm

I am building a LCB extension that should enable LC standalone to read text from NFC tags.
I am doing this using Claude Code (couldn't do without...) and direct CoreNFC system framework binding.

Apple Developer setup should be correct: Bundle ID, provisioning profile, and entitlements properly configured
Everything seems to work, compile, install, init, but return false on nfcIsAvailable().
The custom plist, loaded in the copy pane, is fine but Claude (ha!) thinks that:
LiveCode's standalone builder is NOT extracting and applying these entitlements to the final app binary


Any info you can share on this?
I have been running circles for a while now. The last thing suggested by Claude is to manually inject the entitlements after the build.
Beside how annoying this is, having to create a standalone and side load it to my iPhone 8 instead of yusing "Test", is this a correct approach?

Thanks for any help.
PS: since LC does not update LCB, it would be nice at least to have a list of things that they know don't work with it. It would be helpful.
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

trevix
Posts: 1070
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Building NFC extension for iOS

Post by trevix » Wed Jul 30, 2025 6:05 pm

Forgot the lcb code:

Code: Select all

public handler nfcIsAvailable() returns Boolean
    IOSLog("DEBUGLCB: === COMPREHENSIVE NFC DIAGNOSTICS ===")
    IOSLog("DEBUGLCB: Architecture: " & the architecture)
    IOSLog("DEBUGLCB: Operating system: " & the operating system)
    
    -- Diagnostic 1: Get runtime app info
    unsafe
        variable tDevice as ObjcId
        variable tBundle as ObjcId
        variable tBundleId as ObjcId
        variable tSystemVersion as ObjcId
        
        put ObjC_UIDevice_currentDevice() into tDevice
        put ObjC_UIDevice_systemVersion(tDevice) into tSystemVersion
        put ObjC_NSBundle_mainBundle() into tBundle
        put ObjC_NSBundle_bundleIdentifier(tBundle) into tBundleId
        
        IOSLog("DEBUGLCB: iOS Version: " & StringFromNSString(tSystemVersion))
        IOSLog("DEBUGLCB: Bundle ID: " & StringFromNSString(tBundleId))
    end unsafe
    
    if not _IsIOSNFCSupported() then
        IOSLog("DEBUGLCB: _IsIOSNFCSupported returned false")
        put "DEBUG: iOS NFC not supported" into sLastError
        return false
    end if
    
    -- On simulator, NFC not available
    if the architecture is "x86_64" then
        IOSLog("DEBUGLCB: x86_64 simulator detected - NFC unavailable")
        put "DEBUG: x86_64 simulator - NFC unavailable" into sLastError
        return false
    end if
    
    -- DIRECT CORENFC TEST 
    IOSLog("DEBUGLCB: === DIRECT CORENFC TEST ===")
    IOSLog("DEBUGLCB: About to call CoreNFC readingAvailable method directly")
    
    unsafe
        variable tResult as Boolean
        put ObjC_NFCNDEFReaderSession_readingAvailable() into tResult
        IOSLog("DEBUGLCB: CoreNFC method call completed successfully")
        
        if tResult then
            IOSLog("DEBUGLCB: ✅ CoreNFC readingAvailable returned TRUE - NFC IS AVAILABLE!")
            put "SUCCESS: CoreNFC readingAvailable returned TRUE" into sLastError
        else
            IOSLog("DEBUGLCB: ❌ CoreNFC readingAvailable returned FALSE")
            IOSLog("DEBUGLCB: 🔍 MOST LIKELY CAUSES:")
            IOSLog("DEBUGLCB: 1. ❌ NFC entitlements missing from app build")
            IOSLog("DEBUGLCB: 2. ❌ Provisioning profile missing NFC capability")
            IOSLog("DEBUGLCB: 3. ❌ Bundle ID doesn't match Apple Developer NFC configuration")
            IOSLog("DEBUGLCB: 4. ❌ App code signing issue")
            IOSLog("DEBUGLCB: 5. ❌ Device NFC hardware disabled in Settings")
            put "DIAGNOSTIC: CoreNFC method works but returns FALSE - likely entitlement issue" into sLastError
        end if
        
        return tResult
    end unsafe
end handler
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Post Reply