I followed the advice found in Duplicate and rename Xcode project & associated folders
and it worked, except for the bridging header which still needs the old project name as the prefix. How can I change the bridging header name to correspond to the current project name?
I'm not sure I understand your question correctly but if you would like to just rename the Bridging Header file itself you can do that by finding it in the Project navigator, click enter on it and then type the new name.
If however you would like to change the reference when building to point at your new Bridging Header, then you can change that by going to Build Settings for your project, select the proper target and then the easiest is to do a search for Bridging Header. You should now be able to alter the path and name of where your Bridging Header is located.
Hope that answers your question
Related
I have a stand alone SPM (local) in my project. When ever I add any new files to this package Xcode does not show the prompt to specify the name. Usually when adding files in a project it requests the location which allows to specify a name. But when adding in a SPM it straight away creates a file with File.swift always.
I don't mind renaming but its just that the header is also having a generic File.swift
//
// File.swift
//
//
// Created by McDuck, Scrooge on 02/06/89.
//
Any work arounds ?
I have tried on Xcode 13.4 as well
#user5381191 I had the same problem. I did some searching and found this answer.
The file you want to edit is located in:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/Source/Package Swift File.xctemplate. Edit the TemplateInfo.plist.
As a test I just copied the TemplateInfo.plist file from the Multiplatform/Source/Swift File.xctemplate and it worked. EDIT: For some reason it worked, and then stopped working?
Copy the suggested plist text from the link above into your template file and it works!
Once I did that, I get a new file type "Package Swift File" in the New File dialog.
Instead of the standard file dialog, it gives a dialog for entering the file name. Better than before!
Make sure to save your old template file before making your changes, just in case you need to revert.
It doesn't insert the package name in the header. That might be a nice thing to try and get working, but I'm happy with this for now.
Actually it works as promised (according to Apple guidelines).
In this scenario (as shown on demo) a menu command without ellipsis (...), so no dialog expected.
Once file created Xcode enters edit-name mode, so we can specify a file name which we need.
The file hat is different question and can be edited in templates if needed, or not. Usually depends on project and might even not include file name at all, but for default template - yes we need to change it to align.
Tested with Xcode 13.4
Trying to create a document provider app extension for my app, returns me this error when I try to run the project after creating the app extension (just creating it not adding anything else) :
error: bridging header '/myPath/test-Bridging-Header.h' does not exist
Apparently the app extension is not searching at the right path, the bridging header is in the folder with all the classes and the app extension is looking for it at the root of the project.
Any fix?
Probably a problem with the file path you've provided.
By default Xcode will look for your bridging header file from the directory where you can find your xcodeProj file.
In XCode, go to your Project's Building Settings and search for Code Generation. Under Swift Compiler - Code Generation, verify the path you've supplied for your bridging header file.
For example I drag in a folder "SharedClasses" with shared source code files as a folder reference into Xcode. The folder reference appears in the Project Navigator and lists all .h and .m files correctly.
But Xcode refuses to import them. I tried all kinds of import:
#import "Utility.h"
#import "SharedClasses/Utility.h"
#import <SharedClasses/Utility.h>
None of them work. But a folder reference exists and it contains "Utilities.h"
Xcode knows where the folder comes from so what must I do that it looks inside it?
Because the files are in a different folder than the project Xcode will not include it in the header search path. To fix this add an entry for User Header Search Paths (select your project, select Build Settings, filter to "user header search paths", add the value) in the project that points to the original folder reference. For example in a project I'm working on I have code that is shared between several projects in a workspace which is stored at the same folder level as the projects in a folder named shared. My User Header Search Paths has the following:
$(PROJECT_DIR)/../Shared/MySharedCode/
So I've written code in OpenCV which contains 2 header files using Code::Blocks. When I compile the files, there are no errors except two "undefined reference..." errors which occur because I have used functions that I have declared in the header files. I assumed that code blocks automatically linked the header files? I have used the "#include.." to include the header files at the top of the programs so not sure what the problem could be. Anyone have any idea? Thanks.
I was having a similar problem, but happened upon a solution
Click the "Project" tab, it's in the top right side.
Within the "Project" tab click the "Add Files..." option.
Highlight your Header file and any other files associated with your header file, like if you put your header files definitions in a .cpp file.
Compile and Run.
Hopefully this helps, it worked for me but our issues could be different.
I published lite version of my iPhone-app and is in the store. Now, I want to add the code for the 'full' version and am stuck at a point.
After adding the second target in the project, the lite version compiles fine, but the full version does not. This is because the macro defined in _Prefic.pch file is not visible to the full version of the code.
Can a project have multiple .pch files? If no, how do I specify XCode to share the .pch file with both targets?
Right-click on your target and choose "Get Info". In the "Build" section search for "Prefix Header" setting and look at its value. Set the value as needed (to a new file or to already existing one).