Swift Compiler Error on New Mac - ios

I just copied my project over to a new mac (xcode/iOS up-to-date). However, I'm getting Swift Compiler Error when I try to build/run.
<unknown>:0: error: opening import file for module 'Swift': Permission denied
Looks like its an issue with my bridger file. So I tried the following
Deleted the old reference under Build Settings > Swift Compiler > Objective-C Bridging Header
Added a new objective-c file and created a new bridge.
However, the error still persists.
Any clue what might be causing this?

Try looking the user permissions of your files and add your new user as the owner of those files. Make sure it applies to all descendent items using the finder get info Owner permissions

Possibly one of the most inefficient solutions: I ended up creating a new project and importing all files, frameworks, plist settings, build settings over. Took a while (the project is fairly large), but ended up compiling.

In my case the "Framework Search Paths" was wrong. There was absolute paths from another computer.

Related

Xcode refuses to let me import Swift files to Objective-C files ('projectname-swift.h' not found)

I downloaded this Xcode project and I want to use my Swift files in the Objective-C files but the 'OpenShop-Swift.h' file not found error refuses to go away.
I have tried what seems like every solution on Stack Overflow, including from here and here. Most other solutions were duplicates of the common:
In build settings, set defines module to yes and product module name for the target to your project name and make sure objective-c generated interface header name is correct.
This top solution seemed promising but I am having trouble understanding what he was saying.
If you decide to give it a whirl, just know that the project lacks a working backend and won't compile properly if you get past the file not found error. But, if you add to one of the .m files you should be able to get the error before the project finishes compiling.
Technically, this is not a duplicate since all the other solutions have failed.
I have found the solution thanks to #skladek. I created a swift file and allowed Xcode to create a bridging header file for me when it asked, and the error went away.
I thought the bridging header file (OpenShop-Bridging-Header.h) was to allow the importation of Obj-C code to Swift files and not vice-versa. Thus far everything I have read on the internet has corroborated this, so it's not clear to me why this solution works. Thanks to #skladek once again.

Swift bridging header fail issue

I have an iOS project using swift language which is running normal. Because I worry about the project may miss or other, I copied the project from this address to another address.
when I open this project and run this project. I got those two error tints:
"SVProgressHUD.h" file not found
Failed to import bridging header
I don't understand why this error is happen. And the project in older address is ok.
Has anyone experienced this problem?
on the file manager (left), click on your SVProgressHUD.h file, and look at the path on the utility window (right), or just right click -> show in finder. You will probably find that your file is not where it's supposed to be.

iOS clang error no file or directory

I''m very unfamiliar with the iOS build process. I was giving a legacy application that hasn't been touched in a few years, it was targeting iOS 5 before I opened it.
I'm running into an error Command
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
I could be wrong but I've browsed a few post and it seems like older xCode cersions didn't have a pch file. Any suggestion on how to get this project running again?
Thank you
If this file you are used to bridge OC and Swift,now you should creat a new .header file and Move All Header file Name inside file
and Add Your File Location inside Build setting -> objectiveC Bridging Header
Hope It Works.
It seems the .pch file is missing from the project but reference still exists in the Xcode Settings. So, Xcode is searching for the .pch file but couldn't find the same.
I recommend you to update the GPU-Image Framework as this might be the old framework. Otherwise, Try the below steps:
Go the Build Settings.
Scroll down to the section 'Apple LLVM 8.1- Language'.
You'll see the option for 'Prefix Header' with the path to the .pch file.
Remove the path from the 'Prefix Header'.
Hope this'll solve your issue.

ERROR "swiftc failed with exit code 1" when converting to latest syntax

I was trying to convert syntax of old Swift project to new one as per few suggestion on Stack Overflow I tried converting it through Edit > Convert > To latest Syntax that did not work properly instead I started getting new errors shown as below
Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
failed with exit code 1
And
Command /usr/bin/ditto failed with exit code 1
I tried Xcode 6.0.1 Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1, but it's a different situation.
Have you tried to do clean with Clean build folder?
The combination keys is:
ALT + SHIFT + COMMAND + K
Try delete Derived Data folder and Build it.
Go to Xcode -> Preferences -> Locations for get the derived data path
Clean Xcode. (cmd+shift+k)
Quit Xcode completely.
Open project again.
Wait for Xcode to indexing files.
Now run your project.
Just had the same issue. For me it was because I had renamed some of the project directories. I had a ton of red files in my project navigator. To solve, follow these steps:
click on the directory in project navigator where many files show as red
Under "Identity and Type" in the File Inspector (on the right side), click Containing directory
Select the new directories
Rebuild - command shift K, command B
As far as I know there can be multiple reasons why a compiler fails. Although cmd+alt+shift+k will help most of the time. If this fails, then click on the error message and try to debug it.
For example in the image below, if you read the message, we get to know that, there has been a name duplication. Fixing the name duplication will fix the issue.
Just remove inactive file(deleted file) from Build phases
then
Clean Xcode. (cmd+shift+k)
delete Derived Data folder and Build it.
Go to Xcode -> Preferences -> Locations for get the derived data path or cmd+Alt+shift+k
OR
Just remove inactive file(deleted file) from Build phases
Cleaning the project wasn't working for me, this is because I didn't pay attention to the message right above (Xcode highlights only the final command).
In my case it was
<unknown>:0: error: filename "FileDuplicated.swift" used twice: '/../filepath/FileDuplicated.swift' and '/../filepath/FileDuplicated.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /../bin/swiftc failed with exit code 1
I had to change the name of one of the two files and it was solved.
Hope this can help someone, cheers
In my case it was due to the few swift files which has been showed grayed out in the Build Phases section. After removing those files it was successful.
In my case I deleted few files from project and when try to commit the code, the files was showing there . To solve this issue.
1. Open terminal
2. Type git clean -n // it will show you list of files which are deleted from project but still are saved somewhere
3. Type git clean -f // All unwanted files will be removed
In my case, it was "Other swift flags". I had declared a flag there but not -D, so this was not getting recognized and resulted in the same error
In my case swift development snapshot was selected instead of xcode 9.2. here are the steps and image.
xcode on screen and click on xcode top menu bar.
Than go to toolchains option and check on xcode 9.2. thats it.
Note: If no toolchain found in your xcode than download from Here and install it. (after installation restart xcode).
Happy Coding!!!
Ok, my turn now. In my case I had an existing project. I copied in a few files from another project. One of the files I brought in was SettingsViewController.swift and there was already a file by the same name I was not aware of. The files were in different directories of the project so no duplicate message was shown. The compile/link messages offered no clue to this. I figured out the issue by adding one file at a time to the project (there were 12 total) and the building each time until I found the offending file. I renamed the new file and project builds now.
In my case it was a compiler flag change that didn't work well. It took a few compiles before it actually started failing though! Xcode caches what it compiles.
I just had this issue. It's due to path references. Have you been moving files around and/or copying folders? Check if .xcodeproj is inside or outside of the main project folder. Also, make sure that the project's file and directory structure are intact.
/yourFolderProjectName/ <-- contains your .xcodeproj file AND folder with Xcode project name
/yourProjectFolder <-- here are .swift, info.plist, assets folder, etc.
/yourProjectXcodeFile.xcodeproj
Another thing to check:
In my case I had deleted a row in the "Other Swift Flags" section in the Build Settings screen under the Release setting.
That row had been a value for a compiler flag key/value pair. So the key was there but not the value.
Once I deleted the key as well, then the build worked again.
This issue is happening because of pods
So Follow the below steps to resolve this issue
Remove all the pods and re-install again.
Remove all the pods using below this command (rm -rf "pwd/Pods/")
Quit the Xcode and open it again and build the app with device (generic iOS device).
Now check this issue will be resolved.
I had this error when Xcode found two .swift files with same name. Rename one of them and build again.
Wait for completing the indexing and run the project again. You must get an error then check it which may be Objective-c bridging file not found error. This error comes if you are using any Objective-C library or code directly in the project and your project unable to find the bridging file in the system. This issue basically caused by, if project is unable to find any file in the system which is using in the project (path issue).
I faced this issue while using the Swift auto-generated header file in my project (named as 'TargetName'-swift.h) to use Swift classes in Objective-C.
There was a typo in the file where I had imported this swift header. Correcting the typo helped me resolve the issue.
Clean the build in Xcode cmd+shift+k.
Update the pods.
look the where errors showing.
Add the missing files in Xcode.
After Run the Code. Working fine.
Try below if none of the above working for you.
My project location was desktop/my_project_folder
I tried all above then i made simple change.
I create one more folder on desktop past my project
.
then...
Cause of problem in my case:
This problem occurred when i change my project name in xcode & project folder name from desktop.
I was working on a private pod and was also pointing to it locally. I had made some file name changes.
Hence I was getting this error.
All I had to do was to run pod install so it would reflect the file name changes. After that it compiled.
In my case I copied a core data entity and only renamed the entity but not the class.
So go to your xcdatamodel and select the enitity > rename also the class name
Had the same issue but with duplicate file references.
Deleting Derived Data and cleaning had no success. But I got it fixed by doing this:
Navigate to your project.pbxproj -> open with your text editor of choice(I use atom).
Command+F and find the duplicate file sources and then delete them.
Build/Run and should be fixed.
For me, it was the keychainAccess problem as described in this answer (my error messages were completely opaque, all I had to go by was 'failed with exit code 1')

import <IOKit/IOMessage.h> gives error

I'm using theos on iDevice. Installed it with installtheos3 command. If I got it right, it installed SDK too.
Now I have a project that has
import < IOKit/IOMessage.h >
Also I added IOKit to theos' makefile _FRAMEWORK section. Also I tried to add it to PRIVATE_FRAMEWORKS section.
When I'm trying to 'make' i got this error:
error: IOKit/IOMessage.h: No such file or directory
there is no errors with other frameworks, only with this.
Thank you!
I never use theos, but this kind of error generally come from the Header Search Path option inside Build Settings inside your project settings.
When I ran into similar issue, I had just downloaded files from Github as part of my project and proceed forward.
Problem is, these header files are for C type of library(not really obj C). So I doubt, you would be able to include by changing path or config settings.
For some reasons IOKit framework installed with 'installtheos3' doesn't have Headers directory at all. Copying it solved problem

Resources