I cannot believe how hard this is. Perhaps because the word 'workspace' is overloaded by Apple and perhaps because the UI keeps changing every version. For a newbie to iOS, Xcode and Apple it's a nightmare.
I have Xcode 12
I have created a project.
I used File/save as
workspace to create a workspace to (eventually) hold multiple
projects.
Gave it a name.
I have another already created project (a
static library) that I would like to add to this workspace.
I cannot for the life of me figure out how to do it. I see things for
previous Xcode versions but those UI options are not present in 12.
In the end I want to have a workspace where I have a demo project that uses the static library project for Bluetooth LE communications. I will be spending 90% of my time developing the BT library so I want to be able to access the source of both projects.
By the way, I am not using Storyboards. Not sure if that makes a difference, but just in case!
Thanks for any help
You can do this by
Close the project to add in Xcode
Drag the existing.xcodeproj file (one you closed) from Finder to Xcode and drop it next to existing sources/projects in the workspace
Xcode settings are often painful for even seasoned developers. And every update seems to break something.
As far as I can tell it just doesn't seem possible.
The only option seems to be to create the workspace in XCode 11 add the projects there then open in XCode 12
If you already have a Workspace (i.e. a .xcworkspace file) ready to go, all you need to do is:
Close your project
Open your Workspace
Go to File > Add Files to "<your_workspace_name>"...
Select your existing project
Xcode will duplicate the references to your files, so you manually have to go to the Project navigator (shortcut: ⌘ + 1), select the duplicated references (they'll be at your Workspace's root) and delete them (select Remove Reference, not Move to Trash)
Enjoy your Workspace!
For good measure, select your scheme (most times it'll become available immediately, but sometimes you'll need to restart Xcode), build, and run your project to verify that everything went well.
Verified in Xcode 13.
Related
I haven’t tried this before but wanted to know how it happens. Suppose I have an Xcode file for my project called ‘Project A’. Now I want to make another project with the same features as that of ‘Project A’ for a project called ‘project B’. But for ‘project B’, I don’t want to make a different Xcode file but rather want to incorporate the changes in ‘project A’ itself so that when I run the same project, I’ll be able to run project A or project B as per my need. How can I achieve this…?
Click on your project, Goto General > Targets.
Right click on your project Target and select Duplicate.
You will get to choose between iPad and continue to duplicate for iPhone.
Going ahead in each new/existing file, you can choose which target it belongs to and keep doing your development. If you exclude the file from an target, it will not contribute to that app's size.
You can also keep your future files in both Targets depending on your needs.
I have my own framework which I've made. I use this framework in another project I made. That is, after building my framework, Dragged the Product, .framework to Embedded Binaries of project.
However, I've to continuously make changes to the framework. So the process of dragging and dropping again and again is a lot of work. How to conquer this ?
Can someone tell the exact steps even if it means including the project as well ?
Copy the framework Project to your project folder.
Open your Project in xcode.
Right click on the Project File on left side of xcode and click on option "Add file to Project Name" and then select the framework project here.
Delete the Product .framework available in the embedded libraries and add the framework product properly.
So your goal is to 'deploy' changes made to .framework to all the projects you've already embedded it in previously. Here is one approach to it.
Create [myFramework]Targets.txt file where you'll be putting all the locations (directories) of your framework in different projects, line by line. It will have something like this:
~/Path/to/project/A/Frameworks
~/Path/to/project/B/Frameworks
~/Path/to/project/C/Frameworks
Create deploy_framework.sh file with script that will replace your framework everywhere you need. I'm definitely not the one you can call a Bash expert, by here is what it probably looks like:
for destination in $(<[myFramework]Targets.txt); do /bin/cp -rf /Path/to/updated/[myFramework].framework "$destination"; done
Now, whenever you're done with your framework changes, just run deploy_framework.sh from Terminal. Assuming your Xcode projects have existing reference to .framework and you didn't change its name, it should work.
NOTE: You might still need to do Clean+Build for your projects to compile with updated framework. I believe you can also tweak project settings to 'cache' builds less aggressively.
Let me know if it works for you, we might need to adjust script a bit, since I never tested it.
I have an iPhone app that needs to be physically cleaned to prevent the following build error:
This is what I have in the Navigator:
And this is what I have in the Localization section of Build Settings:
It works, but I'm not sure this ever worked the way it was supposed to; it was written several (like 4) years ago. Now, I am trying to clean it up so I can convert it to a universal app (first I need to make sure it works as designed before making any drastic changes.)
Can someone please point me in the right direction for cleaning this up? (I.e. what files to delete, or ?)
Here is what probably happen in that project:
This xx.lproj file is a legacy. You should be able to find it in Finder but not in a Project Navigator. Like this:
This is only the internal structure of xcode so just remove references from project navigator for all this ``xx.lproj` groups without removing files from project and you'll be fine.
If the app stop building you may need to re-add this files to your target, to do this just select a "parent" storyboard and go to "File Inspector" (first tab on Utilities panel) and select desired target.
I have an XCode workspace created with XCode 6.0.1. It constains 2 (Swift) libraries and one iOS app (Swift) that depends on those 2 libraries. I had stable setup that allowed me to run the iOS app on both iPhone and simulators: The 2 library projects were added as Embedded Binaries (see picture) of the app.
Now, I have XCode 6.1. Recently, I deleted DerivedData folder in ~/Library/Developer/Xcode folder while XCode was running. After that my workspace did not work - the iOS app would fail to compile and I got linker error saying it cannot find the library projects.
I tried to solve it by removing my the 2 libraries from Embedded Binaries of the app project - and I cannot add them back. Clicking + button under Embedded Binaries in project settings displays workspace projects correctly but selecting and adding my library project does not add them to the list of Embedded Binaries. I have solved the linker error by creating new workspace. The app compiles but how it links the libraries is a mystery to me: They are not in listed Embedded Binaries or Linked Frameworks and Libraries not in the Frameworks search path. There appears to be no link between the app and the libraries it needs (and obviously have as it compiles) except that libraries projects are in the same workspace.
Why I cannot add library projects to Embedded Binaries? Is it normal in XCode 6.1 that dependency projects just compile and gets embedded into an app without being listed or linked anywhere?
This is a summary of my answer to the question Xcode won't add “Embedded binary” after deleting “DerivedData”, see the original question and answer for more context and information:
Remove all framework projects from the workspace
Perform a "clean build" and/or remove the "DerivedData"
Add project back into the workspace
Build the project (possibly optional)
In the General tab of the app target click the + under "Linked Frameworks and Libraries", select the framework.
Build and run in the Simulator (there should be no issues building or running)
Build and run for device (this might cause a crash due to the framework not being correctly linked, ignore this crash)
Click the + under "Embedded Binaries", select the framework. This should add it to the project (possible duplicate under "Linked Frameworks and Libraries")
Repeat for all required frameworks
Once building and running (on device) is confirmed you can remove any duplicate (and/or red) frameworks in the Project Navigator or target General tab
Ok, I ran into the same problem as you. After deleting the derived data, I could not re-link my binaries again. I think the reason is because the derived data is where the binaries are written to and linked against in your project.
What I did to solve was to select my Framework as my build target. After building it, the Framework target turned from red to black. I can see in your screenshot it is red, meaning it has not been compiled into a binary and written on disk.
Once I did this, I was able to re-link the Framework to my Project because there was a reference to it on disk. Hope this helps!
Clean your projects & build your framework first. Thereafter you can embed it.
Here is how I solved the problem:
Build the framwork.
Open the build folder and drag built framework into the app project (so it uses the path to DerivedData).
Add the framework to the list of embedded frameworks.
In the Finder, do a Show Contents on the app's xcodeproj file, then open project.pbxproj in your favorite text editor.
Find the line with the long DerivedData path. Change it so there is no name, the path is the framework name, and source tree is BUILT_PRODUCTS_DIR
Xcode should notice the change and the library in the app project will be black instead of red and will now build and run properly.
I have a very similar issue and fixed it just last night. Decided to come back to this thread and offer my workaround, as rjstelling's solution above did not help my case.
I have a workspace that contains two frameworks and one application. The App was making use of both frameworks happily for a while until I got hit by a mysterious compile eror where it decided that adding a property access to an instance variable called "cube" of a class type found in one of the framework, made access to "_cube" impossible (complaining it was not declared, while it had actually worked previously in a setter method).
Long story short, after a clean, somehow the workspace/app project lost track of the embedded framework of my iOS 8+ project. Removing the embedded framework was the last straw in that line of failure, causing my project to no longer allow be to select any frameworks for embedding.
Reverting the project & workspace to an earlier version did not get rid of the voodoo.
I ended up adding the to-be-embeded framework projects in the main app project (as files) and introduced target dependencies on the frameworks.
I was then able to re-embed the frameworks and link.
As for the _cube thing, I had to specify a getter for the property and #synthesize the property to a different name. I dont have an explanation for this one.
It's probably because your framework is a separate project and not a separate target. Try watching carefully Session 416: Building a Modern Framework at around minutes 34-36. It will show you how to set it up correctly.
This makes it a bit confusing if you wanted to share a framework across multiple projects by the way
Xcode 4.5.2, using cocos2d-iphone 1.0.1 for game development.
Recently, I have realized that every time I replace an image file with one of the same name, the project in my device will continue using the old one when I create a CCSprite with such file.
This can be fixed by simply cleaning the project.
However, now the project is rather large, and compiling after cleaning takes quite an annoying amount of time.
Is it possible to replace files and make Xcode use the correct files instead of having to clean the project?
Another simple fix is to give a different name to the new file and delete the old, then change the CCSprite to use the new file name. Of course, this is ridiculous so I'd like to avoid doing it.
I believe that it also happens even when I just delete the app from the device - it seems I do have to clean the project.
Open Organizer in your Xcode. Goto the Projects tab.
you can see Derived data options. Click Delete near to that option, to clean your project