How I can rename swift package - ios

Is there some easy way to rename Swift Package?
I tried some standard ways but there wasn't result in finding quickly solution
Please help me, thanks in advance
Sorry guys i put it badly.
more description:
I have created SP in the my workspace a some time ago and now there are a lot links (imports of this package) around all project and now I want to rename this package. Special tool not avalible for this and i was looking some ather way to avoing a lot of routine work

Go into your Package.swift file and change any instance of your old name to your new name. Hit save, then your xcode project should update itself.

Sadly it doesn't look like there's a good way to do this, and when it's come up I've ended up making a new package with the correct name, moving all the code into it, and updating references to the old package to point to the new one.

Unfortunately I only found a manual way to do it.
These are the steps that I did to change OldName to NewName:
To change the package name that shown on Xcode, you can rename the root folder on your Finder
If your project are currently open, A popup will appear, you can just close the xcode.
Then you can re-open your package.swift file again.
Last, Rename the folder inside your Sources and Tests folder to the
new name. Also adjust your file name too.

I just renamed my package, which was easier than expected. As previously described, you have to do it manually.
Open your package in Xcode (not in a project)
Open the package.swift file and change the name everywhere
In your Sources folder is another folder with your package's name, rename that, too
If you don't use Git, that's pretty much it. If you do, you can commit your files (which will be a lot, because you renamed a parent folder) and change your repository's name. You probably have to clone it again, so there won't be any errors in the future.
After everything is renamed, you need to update your project(s). If you added your package locally, just search for all the import statements and change the name to your package's new name. If you added it via Github, remove the package dependency, add it again and then search for all the import statements and update them accordingly.

Related

Xcode could not open file

I am making a mini tweet and working with team members using RxSwift and MVVM. But when I try to open a new file, it doesn't open. Restarting the computer and restarting the app is the same.
I'm working on the same branch as a team member, is that a problem? Why won't it open
NetworkingAPI and ViewModelType is new created file but The file color is weird
There are lots of reasons why that specific file went missing.
You might've dragged that file from somewhere into your Xcode project and you thought that it was copied properly onto your project folder and deleted it from the original source folder.
Merge issues.
Similar to #2, another team member of your project pushed the file in a wrongful way.
There are of course also ways to recover it.
Check your local machine.
Ask for the most updated file from your teammate.
Check your commits, and simply copy the whole source from there and fix it in your Xcode project by making a new file in your project folder.
I think the #3 should suffice.
You have the reference in Xcode but the files are missing.
This happened when merging and you had .xcodeproj conflict then someone solved it in the wrong way. Check this as reference: https://stackoverflow.com/a/12907864/3933094

Alamofire RED in Xcode project - No Alamofire.framework file

I'm trying to install Alamofire into my Xcode project. However, after following all the steps for installation given by the documentation on the github project, the Alamofire.framework file shows as red in Xcode, and the project will not build. Further, there seems to be no way to fix this, because the Alamofire.framework file does not exist in the package on github.
More detailed explanation:
Following the instructions on github to install manually is fine until the final step: "Click on the + button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add Alamofire.framework."
Because we have already included the project, when we go to add a new framework, Alamofire DOES show up in the list of available things to add. However, when we add it, it shows up red. As we know, this means that the path is incorrect relative to the SDK. Ok, fine... but when we go to correct the path by looking at the Alamofire directory that we put into our project directory, there are a lot of files and none of them are "Alamofire."
I know that I downloaded the package correctly. I installed as a git submodule, I deleted it to retry, I downloaded the zip from github, retried again, etc. Even for this tutorial (http://www.raywenderlich.com/85080/beginning-alamofire-tutorial), if you look at the pictures for this step, we can see that there is no framework file in the directory!
So, Xcode demands a path to a .framework file that doesn't exist... yet we were able to add the framework somehow. Forgive me if I am confused.
There are quite a few questions out there on Alamofire install issues, but I think there must be something here that noobs like me are missing. One poster, here (Alamofire framework not found), is asking something similar, but it appears that her question was misunderstood (she did not accept any answers). I notice the "It's red tho!" frustration showing up in many comments for Alamofire install-related posts- an answer here would really help clear that up.
I was having the same issue as you, however, I found this question which made me build the project even though everything was red. To my surprise it ended up actually building successfully and afterward I was able to import Alamofire into my Swift files.
I had tried to build earlier unsuccessfully, however, between builds I did change one thing. I moved the Alamofire-master folder to the first level of my App's file structure before including the .xcodeproj file in the Project Navigator, as indicated by the tutorial that you linked. I had initially just moved it from its place in my downloads folder.
The whole copy frameworks part seemed to be a nonissue for me because the framework ended up instead in embedded frameworks automatically, after doing the embedded bin step.

Xcode doesn't see the file

I have this file structure:
But Xcode doesn't see file for :#import "VKSdk.h" , because it's in another project, what do I need to do:
Perhaps consider looking into how to work with workspaces in Xcode. It offers great features when working with multiple interconnected projects.
Check this out
https://developer.apple.com/library/ios/featuredarticles/XcodeConcepts/Concept-Workspace.html
VK guid said to add only sdk.xcodeproj file, so it didn't see all the files in this added project, but when I tried to cope these files into the project, it failed to launch.
I added $(PROJECT_DIR)/DatingService/3d\ Party/VKAPI/sdk into Header Search Paths of Build Settings and now it works.
Try to clean your project. I hope it helps
File is not present make sure you are writing right class name
Make sure file is present over there.
If you are adding file from somewhere it is recommended to tick the check box copy item into destination folder.
Fix: you need to update User Header Search Paths in Build Settings like this ../**
Look at the image: https://www.dropbox.com/s/beytwz8ev262l53/header_vksdk_fix.png

Duplicating a project and changing its name

I was creating a new project that is a copy of another project. The thing is that when I want to rename the project, some connection problems appear when I want to execute my app. Can someone tell me a good way to replace all the names of the old project? The classe names are the same in the new one, so I don't have to change them.
Thanks!
I have done this recently and it was a straightforward process.
I suggest you start again. Make a copy of the project then click twice slowly on the project name in the project navigator. You can then rename the project.
Xcode then suggests which files/resources to change - you can accept all changes or amend if you like.
Once complete your project will build and run with no problems.

Project ...xcodeproj cannot be opened because it is missing its project.pbxproj file

I was trying to merge branches and it resulted in the error "Unable to open project… cannot be opened because the project file cannot be parsed". I then tried to take the advice of other stackoverflow responses (namely to edit the file to remove the corruption), but was unable to edit the file. It appears that this is actually a directory, so maybe the structure of this changed with version 4.4 of xcode and since the response to Unable to open project... cannot be opened because the project file cannot be parsed was written.
I then tried to restore myProject.xcodeproj from my time machine backup. This does not work because it says that I don't have permission to access myProject.xcodeproj. I tried to change the permission of that directory, but that did not help.
I closed and reopened xcode. Now the error is:
Project ...xcodeproj cannot be opened because it is missing its project.pbxproj file.
How can I fix this problem in xcode version 4.4? Can it be restored from the previous snapshot or archive or version in xcode. Can it be restored with time machine. I would like to avoid rebuilding the entire project.
The simplest thing to do is probably to
Checkout myProject.xcodeproj from source control. This will contain the changes that were causing you to be in conflict last time.
Redo the project changes that you made since the last time you committed to source control
commit/push to source control.
In the future, when you get a conflict in the project file, take a look at myProject.xcodeproj/project.pbxproj. Often it's just new files in the project that have been added at the same place. In this case you just need to delete the conflict metadata and resolve the conflicted state.
In the end, what I had to do was
'cp -R ...TimeMachineBackup/myProject.xcodeproj ...myProjectArea/myProject.xcodeproj'
Then I had to do the following in myProjectArea:
git reset --merge
This allowed me to open the project and switch branches back to my main branch.
not a pleasant experience
Another way this can happen is if you've been using sudo for some reason with pods or the editor - if the file exists under yourApp.xcodeprojectroj directory but xcode is complaining it can't find it - Go to your project root and do:
sudo chown -R yourusername:staff ./*
For others looking at this issue, the cause in my case turned out to be, that the "conflict text" from a git merge had crept into the actual file:
<<<<<<< HEAD
F0FDA2D61B99EB80007DB99D /* Aptron-mCollegix.xcassets */,
=======
F08CFAAA1BC1E9EE00A5B6F5 /* Aptron-mCollegix.xcassets */,
>>>>>>> hotfix/Column_Text_Cut-off
opening the project.pbxproj in a text editor made the fix easy.
I found my own solution to this issue.
The cause of the bug is that the .xcodeproj file is missing its containing pbxproj file, right? This is usually present when you right click your .xcodeproj file and click 'Show Package Contents'. However, in your own case, it's been deleted, through some mistake or other of git versioning.
As you can't really generate a .pbxproj file, the solution I found was to go to the original project folder location, which I had used to create the repository. To be honest, you could probably simply create a new project also, as long as it has the same bundle identifier and such! As this project's xcodeproj file will correctly contain a .pbxproj file, replacing the files in the XCode environment with your own project's files will allow the .pbxproj file to update based on these files.
Therefore, after opening this original project folder (/new project folder), in the XCode environment, I then removed all the files within the project, and replaced them with the corresponding files from my project which I was unable to open the xcodeproj file of. I had to fix a few resulting bugs here and there, stuff involving build phases and such not lining up, given you've just copied in a bunch of new files. But after fixing a few small errors, the same project in this new location was eventually able to run no problem!
Finally, I took this successfully running version of the project, and copied in all the files, .xcodeproj file, project folder, test files and all, into the original repository location, deleting the files from the repository before hand to avoid confusing overwriting of files (you can cut and paste the old repository files to a new location if you want to be safe, and don't fancy deleting them!). Then open the project in XCode from the repository location, build and run it on your simulator/device to make sure everything lines up (and fix any small bugs you may need to), and voila! Your project is now able to be committed, pushed, and ran!
This isn't the cleanest solution, and you may have to do similar things across various branches if they've all been corrupted. However, if you don't have access to a Mac time machine, and the other solutions aren't working for you, this is possibly the most straight forward way of having a working .pbxproj file again!
Oh, and I removed the .pbxproj from my gitignore. I'm not sure if it's actually find to have it in your gitignore or not, but I'd recommend doing your own research on that subject, I'm not certain myself!
Good luck!
I was able to get this working without commandline stuff like this:
Go to Time Machine drive in Finder.
Navigate to desired backup.
Drag it to where I want it. This will complain about not having permission to access the .pbxproj
Right-click the xcodeproj you just dragged out, select "Show Contents".
Right-click the xcodeproj in the Time Machine backup folder, select "Show Contents".
Drag the .pbxproj you see inside to the destnation you just created with the drag in #3.
Now it should work.
It seems you can generate the file again with:
swift package generate-xcodeproj
although you could see this message:
warning: Xcode can open and build Swift Packages directly. 'generate-xcodeproj' is no longer needed and will be deprecated soon.
generated: ./BokenEngine.xcodeproj
with xcodebuild > 13.4.1:
xcodebuild -version
Xcode 13.4.1
Build version 13F100
If anyone wants to find the missing project.pbxproj file then try opening the .xcodeproj with some code editor and you will find the file there. And note that i had backup of my application in my other pc so i found that file there so you mist have backup of your project somewhere in order for this to work.
In my case the issue was that there were actually 2 folders with .xcodeproj suffix
The actual one was located in MyApp/MyApp.xcodeproj
Somehow another one with the same name MyApp.xcodeproj got added to root folder, with the following contents:
project.xcworkspace/contents.xcworkspacedata
project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
So deleting this corrupt(?) xcodeproj solved the issue.

Resources