xcode 打开模块“Swift”的导入文件权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30196440/
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
Opening import file for module 'Swift' Permission denied
提问by ggomersall
I'm a newbie at working in Xcode and swift. I was working on a iOS project on my macbook (while on holiday), and i've been using github version control, i've now returned to home and now working on my mac mini. Currently working in Xcode 6.3.1 and the target is for iOS 8.3
我是 Xcode 和 swift 工作的新手。我在我的 macbook 上做一个 iOS 项目(在假期里),我一直在使用 github 版本控制,我现在回到家,现在在我的 mac mini 上工作。目前在 Xcode 6.3.1 中工作,目标适用于 iOS 8.3
So i've cloned my project on the mac mini, and when opening and trying to build the project i get the error:
所以我在 mac mini 上克隆了我的项目,当打开并尝试构建项目时,我收到错误:
Opening import file for module 'Swift': Permission denied
打开模块“Swift”的导入文件:权限被拒绝
I'm looking at the errors and it seems to be 4 issues, my AppDelegate.swift, and 3 ViewController.swift files (i only have 3 of these at the moment)
我正在查看错误,似乎有 4 个问题,我的 AppDelegate.swift 和 3 个 ViewController.swift 文件(我目前只有其中的 3 个)
I've had a look at another question on here - Opening import file for module 'Swift': Permission deniedbut it's not relevant to my issue.
我在这里查看了另一个问题 - Opening import file for module 'Swift': Permission denied但它与我的问题无关。
A couple things i noticed were
我注意到的几件事是
- some of my frameworks i.e. parse and bolts were highlighted in red, i pointed them to the location of these on my mac mini (not sure if that was the correct thing to do), but they aren't highlighted anymore.
- Under the products folder, my .app and .xctest files are highlighted red. Not sure how to fix that
- 我的一些框架,即解析和螺栓以红色突出显示,我将它们指向我的 mac mini 上的这些位置(不确定这是否正确),但它们不再突出显示。
- 在产品文件夹下,我的 .app 和 .xctest 文件以红色突出显示。不知道如何解决这个问题
Has anyone encountered this before? I would really appreciate the help from you guys.
有没有人遇到过这个?我真的很感激你们的帮助。
Cheers Gareth
干杯加雷斯
采纳答案by ggomersall
SO i figured out what was causing this issue. It was the 'Search Paths' under 'Build Settings' that was looking in the wrong location for my frameworks. Similar to the Apple Mach-O linker error fix
所以我想出了是什么导致了这个问题。正是“构建设置”下的“搜索路径”在我的框架中寻找错误的位置。类似于 Apple Mach-O 链接器错误修复
It was searching my for the frameworks on my macbook pro, I deleted the 'Framework Search Path' and then re-added my Parse.framework, Bolts.framework and FBSDKCoreKit.framework.
它在我的 macbook pro 上搜索框架,我删除了“框架搜索路径”,然后重新添加了我的 Parse.framework、Bolts.framework 和 FBSDKCoreKit.framework。
The project now builds and runs just as it should without any issues.
该项目现在可以正常构建和运行,没有任何问题。
回答by Marco83
In our case, the error was that some of the frameworks were built with XCode 7.1 on OSX 10.10, then the binaries where uploaded to a dependency manager (Carthage).
在我们的例子中,错误是一些框架是在 OSX 10.10 上使用 XCode 7.1 构建的,然后将二进制文件上传到依赖项管理器 (Carthage)。
The failing project was compiled with XCode 7.1 on OSX 10.11and it was pulling those frameworks from Carthage.
失败的项目是在OSX 10.11上使用 XCode 7.1 编译的,它从 Carthage 中提取了这些框架。
Apparently the mismatch in OSX versions was causing problems. Once all frameworks were recompiled on OSX 10.11, it stopped failing.
显然,OSX 版本的不匹配导致了问题。在 OSX 10.11 上重新编译所有框架后,它停止失败。
Note that sometimes it failed with a permission denied
on one of our frameworks, sometimes with a permission denied
on CoreData. Replacing the frameworks binaries with binaries built with 10.11 fixed the issue.
On a side note, frameworks built with 10.11 seem to work fine on 10.10.
请注意,有时它permission denied
在我们的一个框架上失败,有时permission denied
在 CoreData 上失败。用 10.11 构建的二进制文件替换框架二进制文件解决了这个问题。附带说明一下,使用 10.11 构建的框架似乎在 10.10 上运行良好。
回答by Stephen Chen
I solved this problem by delete the framework search path of other Userin Xcode Search Pathsunder Build Settings, this error occurred when I try to move the project between two Users , when delete the path everything worked fine .
我通过在构建设置下的Xcode搜索路径中删除其他用户的框架搜索路径解决了这个问题,当我尝试在两个用户之间移动项目时发生此错误,删除路径时一切正常。
回答by Yeehaw
For anyone who still has problems, here's my solution:
对于仍然有问题的任何人,这是我的解决方案:
I tried everything recommended, from removing any user data to setting up the project from scratch to reinstalling Xcode - nothing worked for me.
我尝试了所有推荐的方法,从删除任何用户数据到从头开始设置项目再到重新安装 Xcode - 对我来说没有任何效果。
In the end, it turned out that the frameworks I was using were depending on the library mentioned in the error message (Opening import file for module 'FRAMEWORK' Permission denied, in my case this was CoreLocation). I built several ones of them and the project built just fine on another Mac. When pulling this version from Github, the built frameworks threw the above mentioned errors. So I built each framework from scratch, and embedded these frameworks in my final project. This time everything worked, just like on the other Mac.
最后,事实证明我使用的框架取决于错误消息中提到的库(打开模块“框架”权限的导入文件被拒绝,在我的情况下这是 CoreLocation)。我构建了其中的几个,并且该项目在另一台 Mac 上构建得很好。当从 Github 拉取这个版本时,构建的框架抛出了上述错误。所以我从头开始构建每个框架,并将这些框架嵌入到我的最终项目中。这次一切正常,就像在另一台 Mac 上一样。
Just my two cents, since everything I've seen until now could be resolved in a different way than this one.
只是我的两分钱,因为到目前为止我所看到的一切都可以以与此不同的方式解决。
回答by Albert S.
For anyone else encountering this issue, here's what I did to solve it. I tried everything that the above posters suggested with no success. Here's my setup:
对于遇到此问题的其他人,这是我为解决该问题所做的工作。我尝试了上述海报建议的所有内容,但均未成功。这是我的设置:
- MacOS Sierra 10.12.5
- Xcode 8.2
- Frameworks built by Carthage 0.22 on our CI infrastructure
- MacOS 塞拉利昂 10.12.5
- Xcode 8.2
- Carthage 0.22 在我们的 CI 基础设施上构建的框架
I was getting a "Permission Denied" error for an internally built framework.
我收到内部构建框架的“权限被拒绝”错误。
If I replaced all frameworks with ones built using Carthage on my machine, everything would work. If I used the ones built from CI, I would see the "Permission Denied" error.
如果我将所有框架替换为在我的机器上使用 Carthage 构建的框架,一切都会正常。如果我使用从 CI 构建的那些,我会看到“权限被拒绝”错误。
I double checked that OS versions were identical and Xcode versions were identical. I compared the Info.plist values of the framework that was built on my machine from that from the CI infrastructure. I double checked the file permissions for all Carthage built frameworks and internal frameworks under Xcode.
我仔细检查了操作系统版本是否相同,Xcode 版本是否相同。我将构建在我的机器上的框架的 Info.plist 值与来自 CI 基础设施的值进行了比较。我在 Xcode 下仔细检查了所有 Carthage 构建的框架和内部框架的文件权限。
If I replaced the troublesome internally built framework with one that I built locally, the error then moved and gave me a "Permissions Denied" error on UserNotifications module which is from Apple. This made no sense.
如果我用我在本地构建的框架替换了麻烦的内部构建框架,那么错误就会移动并在来自 Apple 的 UserNotifications 模块上给我一个“权限被拒绝”错误。这没有任何意义。
I did short of everything but reinstall MacOS.
我什么都没做,但重新安装了 MacOS。
Turns out, the problem started after I added a new admin user to my machine to test something else out. That user only used git.
事实证明,问题是在我向我的机器添加一个新的管理员用户以测试其他内容后开始的。该用户仅使用 git。
After I removed that user, I was able to build again believe it or not.
删除该用户后,我可以再次构建,不管你信不信。
回答by Jesse
In my case,When I clone project from git into a new Mac(macOS Sierra & Xcode 7.3). Here is my error message:"Opening import file for module ‘ MobileCoreServices':Permission denied".
就我而言,当我将项目从 git 克隆到新 Mac(macOS Sierra 和 Xcode 7.3)时。这是我的错误消息:“正在打开模块‘MobileCoreServices’的导入文件:权限被拒绝”。
I tried reinstalling Xcode, but nothing worked.
我尝试重新安装 Xcode,但没有任何效果。
In the end, I solved this problem by reinstalling macOS Sierra.
最后,我通过重新安装 macOS Sierra 解决了这个问题。
Here is my suggestion: I create a new administrator account in the new Mac, switch into the new account, then delete the old administrator account, maybe I shouldn't delete the old administrator account.
这是我的建议:我在新Mac上创建一个新的管理员帐户,切换到新帐户,然后删除旧的管理员帐户,也许我不应该删除旧的管理员帐户。