{"id":17957659,"url":"https://github.com/evanbacon/expo-swift-example","last_synced_at":"2025-03-25T02:31:52.801Z","repository":{"id":105127799,"uuid":"145757544","full_name":"EvanBacon/expo-swift-example","owner":"EvanBacon","description":"Example of writing Swift modules in Expo","archived":false,"fork":false,"pushed_at":"2018-08-22T20:20:01.000Z","size":3683,"stargazers_count":12,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-19T07:32:32.490Z","etag":null,"topics":["cross-platform","expo","ios","native-modules","react-native","swift"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/EvanBacon.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}},"created_at":"2018-08-22T20:09:28.000Z","updated_at":"2024-09-07T03:52:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"0afa996d-d0b8-4560-b940-8ff30b701490","html_url":"https://github.com/EvanBacon/expo-swift-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvanBacon%2Fexpo-swift-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvanBacon%2Fexpo-swift-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvanBacon%2Fexpo-swift-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvanBacon%2Fexpo-swift-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EvanBacon","download_url":"https://codeload.github.com/EvanBacon/expo-swift-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245385549,"owners_count":20606668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cross-platform","expo","ios","native-modules","react-native","swift"],"created_at":"2024-10-29T10:55:57.461Z","updated_at":"2025-03-25T02:31:52.796Z","avatar_url":"https://github.com/EvanBacon.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# expo-swift-example\n\nExample of writing Swift modules in Expo\n\n## How To\n\nFirst detach your expo project with:\n```sh \nexp detach\n```\n\nThen open your iOS project, and add a swift file. You will also need a `.m` file of the same name.\n\n* `DemoModule.swift`\n* `DemoModule.m`\n\nYou should have been prompted to add a bridging header.\nTo check to make sure your header is linked:\n* Click on the project Icon (Blue icon on the top left)\n* Click the **Build Settings** tab\n* Go to the section **Swift Compiler - General**\n  * The value for **Objective-C Bridging Header** should be `[project]/[project]-Bridging-Header.h`. \n  * Ex: `expo-swift-example/expo-swift-example-Bridging-Header.h`\n\nIn your bridging header, import React Native libraries:\n```objc\n#import \u003cReact/RCTBridgeModule.h\u003e\n#import \u003cReact/RCTEventEmitter.h\u003e\n```\n\nNow in your swift file:\n```swift\n@objc(DemoModule)\nclass DemoModule: RCTEventEmitter {\n    @objc func someMethod(_ input: String) -\u003e Void {}\n    override func supportedEvents() -\u003e [String]! {\n      return []\n    }\n    @objc override func constantsToExport() -\u003e [AnyHashable : Any]! {\n      return []\n    }\n}\n```\n\nIn your `.m` file:\n```objc\n#import \u003cReact/RCTBridgeModule.h\u003e\n#import \u003cReact/RCTEventEmitter.h\u003e\n@interface RCT_EXTERN_MODULE(DemoModule, NSObject)\nRCT_EXTERN_METHOD(someMethod:(NSString *)input);\n@end\n```\n\n\nAnd in JS:\n\n```js\nimport { NativeModules } from 'react-native';\nNativeModules.DemoModule.someMethod(input);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanbacon%2Fexpo-swift-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevanbacon%2Fexpo-swift-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanbacon%2Fexpo-swift-example/lists"}