xcode cocoapods 创建的工作区被锁定

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18109327/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:40:24  来源:igfitidea点击:

Workspace created by cocoapods is locked

xcodecocoapods

提问by kmithi

I'm using CocoaPods with a project. I ran pod installand it installed correctly. Then when I try to open the created xcworkspaceXcode displaying the error 'workspace file is locked'. I tried to unlock it but it's not working. It also didn't include some frameworks (Security.framework, MobileCoreServices.framework etc.) in workspace.

我在一个项目中使用 CocoaPods。我跑了pod install,它安装正确。然后当我尝试打开创建的xcworkspaceXcode 时显示错误“工作区文件已锁定”。我试图解锁它,但它不起作用。它也没有在工作区中包含一些框架(Security.framework、MobileCoreServices.framework 等)。

回答by Heinous Games

I had this problem recently. I don't know about the missing frameworks, but if you go to your project folder within terminal and modify the permissions on the project files, you should be able to open the project. I personally had to modify multiple files and folders to be able to get it to stop asking me if I want to unlock my files.

我最近遇到了这个问题。我不知道缺少的框架,但是如果您转到终端中的项目文件夹并修改项目文件的权限,您应该能够打开该项目。我个人不得不修改多个文件和文件夹才能让它停止询问我是否要解锁我的文件。

Steps that Worked for Me:

对我有用的步骤:

Use the terminal to go to the folder that contains the xcworkspace file. Type

使用终端转到包含 xcworkspace 文件的文件夹。类型

sudo chmod 777 NameOfYourWorkspaceFile.xcworkspace 

(Please don't literally use that file name unless that's what your xcworkspace file is called). This should change the permissions for your entire workspace, but you will still have the unlock problem with your Pods project.

(请不要从字面上使用该文件名,除非这是您的 xcworkspace 文件的名称)。这应该会更改整个工作区的权限,但您的 Pods 项目仍然会遇到解锁问题。

From within the same directory, you can do another chmod on the Pods folder like so:

在同一目录中,您可以在 Pods 文件夹上执行另一个 chmod,如下所示:

sudo chmod 777 Pods

After that, go into your Pods folder by typing "cd Pods" and then modify the permissions on your Pods.xcodeproj file as so:

之后,输入“cd Pods”进入 Pods 文件夹,然后修改 Pods.xcodeproj 文件的权限,如下所示:

sudo chmod 777 Pods.xcodeproj

Like I said previously, these permission changes were enough to get xCode to stop asking me if I want to unlock my projects. I don't know if it will be enough for you though. Hopefully it helps!

就像我之前说的,这些权限更改足以让 xCode 停止询问我是否要解锁我的项目。我不知道这对你来说是否足够。希望它有帮助!

回答by DavidCollado

I had the same 'locked workspace' problem.

我有同样的“锁定工作区”问题。

The root of my problem was that I was running sudo pod installinstead of pod install. If I ran pod installI got:

我的问题的根源在于我正在运行sudo pod install而不是pod install. 如果我跑pod install我得到:

[!] Pod::Executable pull 
error: cannot open .git/FETCH_HEAD: Permission denied   

The problem is that running sudo pod install, the root is creating the .xcworkspace and when you open it with your user, it says that the project is locked.

问题在于运行时sudo pod install,root 正在创建 .xcworkspace,当您与用户一起打开它时,它说该项目已锁定。

What I did was change the permissions to be able to run pod installby doing:

我所做的是pod install通过执行以下操作更改权限以使其能够运行:

sudo chown -R $USER ~/Library/Caches/CocoaPods
sudo chown -R $USER ~/.cocoapods

Changing these permissions, the command pod installshould work and the generated .xcworkspace should not be locked.

更改这些权限,命令pod install应该可以工作并且生成的 .xcworkspace 不应该被锁定。

I hope this helps someone!

我希望这可以帮助别人!