{"id":15018421,"url":"https://github.com/nativescript/plugin-ios-modulemap-sample","last_synced_at":"2026-01-15T22:11:23.389Z","repository":{"id":141979740,"uuid":"112740468","full_name":"NativeScript/plugin-ios-modulemap-sample","owner":"NativeScript","description":"This sample demonstrates how to use a manually generated module.modulemap file for the consumption of a native library within a plugin.","archived":false,"fork":false,"pushed_at":"2017-12-01T15:51:36.000Z","size":2098,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T11:22:52.515Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/NativeScript.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}},"created_at":"2017-12-01T13:01:02.000Z","updated_at":"2019-03-20T22:05:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"5c2d1221-4e94-4c89-8868-57cbbd3e6a89","html_url":"https://github.com/NativeScript/plugin-ios-modulemap-sample","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.33333333333333337","last_synced_commit":"0c60867711ba1540f91ef49739612656809ea9ec"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NativeScript%2Fplugin-ios-modulemap-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NativeScript%2Fplugin-ios-modulemap-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NativeScript%2Fplugin-ios-modulemap-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NativeScript%2Fplugin-ios-modulemap-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NativeScript","download_url":"https://codeload.github.com/NativeScript/plugin-ios-modulemap-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247093413,"owners_count":20882405,"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":[],"created_at":"2024-09-24T19:51:56.759Z","updated_at":"2026-01-15T22:11:23.348Z","avatar_url":"https://github.com/NativeScript.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\nThis sample demonstrates how to use a manually generated `module.modulemap` file for the consumption of a native library within a plugin.\n\n# Motivation\nWhen you design a NativeScript plugin consuming a native iOS library for which you must create a `module.modulemap` you may encounter problems with consuming the native iOS types with JavaScript code. These problems boil down to several factors:\n\n- you are using a version of NPM greater or equal to 5\n- you are installing the plugin from a local folder, i.e. a cloned Github repository\n\nWhen installing a plugin from a local folder with NPM 5 or later, the plugin source is added in the NativeScript app's `node_modules` folder as a symlink. Because of the symlink, upon build, when the NativeScript metadata generator iterates over the headers of the native libraries, the paths within your `module.modulemap` may not be resolved correctly thus preventing NativeScript from generating metadata for your native library. To prevent this from hapenning you need to move the affected `module.modulemap` outside of the symlinked folder and update the paths in it correspondingly. You will also need to update the `build.xcconfig` file describing the `HEADER_SEARCH_PATHS` for the native library to point to the new `module.modulemap` location.\n\nThis sample implements an automated approach for doing this by integrating NativeScript hooks into your plugin. These hooks will copy the `module.modulemap` file into a dedicated folder in the `platforms/ios` directory of your NativeScript app when the `tns prepare ios` command is executed (directly or indirectly).\n\n# Dependencies\nTo work with NativeScript hooks you will need to install the `nativescript-hook` plugin and integrate it into your plugin as instructed here: https://github.com/NativeScript/nativescript-hook\n\n# Implementation\nThe sample implements a scenario in which a NativeScript app references two plugins that use static native libraries coming from Pods. Both plugins define `module.modulemap` files to expose the native APIs of the corresponding libraries. A NativeScript hook is used to copy the module maps after the plugin is prepared to a location within the app's `platforms/ios` folder. \n\n## Sample source\n\n### after-prepare hook\n```\nconst sourceMapLocation = '/node_modules/plugin1/platforms/ios/module.modulemap';\nconst targetMapLocation = '/platforms/ios/GVRSDK/module.modulemap';\nconst projectMapFolder = '/platforms/ios/GVRSDK/';\nmodule.exports = function (logger, platformsData, projectData, hookArgs, $usbLiveSyncService) {\n    var fs = require('fs');\n    let targetMapFolder = projectData.projectDir + projectMapFolder;\n    if (!fs.existsSync(targetMapFolder)) {\n        fs.mkdirSync(targetMapFolder);\n    }\n    fs.copyFileSync(projectData.projectDir + sourceMapLocation, projectData.projectDir + targetMapLocation);\n}\n```\n### module.modulemap contents\nAnd here's a sample of how the `module.modulemap` will look like:\n\n```\nmodule GVRSDK {\n    umbrella \"../Pods/GVRSDK/Sources\"\n    export *\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativescript%2Fplugin-ios-modulemap-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnativescript%2Fplugin-ios-modulemap-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativescript%2Fplugin-ios-modulemap-sample/lists"}