{"id":28290807,"url":"https://github.com/betulcalik/ios-unity-communication","last_synced_at":"2026-04-20T06:03:11.586Z","repository":{"id":190877843,"uuid":"683472711","full_name":"betulcalik/ios-unity-communication","owner":"betulcalik","description":"This repository is an iOS project that includes iOS and Unity communication.","archived":false,"fork":false,"pushed_at":"2023-08-27T09:42:36.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T08:45:04.747Z","etag":null,"topics":["communication","swift","unity","unityframework"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/betulcalik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-08-26T17:23:14.000Z","updated_at":"2023-12-27T12:15:13.000Z","dependencies_parsed_at":"2025-10-17T06:20:00.832Z","dependency_job_id":"d9a6ffa0-0da4-4558-b165-b60cd678db39","html_url":"https://github.com/betulcalik/ios-unity-communication","commit_stats":null,"previous_names":["betulcalik/ios-unity-communication"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/betulcalik/ios-unity-communication","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betulcalik%2Fios-unity-communication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betulcalik%2Fios-unity-communication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betulcalik%2Fios-unity-communication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betulcalik%2Fios-unity-communication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/betulcalik","download_url":"https://codeload.github.com/betulcalik/ios-unity-communication/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betulcalik%2Fios-unity-communication/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32035276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["communication","swift","unity","unityframework"],"created_at":"2025-05-22T03:12:28.216Z","updated_at":"2026-04-20T06:03:11.581Z","avatar_url":"https://github.com/betulcalik.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- PROJECT LOGO --\u003e\n\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e iOS-Unity Communication \u003c/h1\u003e\n\n  \u003cp align=\"center\"\u003e\n    This repository is an iOS project that includes iOS and Unity communication.\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/betulcalik/ios-unity-communication/tree/main/ios-unity-communication\"\u003e\u003cstrong\u003eExplore the project »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/betulcalik/ios-unity-communication/issues\"\u003eReport Bug\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n---\n\u003c!-- Article and code links --\u003e\n\n\u003ca href=\"https://medium.com/mop-developers/communicate-with-a-unity-game-embedded-in-a-swiftui-ios-app-1cefb38ff439\"\u003e\u003cstrong\u003eCommunicate with a Unity game embedded in a SwiftUI iOS App »\u003c/strong\u003e\u003c/a\u003e\n\n\u003c!-- Table Of Contents --\u003e\n\n## Table Of Contents\n\n### 1. Technologies\n1. Unity\n2. UnityFramework\n3. NativeCallProxy\n\n### 2. Steps to Embed a Unity Game into an iOS Application\n1. Create an Unity project.\n2. Export the Unity project.\n3. Drag and drop the Unity-iPhone.xcodeproj file to the iOS workspace.\n4. Add a new framework to the iOS workspace: \n```\nGeneral \u003e\nFrameworks, Libraries and Embedded Content \u003e\nClick the + button \u003e\nSelect the UnityFramework.framework from the list.\n```\n\n| | |\n|-|-|\n|`NOTE` | You must connect and run on a real device to successful build. |\n\n### 3. iOS to Unity Communication\n1. Create a struct called UnityMessage.\n```\nstruct UnityMessage {\n    let objectName: String?\n    let methodName: String?\n    let messageBody: String?\n}\n```\n2. Create a cache array for cases where Unity is not initialized.\n```\nvar cachedMessages = [UnityMessage]()\n```\n3. Create a sendMessage function to sending message to Unity.\n* Object Name: Name of Unity object.\n* Method Name: Name of Unity method.\n* Message: Message to Unity.\n\n```\nfunc sendMessage(_ objectName: String, methodName: String, message: String) {\n    let msg: UnityMessage = UnityMessage(\n        objectName: objectName,\n        methodName: methodName,\n        messageBody: message)\n\n    // Send the message right away if Unity is initialized, else cache it\n    if isInitialized {\n        unityFramework?.sendMessageToGO(\n            withName: msg.objectName,\n            functionName: msg.methodName,\n            message: msg.messageBody)\n    } else {\n        cachedMessages.append(msg)\n    }\n}\n```\n4. Send message to Unity.\n```\nUnityManager.shared.sendMessage(\n    \"Ball\",\n    methodName: \"SetBallColor\",\n    message: \"red\")\n```\n\n### 4. Unity to iOS Communication\n\n1. Create a NativeCallProxy.h file.\n\n```\n#import \u003cFoundation/Foundation.h\u003e\n\n@protocol NativeCallsProtocol\n@required\n- (void) sendMessageToMobileApp:(NSString*)message;\n// other methods\n@end\n\n__attribute__ ((visibility(\"default\")))\n@interface FrameworkLibAPI : NSObject\n+(void) registerAPIforNativeCalls:(id\u003cNativeCallsProtocol\u003e) aApi;\n\n@end\n```\n\n2. Create a NativeCallProxy.mm file.\n\n```\n#import \u003cFoundation/Foundation.h\u003e\n#import \"NativeCallProxy.h\"\n\n@implementation FrameworkLibAPI\n\nid\u003cNativeCallsProtocol\u003e api = NULL;\n+(void) registerAPIforNativeCalls:(id\u003cNativeCallsProtocol\u003e) aApi\n{\n    api = aApi;\n}\n\n@end\n\nextern \"C\"\n{\n    void sendMessageToMobileApp(const char* message)\n    {\n        return [api sendMessageToMobileApp:[NSString stringWithUTF8String:message]];\n    }\n}\n```\n\n3. Add NativeCallProxy.h and NativeCallProxy.mm files to the Unity.\n4. Create a bridging header file in the iOS project.\n\n```\n#import \u003cUnityFramework/NativeCallProxy.h\u003e\n```\n\n5. Send message to the iOS project using NativeAPI in the Unity project.\n\n```\npublic class NativeAPI {\n    [DllImport(\"__Internal\")]\n    public static extern void sendMessageToMobileApp(string message);\n}\n\npublic void ButtonPressed()\n{\n    pressCount++;\n    NativeAPI.sendMessageToMobileApp(\"The button has been tapped \" + pressCount.ToString() + \" times!\");\n}\n\n```\n\n6. Implement the NativeCallsProtocol in the iOS project. And get message from Unity using sendMessage() function.\n\n```\nextension ViewController: NativeCallsProtocol {\n    func sendMessage(toMobileApp message: String) {\n        print(message)\n    }\n}\n```\n\n### 3. Application Overview\n\nhttps://github.com/betulcalik/ios-unity-communication/assets/80328286/f54bb24d-9ba2-473c-b847-1da6c9050078\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetulcalik%2Fios-unity-communication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetulcalik%2Fios-unity-communication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetulcalik%2Fios-unity-communication/lists"}