Xcode project not working when cloned from remote repository - ios

I have developed an app in Xcode, and I now want to start using GitHub. I was able to successfully push the local project to remote, but when I try to clone the project to another computer and run the project, the project won't work.
When trying to run the workspace, which I usually have to use when editing the project, the .xcodeproj file in the left section of the screen is red, and it is no way to run it. In addition to this, it looks like the framework from the original local project has been left out. Attached is a screenshot where you can see my issue.
I would appreciate any help on this!
Screenshot

I finally got this working. What I had to do was simply deleting the empty (red) .xcodeproj file, go to File -> add files to "...", and manually locate and select the .xcodeproj file in the cloned folder.

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

Files are not in project navigator eventhough project compiles and can search for them

The problem started when I got into the project and saw I have no scheme. Couldn't create new scheme except for the cocoa-pods target. Then I went into my project via finder, and noticed that the project was backedup into the iCloud, and when downloaded it it appeared in the schemes and ran fine.
So I am with this project for a while now, started it in xcode 9 and already released a few versions to the store. Today I open the project for more developing, and I notice that I cannot see the files in the navigator. If I search for them I can go into them and edit. If I am running it, it builds and runs perfectly. Only problem is that I cannot navigate between files, and cannot find the storyboard in the search, so cannot open it at all.
I tried -
Hard clean
Delete derived data
reset computer and xcode.
But still cannot see the files in navigator.
Screen shot of navigator added:
As per our discussion in comments above I am adding the comment as answer, you can try deleting the xcuserdata folder inside .xcodeproj and re-run the pod install to solve the problem.
In order to do that, go to your .xcodeproj right click and select show package contents
Once it opens the finder window with contents inside it, simply delete the xcuserdata folder
Now get back to your project root folder in terminal and run pod install once done open the project using workspace.
That should solve your problem :)
Happy coding:)

Xcode not able to find project file

In my Xcode project there are other projects linked but somehow its not able to read the sub project.
As you can see MobiResourceManager.xcodeproj is shown in red. And thus the classes which uses headers inside it gives error. But I am not able to understand why its not able to show the project. Sometimes it doesn't show MobiResourceManager.xcodeproj in red but even then the classes using its header gives error of HeaderName.h not found.
The problem that I am facing is happening only in my system. I tried cleaning, deleting-installing Xcode, cloning the repository again but nothing works.
All the project file shown in the screen shot are sub project inside one main project.
Probably that red file was removed or moved somewhere else. Open Finder, locate the missing xcodeproj, then remove this one in Xcode and drag&drop the located one. If that red xcodeproj is inside your repository (what I suspect) then do not select to copy it to the destination.
If you cannot locate that red file, it means it is not added to the repository. For example, it could mean that you need to install it with git submodules or another way - depends on the project configuration.
Are you using the workspace? if yes then please open that file not xcode project file

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.

Creating Sencha Touch, Phone Gap project in Xcode

Having trouble creating a sencha project, with phone gap. My development machine is a Mac.
These are the steps I took.
Downloaded phone gap from link.
created a project in xCode using Cordova-based-application
Run the application in xCode.
Got an error that the index.html file is missing so R-click on
Project and added www folder. I unchecked copy items to
destination folder and 'checked create folder references for any
added folder'
Once I added the www folder, I was unable to R-Click and add any
files or create folders inside it. Here's the screen shot;
Now, when I run the application, it says Cordova is working. I am unable to R-Click and add a file inside the www folder.
Why is this and how can I solve this ?
I guess the next step i should take is to add the Sencha Touch 2 files in to this project. I am not sure about the steps i should get. So can someone kindly give me the steps or a good link (which gives step-by-step guidelines to make this work).
Am I correct up to now if I have missed any steps please correct me. I have been trying to make this work for more than 3 days now.
Note:
My ultimate goal is to run the application (Hello world code) in an
iPhone and Android device. So Please help me.
I have gone through this tutorial
UPDATE- AFTER ADDING SENCHATOUCH PROJECT TO MY APPLICATION
When I expand the SenchaTouch Project
You will need to use Finder to manage the files. Two finger click on the root project and select "Show in Finder". Once you have that directory open, copy your Sencha Touch project to the directory using Finder. You can edit those files in XCode but you cannot do most of the normal file functions in XCode because the WWW directory is referenced directory.

Resources