Skip to content

Commit 75a4a3c

Browse files
committed
fix: fix generating cpp project on iOS
1 parent 0bfd51a commit 75a4a3c

File tree

9 files changed

+17
-10
lines changed

9 files changed

+17
-10
lines changed

packages/create-react-native-library/src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ async function create(argv: yargs.Arguments<any>) {
351351
.replace(/[^a-z0-9](\w)/g, (_, $1) => $1.toUpperCase())
352352
.slice(1)}`,
353353
package: slug.replace(/[^a-z0-9]/g, '').toLowerCase(),
354-
podspec: slug.replace(/[^a-z0-9]+/g, '-').replace(/^-/, ''),
354+
identifier: slug.replace(/[^a-z0-9]+/g, '-').replace(/^-/, ''),
355355
native: languages !== 'js',
356356
cpp: languages === 'cpp',
357357
kotlin: languages === 'kotlin-objc' || languages === 'kotlin-swift',
@@ -417,15 +417,17 @@ async function create(argv: yargs.Arguments<any>) {
417417

418418
await copyDir(NATIVE_COMMON_FILES, folder);
419419

420-
if (options.project.cpp) {
421-
await copyDir(CPP_FILES, folder);
422-
}
423-
424420
if (options.project.swift) {
425421
await copyDir(SWIFT_FILES(type), folder);
426422
} else {
427423
await copyDir(OBJC_FILES(type), folder);
428424
}
425+
426+
if (options.project.cpp) {
427+
await copyDir(CPP_FILES, folder);
428+
await fs.remove(path.join(folder, 'ios', `${options.project.name}.m`));
429+
}
430+
429431
if (options.project.kotlin) {
430432
await copyDir(KOTLIN_FILES(type), folder);
431433
} else {

packages/create-react-native-library/templates/common/$.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ project.xcworkspace
3131

3232
# Android/IJ
3333
#
34-
.idea
34+
.classpath
35+
.cxx
3536
.gradle
37+
.idea
38+
.project
39+
.settings
3640
local.properties
3741
android.iml
3842

packages/create-react-native-library/templates/common/$package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"android",
1414
"ios",
1515
"cpp",
16-
"<%- project.podspec %>.podspec",
16+
"<%- project.identifier %>.podspec",
1717
"!lib/typescript/example",
1818
"!android/build",
1919
"!ios/build",

packages/create-react-native-library/templates/cpp-library/ios/{%- project.name %}.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import "<%- project.name %>.h"
2+
#import "<%- project.identifier %>.h"
23

34
@implementation <%- project.name %>
45

packages/create-react-native-library/templates/example/example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target '<%- project.name %>Example' do
99
use_react_native!(:path => config["reactNativePath"])
1010
<% if (project.native) { -%>
1111
12-
pod '<%- project.podspec %>', :path => '../..'
12+
pod '<%- project.identifier %>', :path => '../..'
1313
<% } -%>
1414
1515
# Enables Flipper.

packages/create-react-native-library/templates/expo-library/example/app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "<%- project.name %> Example",
44
"expo": {
55
"name": "<%- project.slug %>-example",
6-
"slug": "<%- project.podspec %>-example",
6+
"slug": "<%- project.identifier %>-example",
77
"description": "Example app for <%- project.slug %>",
88
"privacy": "public",
99
"version": "1.0.0",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require "json"
33
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
44

55
Pod::Spec.new do |s|
6-
s.name = "<%- project.podspec %>"
6+
s.name = "<%- project.identifier %>"
77
s.version = package["version"]
88
s.summary = package["description"]
99
s.homepage = package["homepage"]

0 commit comments

Comments
 (0)