Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new setBuildSettings directive for iOS plugin configuration #1196

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/platform-parts/manifest/native-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,21 @@ Adds a source file from the plugin project to the container list of sources.
"path": "ElectrodeReactNativeBridge/ElectrodeObject.swift",
"group": "ElectrodeReactNativeBridge"
}
```

- `setBuildSettings`

Set one or more build setting(s) in one or more pbxproj(s) associated to the plugin.
For example setting `ENABLE_BITCODE` to `NO` for `Debug` and `Release` configurations of `Foo` plugin project :

```json
"setBuildSettings": [
{
"path": "{{{projectName}}}/Libraries/Foo/Foo.xcodeproj/project.pbxproj",
"buildSettings": {
"configurations": ["Debug", "Release"],
"settings": { "ENABLE_BITCODE": "NO" }
}
}
]
```
21 changes: 21 additions & 0 deletions ern-core/src/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ export interface IosPluginConfig extends CommonPluginConfig {
* Directives specific to Container pbxproj patching
*/
pbxproj: PbxProjDirectives
/**
* Set specific build settings in the plugin pbxproj
*/
setBuildSettings?: IosPluginSetBuildSettingsDirective[]
}

/**
Expand Down Expand Up @@ -329,6 +333,23 @@ export interface IosPluginAddProjectDirective {
group: string
}

export interface IosPluginBuildSettings {
/**
* Configuration(s) for which these build settings apply.
* For example [ 'Debug' , 'Release' ]
*/
configurations: string[]

/**
* Build settings as key values pairs
*/
settings: { [key: string]: string }
}
export interface IosPluginSetBuildSettingsDirective {
path: string
buildSettings: IosPluginBuildSettings[] | IosPluginBuildSettings
}

/**
* iOS Static library representation
*/
Expand Down
29 changes: 29 additions & 0 deletions ern-core/src/iosUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,35 @@ export async function fillProjectHull(
}
}

if (pluginConfig.ios.setBuildSettings) {
for (const s of pluginConfig.ios.setBuildSettings) {
const pathToPbxProj = path.join(pathSpec.outputDir, s.path)
// Add any missing section in the target pbxproj
// This is necessary for proper parsing and modification of
// the pbxproj with the xcode-ern library
xcode
.pbxProjFileUtils()
.addMissingSectionsToPbxProj(pathToPbxProj)
const iosProj = await getIosProject(projectPath)
const buildSettings =
s.buildSettings instanceof Array
? s.buildSettings
: [s.buildSettings]
for (const buildSettingsEntry of buildSettings) {
for (const buildType of buildSettingsEntry.configurations) {
for (const key of Object.keys(buildSettingsEntry.settings)) {
iosProj.updateBuildProperty(
key,
buildSettingsEntry.settings[key],
buildType
)
}
}
}
fs.writeFileSync(pathToPbxProj, iosProj.writeSync())
}
}

if (pluginConfig.ios.pbxproj) {
if (pluginConfig.ios.pbxproj.addSource) {
for (const source of pluginConfig.ios.pbxproj.addSource) {
Expand Down