Getting error after changing project folder name in XCode - ios

When I created my project, I called it "Project1". Then, later I've changed it to "Project2" from the Xcode. I changed all "Project1" to "Project2", but now, when I compile my project, it looks for files in Project2/Project1/myFile.swift and I get the next error:
<unknown>:0: error: no such file or directory: '/Users/myusername/Copy/Projects/Project2/Project1/myFile.swift'
I need to make that it will look at
/Users/myusername/Copy/Projects/Project2/myFile.swift
without Project1 in the path.
How can I solve this problem? Also, I changed from Xcode Identity and Type section Location of my project.

Today I had the same problem when I renamed the folder containing the Xcode project and some parent folders of it.
In my case there where a .swift file shown with it's name in red in the list of files of Xcode (Navigator area). I think that this means that Xcode was not capable to find that file.
I selected that file (actually it's not a real file but a representation of it).
Then, in the File Inspector (Utility area), I clicked on the Folder icon and chose the file on Finder.
This worked for me.

Renaming projects in xcode in one of the most annoying things in iOS development. I assume you want to rename your app. I faced this problem once and figured out a simple, clean way to do it.
Go back to the point where everything worked.
Open project in xcode and click on the project icon in the project structure( first file)
Go to the info tab
Search for Bundle Name. Most probably it will automatically be set to $(PRODUCT_NAME) which is a shell variable that will set your app name the same as the project name.
Set it to whatever you want your app name to be
Done
Note : If you use custom URL Schemes this might produce an error when redirecting.
ALWAYS use git or some other SVN in your projects. This will come in handy in this kind of situations

Change you folder name in you finder "Project1" to "Project2"
Remove "myFile.swift" file from project (copy on Desktop)
Restart Xcode. Copy "myFile.swift" in project select "Copy file to folder" hope this will help.

Related

iOS My application.xcodeproj causes and display red text, Then I unable to open project?

I have facing this issue when I was changing project name and copying my project from one mac to another. There are some red texts indicate the missing files from the project source codes(But I have all files in Project folder) I have used cocoapods in this project. How to avoid these?
Here I have shown my project screen shot.
As per your description... you must be having some issue in your project.pbxproj file. Please check that file. Common issue happens in that file when you try to merge different branches having conflicts in project structure.
There could be different reasons of this:
It may happen because the xcode is open and the source folder is not available.
It may happen when source path is not found in your system and xcode shows that.
For resolving this, quiet xcode and reopen your source from .xcodeproj again, will resolve the problem.
Click on the file, then on the far top right of Xcode look under Identity and Type Check and see if the path to the file is correct. In my case is was not so I had to click on the small folder icon (not the arrow icon) and select the folder in finder.

Could not find a valid GoogleService-Info.plist in your project

When I run my swift 3.2 code with Xcode 9 beta 4 this is the error I get:
*** Terminating app due to uncaught exception 'com.firebase.core', reason: '[FIRApp configure]; (FirebaseApp.configure() in Swift) could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/.'
I already have a GoogleService-Info.plist file that is named exactly like it should and it is valid.
Is there any trial to firebase or something like that?
Remove the Google-Info.plist file from your project and try to add it from your project folder's option menu.
EDIT:
this is how you remove a plist file
Xcode 10 Error: Multiple commands produce
I had the same issue.
Click on the Googleservice-info.plist in your project and check Target Membership for app in the inspector. That fixed it for me.
That is the reason for this crash and removing the file and adding again is another way of doing as suggested by answers above. But the actual cause is this and this is the right way to solve it.
Please refer to the image below for further clarification:
Once you add the file to the project, you may also need to add it to Build Phases in the Compile Sources section.
Add the GoogleService-Info.plist in Build Phases as screenshot above:
Make sure the name of the file is correct, i.e: "GoogleService-info.plist"
Add it to the project in mac finder under the project name and then drag it into the project to reference it.
Finally, as Silvajee mentioned, go to the file inspector for the plist file and tick the box under target membership to include it as part of the project.
If you have multiple environments (Production, Develop, Staging), you will need a different Google.plist for each.
They all have to have the same name.
To get around this, create folders for each of these files (one for each environment) and place them inside their corresponding folders.
When you drag the files from the Finder to Xcode, make sure to select the proper environment for each under Target Membership
That will do the trick and allow you to build environments separately. Especially if each environment has a different Bundle ID.
Make sure your file name is correct as "GoogleService-Info.plist". Any other name would cause problem. Restart XCode and you are good to go.
Unfortunately or fortunately, the error specified is very accurate. There is only one option available right now. i.,e placing Google-Info.plist file in your project properly. Try to remove and add that again. Also, check if a target is selected or not.
Restarting Xcode worked for me, none of the above option worked.
These steps solved my problem. FOllow these.
1.You must drag and drop the GoogleService-Info.plist file into your project in a location such as Shared Resources. When you have successfully added the file, you should also make sure to include it in the project build:
2.Double-check that in the "Build Phases" section of your project that your project is including GoogleService-Info.plist.
3.Double check the file name. The file name must be exactly GoogleService-Info.plist common misspellings include GoogleServices-Info.plist and GoogleService-info.plist - case sensitive and exactly named only will work.
Actually this error is occur when GoogleService-Info.plist file is not actually located in our project folder but it just have a reference to that file where it is downloaded. So solution is that remove reference to this file and again add it to your project folder by drag and drop or by using "Add Files ..." option by right click to your project folder. Also recheck whether file is locating your project folder destination otherwise error will be occur again.
Don't forget to check your "GoogleService-Info.plist" file have same name as shown in error otherwise rename it.
For those of you working with Ionic, make sure to open your .xcworkspace file in Xcode first, then drag the GoogleService-info.plist file into the Resources folder.
Most tutorials online don't do a good job of explaining that portion for some reason.
Shout out to Shahzaib Maqbool because his comment helped me get this for my project.
Below setting can fix my compiler fail
1. Add to "Copy Files"
2. Not add to "Copy Bundle Resources"
We must make sure that full path is correct in Xcode. It would be better to add it from the start. If you already did, jump to step 5.
Quit Xcode.
Make sure that file name is correct, "GoogleService-Info.plist".
Add .plist file to project folder. Same level with Podfile, .xcworkspace, etc.
Open Xcode, identify .plist file on Project Navigator. If it's not there, right-click and click Add new file to "[Project Name]". Make sure to click project name below Add to targets option.
On Project Navigator, click on GoogleService-Info.plist. Select File Inspector from right navigator. Ensure that Full Path is correct. If not, click on folder icon and select the .plist file inside the project file.
Build. If still doesn't work, Quit Xcode and Build again.
Doing a clean then build a couple times worked for me.
1 - open "GoogleService-Info.plist" and change any or to and
2 - reopen the xamarin solution
3 - it should work now
I solved the issue by deleting the project from Firebase and deleted the GoogleService-Info.plist from project. After I again added the project to Firebase and added the new GoogleService-Info.plist file worked for me.
This error occur download google service more than 1 time. When we download first time from firebase, it's like GoolgeService-Info.Plist. If you download again, that will come GoogleService-Info(1).Plist. We need to remove (1) from GoogleService-Info(1).Plist.
Please try this.
Click on GoogleService-Info.
checked the target membership on the right side .
Clean and build . It will work.
2022 Update
If you're migrating from older firebase version and want to initialize Firebase from Dart only, then you have to remove Firebase Initialization from AppDelegate.m or Appdelegate.swift
in swift, remove FirebaseApp.configure()
and start again.
I know this question has a million answers already, but perhaps this solution will help someone who isn't using Xcode build configs like many answers above.
If you're converting an iOS app to Catalyst (as I am), then I found a minor but obtuse difference is Catalyst apps make bundles with a "Content/Resources" folder structure that was throwing off my builds for a while. My build phases copy my release/debug Plist files for me and the pathing difference from iOS -> Catalyst was causing this error.
You can probably solve this problem many ways, like the multiple folders with same named Plist files above. I use a custom bash script via build phases, and copy the file manually like this:
if [ $CONFIGURATION == "Debug" ]; then
echo using DEBUG firebase!
# Mac Catalyst appends a "Contents" folder so we need to handle that explicitly here
if [ $IS_MACCATALYST ]; then
#echo "MAC CATALYST BUILD"
cp ${SRCROOT}/${PROJECT-DIR}/your-custom-paths-here/GoogleService-Info.plist ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Resources/GoogleService-Info.plist
else
cp ${SRCROOT}/${PROJECT-DIR}/firebase/debug/GoogleService-Info.plist ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
fi
fi
Go to build phases and add file in copy bundle resources. Thats it.
delete any other "GoogleService-Info.plist" files that have been previously installed. in my case, when I installed it, it was names as "GoogleService-Info.plist-2" since I had another file installed in the same folder. it looks that this will create a confusion for firebase. I deleted all old files and changed the name of the current one to "GoogleService-Info.plist" exactly. it worked.
In my case something went wrong when i merged conflicts in project.pbxproj
GoogleService-Info.plist -> didn't have Target membership selected on the right pane and I couldn't select it because project.pbxproj was corrupted (even though build was successful)
I had to rollback project.pbxproj and after that GoogleService-Info.plist had Target membership selected.
Make sure project.pbxproj isn't corrupted after merging conflicts (it had something to do with attempted to initialize an object with an unknown UUID)
For anyone using Xamarin by mistake (you should avoid this piece of tool by all means):
open project file as code, and check that the file has import tag BundleResource, and not None (the red one is the correct one):
I'm using FirebaseUI and was receiving a slightly different error when pressing Sign-In with Google:
***Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'OAuth client ID not found. Please make sure Google Sign-In is enabled in the Firebase console. You may have to download a new GoogleService-Info.plist file after enabling Google Sign-In.'
What fixed that issue for me was changing this line (that seems to be deprecated)
[[FUIGoogleAuth alloc] init]]
to
[[FUIGoogleAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]]
when building providers list
NSArray<id<FUIAuthProvider>> *providers = #[
[[FUIGoogleAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]],
[[FUIPhoneAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]]
];
Another easily overlooked problem is when you have multiple PLIST files downloaded so the file is not exactly named 'GoogleService-Info.plist'.
I had multiple copies so was trying to use 'GoogleService-Info.plist(2)' which throws the same error, so make sure the file itself is named as it is meant to be!
My problem same this case and solved that ->
ı added xcode runner Open Xcode, then right-click on Runner directory and select Add Files to "Runner".
most importantly;
terminal: cd ios- " pod install "
and info.list thats ok.
ı hope your problems solved
I had to same issue and same error what you have. I downloaded from Firebase more than one info.plist file that why my MacBook save these files like
GoogleService-Info.plist,GoogleService-Info-2.plist,GoogleService-Info-3.plist
Then I copied mistakenly in my project GoogleService-Info-3.plist then I took same error. Then I just copied GoogleService-Info.plist and problem has been solved.
But be careful about bundle identifier. You have to copied correct project plist.
Just drag and drop the file into terminal, don't copy paste from Notes or TextEdit or from elsewhere.

Name Change Issue - Xcode trying to build from old file name

I've changed the name of my project from "BSV22" to "BSVC". I renamed the project by going to project navigator and double-clicking the title. I accepted changes to all the file names. When I then run the project I get the following error:
could not read data from '/Users/bobpreston/Desktop/BSV22/BSV22/BSV22-Info.plist':
The file “BSV22-Info.plist” couldn’t be opened because there is no such file.
it's pretty obvious why Xcode can't find the old file "BSV22-Info.plist"...because it was renamed when Xcode changed all the file names during the project rename. my question is why is Xcode still trying to build from that old file? it should be compiling from the new filename "BSVC-Info.plist" - and also how do i fix the issue? what else do i have to do?
In your target Build Settings, check the Packaging section for the row called Info.plist File. Make sure it has been updated to use the new filename.
While renaming the project name from old name below are the steps:-
1) Changing the name from testing to testing123 and enter.
2) After that it will show the below window. So just click on the rename button
3) After that clean your build and run.

Interface Builder could not open the document ".storyboard" because it does not exist

This problem is getting me really crazy. Xcode is looking for a storyboard in my project in a differente location from my project. I tryed removing the file, adding it again, cleaning the project, etc but didn't have luck.
This is the error.
cd /Users/fmartin91/Projects/loovin/loovin-ios
setenv IBSC_MINIMUM_COMPATIBILITY_VERSION 7.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
setenv XCODE_DEVELOPER_USR_PATH /Applications/Xcode.app/Contents/Developer/usr/bin/..
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ibtool --errors --warnings --notices --minimum-deployment-target 7.0 --output-format human-readable-text --compile /Users/fmartin91/Projects/loovin/loovin-ios/Build/Products/Debug-iphonesimulator/loovin.app/Base.lproj/LOOVProductIndex.storyboardc /Users/fmartin91/Projects/Base.lproj/LOOVProductIndex.storyboard
/* com.apple.ibtool.errors */
/Users/fmartin91/Projects/Base.lproj/LOOVProductIndex.storyboard:
error: Interface Builder could not open the document
"LOOVProductIndex.storyboard" because it does not exist.
I could fix this bug by killing ibtoold:
$ sudo killall -9 ibtoold
Why does ibtool need a daemon anyway?
Your storyboard is not in NSBundle mainbundle.
this problem is probably due a "Copy Bundle Resources" in "Build phases" problem.
For corrected it verify if your storyboard file is in "Copy Bundle Resources" for all targets. On project navigator select the project file select Build phases tab and check it is.
When you upload your file to google drive without zip, it appends the extension of .storyboard to .xml automatically and hence when you download it obviously the file won't exist.
To solve this issue, go to the:
[project folder] > [Project folder] > [Base.lproj]
There would be a .storyboard.xml extension type of file which you would have to rename it to the .storyboard extension. And hence your work is done.
Story board error solving visual guide:
I had a very similar problem and it took a few hours to resolve. Clearly xcode locked itself in some strange state that the project explorer could see the xib file while the compile could not. Finally this got resolved when I changed the Location in the File Inspector from Relative to Group to Relative to Project. I got this by comparing the project.pbxproj file in a regular text editor to search for any clues.
I encountered this same issue and here's how I resolved it:
Save a copy of the affected file outside of the project
Delete the file from the project, selecting Move to Trash to completely delete the file and reference from the project
Edit ProjectName.xcodeproj/project.pbxproj to remove all lines referencing the affected file
Re-add the file, making sure to check Copy items into destination group's folder (if needed)
Clean and build
I just ran into this issue running Xcode 9.2. I had copied my files from a school computer onto google drive and then downloaded them at home.
When I opened the files at home it kept telling me main.storyboard and the launch storyboard did not exist. The two storyboard files would display as xml, so they clearly existed, but even right clicking to "open as" produced nothing. After much troubleshooting I found a fix that worked for me.
SOLUTION:
Open your project folder, then the next folder named the same as your project. Open Base.lproj and you will see your two storyboards in xml format. Copy both the files, paste them into the same folder, delete the .xml and confirm the change to .storyboard. Do this for both files and you're set!
This happened to me after a git merge. I changed some storyboard localized files from one project to another and Xcode seems to keep on searching the file in the old project.
My solution was:
Edit the OldProjectName.xcodeproj/project.pbxproj
Search for the Storyboard name
Delete the references to the Storyboard name that appear followed by localization stuff (things like "Base.lproj", "es.lproj", etc)
Delete also the following localization entries (because they refer to the Storyboard file)
Clean and build
Repeat if other files keep throwing compile errors
For me I use xcode 10,
Click on the your project name (blue icon on left) > Build Phases > Under Copy Bundle Resources
Find the file, remove the duplicates if it’s there. Clean project and run again
I encountered same problem when moving the project to another computer. I followed below steps to solve this issue:
Open previous Main.storyboard file as Source Code, copy all
Create a new Main.storyboard file, Open as Source Code, paste
Delete previous Main.storyboard
Clean and build project.
In my case I found that the storyboard was placed in a group that referenced a folder that did not exist in the "Identity and Type" panel.
Removing that group and the storyboard, and adding it back referencing an existing folder solve the problem for me.
For me resetting the container folder of Main.storyboard file worked
I resolved this by doing this:
Open your Xcode project folder in finder, then find the file that you can't open.
Drag that file to your file path in Xcode Project (Inside Xcode App) like this.
Thick "copy item if needed" and choose "create folder references" and then click finish.
Restart Xcode
I could solve my issue, i really don't know how i did it but the things i tried were cleaning and building the project like a billion times, i hope this will be of help to anyone.
I just experienced this, and fixed it by restarting the darn computer. I found out more about it, though. In my case, my ibtool scripts weren't working, giving file-not-found errors just like yours. However I noticed a change in behavior when I ran them as sudo:
2013-09-20 20:49:40.339 Interface Builder Cocoa Touch Tool[58454:303]
CFPreferences: user home directory at
file:///var/root/Library/Application%20Support/iPhone%20Simulator/User/
is unavailable. User domains will be volatile.
Subsequent commands would fail or return without doing anything. So! ibtool/Interface Builder/whatever is somehow using some other launching service to run itself, with some other username or privileges.
Could it be that I installed some tool updates for Xcode 5.0, and it screwed up whatever serving process was running? Yes it could :)
I experienced the same situation with Xcode 7 beta 5. Rebooting my Mac did the trick.
Goto Build Phases > Copy Bundle Resources > Check for the Storyboard for which you are getting error > It should be displaying as blurred > If YES then delete its reference and add it again > Compile again.
In my case, folders in the project navigator and finder were not formed exactly the same. The Main.storyboard was in \Views folder in the project navigator but not in finder. Xcode wouldn't let me quit the app, because Main.storyboard couldn't be saved.
Here's what I did, that solved this problem:
Identify which files are missing or misaligned in your project navigator and finder simultaneously.
Copy Main.storyboard and other files that are not in their right place to a safe location.
Force quit Xcode from Activity Monitor. Reopen Xcode.
Paste previously copied files in finder. Make sure that the folder order is the same as the Xcode project navigator.
In Xcode, from project navigator right-click to where you need to add files and click add new files.
Add files from the finder.
Clean and build.

move xcode project causes red text (missing files from project)

When I move iphone project directory to a new path.
There are some red texts indicate the missing files from the project source codes.
How to avoid these?
Here is how to locate the missing (red) files using the Xcode 4 interface:
Select the file or files in the left hand Project Navigator (the folder icon)
In the right sidebar click on "File Inspector" which is the leftmost icon resembling a page
In the "Identity and Type" section, there is a grey box labeled "Location".
Click on the small icon to the lower left that resembles a file browser - this will come up with a file browser to locate the file.
Voila, you are done.
Xcode 7
1.) Right click on the red (missing) file.
2.) Select "Show File Inspector"
3.) Look at the right hand side of the screen under "Identity and Type" between "Location" and "Full Path"
4.) Click on the folder icon to the right of the file name.
5.) Navigate to the file's new location in the pop-up window and select the file.
I encountered this issue when copying my project from one mac to another.
The solution for me:
assuming your files are grouped (in folder)
from xcode open the group in file inspector
The group will probably be missing the absolute path.
press the little icon nearby to pick the folder to associate the group with.
restart xcode to see the changes.
I had the same problem, when I changed the permission on the files/folders to everyone read/write they then appeared in Xcode.
This worked on a Pod project. Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.
In Finder, create a duplicate of the project directory just in case all goes squiffy.
In Finder, open the project directory that contains all the files with red references
For all the red files you see in XCode, except the info.plist file (see step 5 below), highlight them in Finder and drag them from Finder to XCode's project navigator. i.e. import them.
In XCode's "Choose options for adding these files" window: a) Select Copy items into Destination's group folder (if needed)
b) Select Create groups for any added folder
c) Select Add to Targets, and press Finish
Highlight and drag the info.plist file from Finder to Project Navigator and repeat step 4 WITHOUT selecting Add to Targets
If you had groups in Project Navigator (e.g. Supporting Files), reorder the files to be in the right places.
Delete the original bad red references in Project Navigator, and Cmd-Shift-K to clean for good measure.
Build and run on a device to remove the bad reference to the .app file
you just have to locate the missing file press in file icon in the identity and type you will find the full path just locate your file where do you move it click the file icon
When you create these files be sure to save in your app directory. Or if you import classes from other project be sure to check the copy option.
I dont know if this is the main reason but when you are importing files to the application, do you mary the "Copy items in to destination group's folder (if needed)" ?
this make sure the file is not only referenced but added to your project folder and ir will move any where you move your project.
Did you move files in to folders directly in your project folder and not in xcode?
This worked on a Pod project.
go into finder and project.
right click on your project .xcworkspace and click show package contents
right click on contents.xcworkspacedata and open with textEdit then make sure file path is correct. If project has been moved this can change
I also did this below but now sure if you need it
Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.
If you create an Xcode project, then move the .xcodeproj file or the newly created project folder to a different folder using Finder, subsequent builds may show many missing files which still reference the original folder locations (which no longer exist because you moved them). These missing files can appear as red text or as issues in the Issue Navigator.
This can happen when Xcode is configured to automatically add or remove files to/from source control (under Xcode > Preferences > Source Control). When configured this way, simply creating a project in Xcode causes new project folders and files to be marked for addition to source control. When you later move the project folder or .xcodeproj file these pending adds now point to missing files.
To resolve this issue when Subversion is the source control program, revert the pending adds for the phantom items from your local working copy folder. In my case this requires dropping into a Terminal window, navigating to the parent of the phantom project folder, then reverting the automatic add, e.g.
cd /my-working-copy-folder
svn status --depth infinity
svn status --depth infinity existing-parent-folder/phantom-project-folder/
svn revert --depth infinity existing-parent-folder/phantom-project-folder/
Note that the first svn status command will list both missing files as well as properly added, modified or deleted files which you must take care to avoid reverting. The second status command is "practice" for the final revert command, to ensure you've specified the proper path to revert.
I do not know git but I assume it offers corresponding commands.
It's too simple to do :
Close the project that includes the missed files and open the Xcode, go to "Organizer">"Projects" and remove the project from the list there. Open your project from Finder and that's it.
hope this help.

Resources