Cannot build blender

Hello, I tried to build blender in my m1 mac, by following Building Blender/Mac - Blender Developer Wiki , but it didn’t work.

Following is the error message, seems like a permission problem, but please let me know what I should do.

Showing Recent Issues
PhaseScriptExecution CMake\ PostBuild\ Rules /Users/kybin/blender-git/build_xcode/Blender.build/Debug/install.build/Script-93426DA6A4AC2C2AC9CE883C.sh (in target 'install' from project 'Blender')
    cd /Users/kybin/blender-git/blender
    /bin/sh -c /Users/kybin/blender-git/build_xcode/Blender.build/Debug/install.build/Script-93426DA6A4AC2C2AC9CE883C.sh

-- Install configuration: "Debug"
-- Installing: /usr/local/Blender.app/Contents/Resources/3.1/scripts
CMake Error at source/creator/cmake_install.cmake:47 (file):
  file INSTALL cannot make directory
  "/usr/local/Blender.app/Contents/Resources/3.1/scripts": No such file or
  directory.
Call Stack (most recent call first):
  cmake_install.cmake:48 (include)


Command PhaseScriptExecution failed with a nonzero exit code

In further investigation, I found cmake_install.cmake has these lines, which causes the problem in my guess. But still don’t know what to do.

if(NOT DEFINED CMAKE_INSTALL_PREFIX)
  set(CMAKE_INSTALL_PREFIX "/usr/local")
endif()

I noticed that I’ve already build blender with make command in the guide. Still, it would be great that I can build inside of XCode.

Thanks!

I got it working.

What I did is removing of the build_xcode directory and rebuild with cmake . -B ../build_xcode/ -G "Xcode".

I guess what causes the problem is that I set path of cmake executable (xcode-select --reset) after the folder is generated.