{"id":118812,"date":"2021-03-01T06:57:11","date_gmt":"2021-03-01T05:57:11","guid":{"rendered":"https:\/\/blog.jetbrains.com\/?post_type=objc&#038;p=118812"},"modified":"2021-03-01T06:57:11","modified_gmt":"2021-03-01T05:57:11","slug":"server-side-swift-in-appcode","status":"publish","type":"appcode","link":"https:\/\/blog.jetbrains.com\/fr\/appcode\/2021\/03\/server-side-swift-in-appcode","title":{"rendered":"Server-side Swift in AppCode"},"content":{"rendered":"<p>In this short article we\u2019ll take a look at various AppCode features that are useful for server-side Swift development, as now you can open standalone SPM projects in AppCode on macOS. <\/p>\n<h2 id=\"check_out_and_open_the_project\">Check out and open the project<\/h2>\n<p>On the Welcome screen, click the <strong>Get from VCS <\/strong>button and enter the address of the <a href=\"https:\/\/github.com\/FeatherCMS\/feather\" target=\"_blank\" rel=\"noopener\">Feather<\/a> repository:<\/p>\n<p><img decoding=\"async\" alt=\"Get from VCS\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/welcome_spm-2x.png\"\/><\/p>\n<p>Click <strong>Clone<\/strong>. As soon as the project is checked out, it will be automatically opened in AppCode. After loading the project, AppCode will start syncing its dependencies declared in <code>Package.swift<\/code>. You can manually invoke the synchronization later from <code>Tools | Swift Package Manager<\/code> of from the <strong>Project<\/strong> view context menu:<\/p>\n<p><img decoding=\"async\" alt=\"SPM actions\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/spm_actions-2x.png\"\/><\/p>\n<h2 id=\"code_assistance\">Code Assistance<\/h2>\n<p>All the code assistance available for Xcode projects works in pure SPM ones:<\/p>\n<p><img decoding=\"async\" alt=\"SPM code assistance\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/code_assistance-2x.png\"\/><\/p>\n<h2 id=\"run_and_debug\">Run and Debug<\/h2>\n<p>Once the synchronization is complete, run configurations for executable targets and tests are automatically created in AppCode:<\/p>\n<p><img decoding=\"async\" alt=\"Run configurations\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/run_configurations-2x.png\"\/><\/p>\n<p>To run the project, we need to generate the <code>.env<\/code> file. We can do this easily by executing the <code>make env<\/code> command via <strong>Run Anything<\/strong> (<code>Double \u2303<\/code>):<\/p>\n<p><img decoding=\"async\" alt=\"Run Anything\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/run_anything-2x.gif\"\/><\/p>\n<p>Next, as all the resources needed for running our blog are stored in the root folder of the project. We need to point the <code>Feather<\/code><strong> <\/strong>run configuration to this directory:<\/p>\n<p><img decoding=\"async\" alt=\"Set work directory\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/set_work_dir-2x.png\"\/><\/p>\n<p>After that, we can run the project locally and open the blog in a browser by clicking on the link in the <strong>Run<\/strong> console:<\/p>\n<p><img decoding=\"async\" alt=\"Run console\" width=\"800\" src=\"https:\/\/resources.jetbrains.com\/storage\/products\/blog\/wp-content\/uploads\/AppCode\/run_feather@2x.gif\"\/><\/p>\n<p>Or you can add an additional step directly into the <strong>Feather <\/strong>run configuration to make the browser open automatically:<\/p>\n<p><img decoding=\"async\" alt=\"Launch web browser\" width=\"790\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/launch_web-2x.png\"\/><\/p>\n<p>Debugging works in the same way as it does in Xcode projects, with all the same features. Just select the target you\u2019d like to debug and press <code>\u2303D<\/code>.<\/p>\n<h2 id=\"html_and_javascript\">HTML and JavaScript<\/h2>\n<p>Though <a href=\"https:\/\/github.com\/vapor\/leaf.git\" target=\"_blank\" rel=\"noopener\">Leaf<\/a> templates are not supported by AppCode, you may find <a href=\"https:\/\/www.jetbrains.com\/help\/objc\/editing-html-files.html\" target=\"_blank\" rel=\"noopener\">HTML<\/a> and <a href=\"https:\/\/www.jetbrains.com\/help\/objc\/javascript-specific-guidelines.html\" target=\"_blank\" rel=\"noopener\">JavaScript<\/a> support useful for pure HTML and JavaScript files: <\/p>\n<p><img decoding=\"async\" alt=\"HTML code assistance\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/html_assist-2x.png\"\/><\/p>\n<h2 id=\"docker\">Docker<\/h2>\n<p>We can run the Docker image included in the Feather project to test it on Linux:<\/p>\n<ul>\n<li>\nInstall the <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/7724-docker\" target=\"_blank\" rel=\"noopener\">Docker plugin<\/a> from <code>Preferences | Plugins<\/code>\n<\/li>\n<li>\nOpen the <code>docker\/docker-compose.yml<\/code> file\n<\/li>\n<li>\nPress <code>\u21e7\u2303R<\/code> to execute <code>docker-compose up<\/code>\n<\/li>\n<\/ul>\n<p>And that\u2019s it: as soon as the docker image is started, we can navigate to <code>0.0.0.0:8080<\/code> and see the Feather-powered blog. <\/p>\n<p>If you need to edit the <code>Dockerfile<\/code>, simply open it in AppCode and the range of code assistance features will be available:<\/p>\n<p><img decoding=\"async\" alt=\"Docker code assistance\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/docker_assist-2x.png\"\/><\/p>\n<p>The same is true for <code>docker-compose.yml,<\/code> as YAML support is bundled in AppCode by default. <\/p>\n<h2 id=\"databases\">Databases<\/h2>\n<p>AppCode has a built-in database client, just like <a href=\"https:\/\/www.jetbrains.com\/datagrip\/\" target=\"_blank\" rel=\"noopener\">DataGrip<\/a>: <\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/fdcIKvhxGv8\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/p>\n<p>It allows you to connect to any database, local or remote. For example, we can use it to view the contents of <code>db.sqlite<\/code> in our project:<\/p>\n<p><img decoding=\"async\" alt=\"Database\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/database-2x.png\"\/><\/p>\n<h2 id=\"requests_testing\">Requests testing<\/h2>\n<p>To test an HTTP request, simply execute <code>Tools | HTTP Client | Test RESTful Web Service<\/code>, enter the URL you\u2019d like to test, and press <code>\u21e7\u2303R<\/code>:<\/p>\n<p><img decoding=\"async\" alt=\"HTTP Client\" width=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/02\/http_client-2x.png\"\/><\/p>\n<p>The formatted response will be displayed in the dedicated tool window. To save your requests, just put the <code>.http<\/code> file in one of the project folders. <\/p>\n<p>That\u2019s it! We hope that the long-awaited standalone SPM project support in AppCode will make your development process easier and faster. <\/p>\n<p><em>Your AppCode team<\/em><br \/>\n<em>JetBrains<\/em><br \/>\n<em>The Drive to Develop<\/em><\/p>\n","protected":false},"author":437,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","categories":[4244,89,601],"tags":[6482,325,600,198,197,725,721],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/appcode\/118812"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/appcode"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/types\/appcode"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/users\/437"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/comments?post=118812"}],"version-history":[{"count":2,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/appcode\/118812\/revisions"}],"predecessor-version":[{"id":118814,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/appcode\/118812\/revisions\/118814"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/media?parent=118812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/categories?post=118812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/tags?post=118812"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/cross-post-tag?post=118812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}