Cocos2d-x v4 adding new file after installing

Hi,

I was using v3.17 but Apple will not allow contains UIWebKit from April, 2020 for new app. So, I want to start new project with new version. I downloaded v4 from website. I created new project.

cocos new Test -l cpp -p com.Kemal.Test

After, I run cmake command according to docs (https://github.com/cocos2d/cocos2d-x/blob/v4/cmake/README.md#generate-macos-project).
I opened xcodeproj in ios-build folder. I fix bundle identifier and certificate for device running. It built. Here, I don’t have any problem.

Later, I created new header file and called “Definitions.h”. I include this file to HelloWorldScene.cpp (#include “Definitions.h”). And, ‘Definitions.h’ file not found. I don’t know that how to work cmake system but I added to list for cross-platforms.

list(APPEND GAME_HEADER
Classes/AppDelegate.h
Classes/HelloWorldScene.h
Definitions.h
)

In this time, Xcode build always cancelled. Also, I removed “Definitions.h” from list, but I can’t build. I checked signing and this values is removed. I fixed this values but this values is removed when I rebuild project. On the other hand, I’m trying to build for simulator and still cancelled.

How can I add new file to project?

Thanks.

1 Like

is it in Classes/Definitions.h? How a screen shot of your project folder.

I create new file right click to classes folder in Xcode.

But this file created in project main folder.

So, I added to “Definitions.h”, but I moved to classes folder and updated list with Classes/Definitions.h now. Xcode still cancel build.

I think, I understand that how to work :slight_smile:

I want to write shortly for information. First of all, I don’t like that I need to select signing certificate in each build. So, I added this options to CMake file.

set_xcode_property(${APP_NAME} PRODUCT_BUNDLE_IDENTIFIER "com.Kemal.Test")
set_xcode_property(${APP_NAME} CODE_SIGN_STYLE "Manual")
set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "Apple Development")
set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM[variant=Debug] "xxxxxxxxxx")
set_xcode_property(${APP_NAME} PROVISIONING_PROFILE_SPECIFIER[variant=Debug] "Kemal Demos")

Later, I said in previous post. When I added new file in Xcode, this file location is wrong. I moved to Classes folder. Then, I added to h (GAME_HEADER) and cpp (GAME_SOURCE) list in CMake. This wrong folder problem exist that creating folder. If I create folder in Xcode, I need to create physical location. Later, I select location for that folder in Xcode. In addition, I must add this folder name to target_include_directories in CMake file. Finally, If I create new file, I need to run CMake code in terminal.

cmake … -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos

Lastly, I’m working in debug mode, I don’t know that how to work in relesae mode :slight_smile:

If I wrote wrong information any part, feel free to fix please :slight_smile: Thanks.

1 Like

From https://github.com/cocos2d/cocos2d-x/blob/v4/cmake/README.md#tips:

Don’t need CMAKE_BUILD_TYPE options when -G Xcode or Visual Studio, CMake scripts will generate both configurations, so you can switch Debug and Release in IDE.

2 Likes