ggomersall
ggomersall

Reputation: 113

Opening import file for module 'Swift' Permission denied

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

So i've cloned my project on the mac mini, and when opening and trying to build the project i get the error:

Opening import file for module 'Swift': Permission denied

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)

I've had a look at another question on here - Opening import file for module 'Swift': Permission denied but it's not relevant to my issue.

A couple things i noticed were

  1. 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.
  2. Under the products folder, my .app and .xctest files are highlighted red. Not sure how to fix that

Has anyone encountered this before? I would really appreciate the help from you guys.

Cheers Gareth

Upvotes: 6

Views: 8671

Answers (6)

Albert S.
Albert S.

Reputation: 331

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

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.

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.

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.

I did short of everything but reinstall 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.

After I removed that user, I was able to build again believe it or not.

Upvotes: 2

Jesse
Jesse

Reputation: 1

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".

I tried reinstalling Xcode, but nothing worked.

In the end, I solved this problem by reinstalling 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.

Upvotes: -1

Stephen Chen
Stephen Chen

Reputation: 3057

I solved this problem by delete the framework search path of other User in Xcode Search Paths under Build Settings , this error occurred when I try to move the project between two Users , when delete the path everything worked fine .

Upvotes: 2

Yeehaw
Yeehaw

Reputation: 105

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.

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.

Just my two cents, since everything I've seen until now could be resolved in a different way than this one.

Upvotes: 2

Marco83
Marco83

Reputation: 1191

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).

The failing project was compiled with XCode 7.1 on OSX 10.11 and it was pulling those frameworks from Carthage.

Apparently the mismatch in OSX versions was causing problems. Once all frameworks were recompiled on OSX 10.11, it stopped failing.

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.

Upvotes: 3

ggomersall
ggomersall

Reputation: 113

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

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.

The project now builds and runs just as it should without any issues.

Upvotes: 2

Related Questions