How to use SFML in xcode arm64 macOS Big Sur Apple M1 chip

  arm64, c++, macos, sfml, xcode

I have been trying to run a sample SFML c++ program on Xcode. I am new to SFML. I want to build a simple basic car game using SFML c++. I have downloaded SFML and moved the SFML frameworks and items in exlibs to the frameworks folder (in the library folder). I have also added templates by creating an Xcode folder in the developer folder (in the library folder).
I am new to mac and xcode.
Please help.
It gives the following error:
[ERROR][1] This is the code:

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include "ResourcePath.hpp"

int main(int, char const**)
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    sf::Image icon;
    if (!icon.loadFromFile(resourcePath() + "icon.png")) {
        return EXIT_FAILURE;
    }
    window.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());
    sf::Texture texture;
    if (!texture.loadFromFile(resourcePath() + "cute_image.jpg")) {
        return EXIT_FAILURE;
    }
    sf::Sprite sprite(texture);
    sf::Font font;
    if (!font.loadFromFile(resourcePath() + "sansation.ttf")) {
        return EXIT_FAILURE;
    }
    sf::Text text("Hello SFML", font, 50);
    text.setFillColor(sf::Color::Black);
    sf::Music music;
    if (!music.openFromFile(resourcePath() + "nice_music.ogg")) {
        return EXIT_FAILURE;
    }
    music.play();
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
                window.close();
            }
        }
        window.clear();
        window.draw(sprite);
        window.draw(text);
        window.display();
    }

    return EXIT_SUCCESS;
}```


  [1]: https://i.stack.imgur.com/JjieP.png

Source: Windows Questions C++

LEAVE A COMMENT