Creating a New Project
After installing the Poly CLI, you can now create a new Poly project:
poly generate --name=MyNewApp --package=org.mythis generates a new Poly application called “MyNewApp” under the package identifier “org.my”. The package identifier corresponds to:
- the organization identifier in Xcode when creating a new app; and
- the application ID in GTK when creating a new GTK application, minus the application name.
Creating the Project In a Separate Directory
You can pass the --output flag to generate the project in a different directory:
poly generate --name=MyNewApp --package=org.my --output=../projectThis outputs the MyNewApp directory in the project directory that is in the parent directory of the current working directory.
Project Structure
The command generates a directory named MyNewApp in the current working directory that has the following structure:
MyNewApp/├── gtk/│ ├── packaging/│ │ ├── rpm/│ │ │ └── app.spec│ │ └── launch.sh│ ├── src/│ │ └── main.cxx│ └── CMakeLists.txt├── macOS/│ ├── MyNewApp/│ │ ├── AppDelegate.swift│ │ └── main.swift│ └── project.yml└── app/ ├── src/ │ └── main.ts ├── package.json └── tsconfig.jsongtk: the entry point to the GTK layer of the application. It contains all the necessary components to build the application as a GTK application that can run on Linux.packaging: this directory contains files that is required when packaging the GTK application.launch.sh: this is the launch script for the application when it is installed. It sets up the correct environment for the application. When running the installed application,launch.shwill be invoked.rpm: this directory contains files that are required to package the application as a.rpmpackage.
macOS: the entry point to the AppKit layer of the application. It contains all the necessary components to build the application as an AppKit application that can run on macOS.project.yml: Thexcodegenspec for the XCode project. When the project is created in macOS,xcodegen generatewill be run automatically, which will generateMyNewApp.xcodeproj. The AppKit project can then be opened in XCode.
app: the directory that contains code for the portable layer. Poly only supports TypeScript for now, soappwill contain a TypeScript project. All application logic will go in this directory.
Running the Project
In order to run the project, change into the app directory, and then run the build NPM script:
npm run buildMacOS
If the .xcodeproj file is not present, generate it by changing into the macOS directory and running xcodegen:
xcodegen generateOpen the .xcodeproj in XCode, and then run the project.