I have a few xcode projects (static libraries) that I include in several other projects through the use of git-submodules. This works great and I like this way of sharing code between projects. However, since I am adding some of these libraries to pretty much every new project I create I would like to streamline this process somehow. Create some sort of "template" of which I can base all my projects.
I would like some way to automaticly go through these steps:
Create a new project called X
Add a fixed (or dynamic) list of submodules
Have the added submodules automaticly added to the Xcode-project
Is it possible to create a script for this? With a syntax like:
fooproj -n "Bar" -s "foundation, coredata, uikit"
(where Bar is the name of the new project and foundation, coredata and uikit would be the submodules to add)
Or is there some other way I could streamline this process?
Have you looked into Xcode Templates? They're quite powerful and are the basis of how Xcode currently sets up new projects. Here are a few links on how to create Xcode templates:
NSScreencast, bob Mccune's blog, meandmark.com
And a few sample resources to get you started:
Xcode 5 project templates and Minimal templates
They're confusing at first, now I couldn't live without them. Xcode templates are a huge time-saver.
Related
I'm creating a RN app that is meant to be some kind of wrapper. It should have multiple targets (like in Xcode) and all its content (images, text, etc.) should be target dependent. Unfortunately, I cannot find any useful informations about how to achieve this without opening Xcode or Android Studio project and create those targets manually (like here). Is there any other solutions for this?
I was still struggling with described problem but I finally found a solution. It's not easy, needs writing a bit of boilerplate code and looks more like a workaround but I hope it will help someone in the future. What I did is I have completed my wrapper app with the resources for one of my targets so I can have visual effect. In the project's root directory I've created a folder with subfolders for each target. Inside each I have put files (images, source code files, other assets) that are target-dependent. Then I've created bash script that takes one argument - target's name. Based on it, it replaces all the target-dependent files from target's subfolder to the original file's destination in the project structure. In this proces all meta-data informations are also replaced so after firing .sh file I can build the app and upload it to both stores. It's really time consuming to create all these apps separately and publish them and it's maybe not the best solution, but at least it works!
On android, you can edit build.gradle files, java or properties, without having to launch Android Studio (which simply uses Gradle)
You can build different type flavours by only changing app/build.gradle
On iOS, that's another story. Project file (.pbxproj) is a mess,and other Workspace/Scheme files are not easy to read or script. So XCode is the way to Go.
I tried to have dynamic target & Info.plist, there are tools to script that like PlistBuddy
in the end, I saw there are many ways to launch a React Native app for developpers. Some prefer the command line, and only VSCode.
Others want to play with native IDE.
By the way, native IDEs are VERY useful.
e.g. : you want to fine-tune your application performance, using XCode view hierarchy debugger or android Studio Layout Inspector (and be sure you don't use to many views), or use any other performance tools these IDEs offer...
In the end, I used react-native-config along with multiple almost similar configs (Info.plist < target < Scheme for each), here's a post giving an overview of the setup.
I have two projects. One is written in Swift 3, while the other is written in Objective C. Both compile and run fine.
I have tried to add the Objective C project into Swift by adding files to the project. The project won't build because it can't import the bridging header. I have spent two days on this and am certain that I am correctly specifying the location of the bridging header and header files under build settings. I'm now looking for an alternative approach to merging these projects.
From Apple: In addition to organizing all the files in each Xcode project, a workspace provides implicit and explicit relationships among the included projects and their targets.
Does this mean if I add the two projects to a Workspace that I can build the two targets into one target resulting in one product? I read something about using schemes, but the post wasn't detailed. I'm running Xcode 8 and Swift 3.
Thanks.
Workspace is used to maintain multiple projects in single space.It wont merge two projects and create a single target/product.
Simple way to add bridging header, create a new ObjectiveC/Swift file in the project will prompt "Would you like to configure an Objective-C bridging header?" dialog by xcode, will automatically create the "yourprojectname-Swift.h" file for you.
I'm developing a project, an application, which will have several versions. I will reuse your source code and change only some superficial characteristics.
To help in versioning App, I adopted the solution of using multiple Target's to create different versions of the app, reusing the source code
But I have a question of how should I set up Xcode.
I performed the following operation:
I created a Target Template, possessing all the functionality I need, so whenever I need a new version I duplicate the Target Template.
But when I need to insert a new class, it is not automatically inserted into the target's already created, so I have to tell Xcode to be included the new class in the other target's hand when creating the class.
I would like to know how to set up Xcode so that every time I add a new class in the Target Template, this class is automatically included in other targets.
If someone possessed some guidance on how I can create multiple versions of the same app than with the use of multi targets.
I'm open for suggestions or other solutions!
Thx!
Note. I'm using Xcode 6 and Swift.
I would suggest setting up to have a library, (static or shared), target for the common, back end, code, possibly with a test harness in the same "project" and then using the same common back end in all your GUI targets. You could even have a GUI components library in a similar manner.
Your workflow would then be to develop and test your new back end code and classes then, when you are happy with it, simply rebuild your GUI targets. If things like menu items are derived from the back end codes published interfaces you would not even have to add the new functionality to them all, it would happen automatically on a rebuild.
Also look at using makefiles for building your code, then you can have a build all at the level above to rebuild all your GUIs.
I am not sure about XCode but a lot of IDEs now support having a super-project, called different things in different tools, that consists of multiple projects so that you can simply load your super project and build all in that.
[UPDATE 03/04/2015]
The question is now 4 years old, and applies to a specific version of XCode which I have now specified in the subject.
I have searched a lot for this argument, but I couldn't find a solution, I even post on stackoverflow, but I soon deleted the question becuase of very little access.
Now I am trying again.
I have a workspace with two distinct projects A and B.
B has two targets, one that build a static library Blib.a, and one that build a bundle B.bundle. All of them get built in the derived directory.
In project A I can easily add the static library from the build phases. However I cannot find a way to include the bundle. B.bundle is not visible from "copy resource" tab in A.
Therefore I need to add manually, with all that implies.
I also thought about using a script, but I would like to use this as a very last option.
Has someone a solution for this ? Did I miss something ?
thanks
After long investigation, it came up there's no easy way of doing this. The B.bundle is never visible to A project, and there's no settings in workspace to change that.
At this point there are three solutions:
Include the bundle manually from "copy resources->other", I started with this, but everytime there's a change you have to drop and include the bundle again
Create a script to be run in build phase, if everything is built into the PRODUCTS dir you can find the bundle easily and having copied automatically into the app.bundle. This is not a bad solution. If you are using svn the script got included in project, and users have it for free without additional work.
As suggested by Apple tech support, use folder references.Build bundle B into a folder and add such folder to project A using the "Create Folder References for any added folders" option. Xcode 4 will update your bundle into that folder every time you built it.
The added folder will appear as blue once included in your project A.
Thats's it, I personally use the script, because this solution is path independent if you use standard xcode reference variable such as BUILT_PRODUCTS_DIR and so on, and the shell script is just a cp -r-f
[UPDATE 03/04/2015]
I would like to point out that the question is now 4 years old. At that time there weren't many "official" options available. I even spoke with Apple Tech Support, which proposed solution 3 as the only available solution. It is of course very likely that things are now changed, and there is a much better solution. Just to speak, I also like to add that the three above are not "hacks" but "solutions", maybe technically outdated, but they can still be used nowadays. I intend a "hack" as a..."hack", which means it probably not going to work in future software release.
Here is how I did it.
Drag and drop B.bundle from Project B → Products → B.bundle into the Copy Bundle Resources build phase of your app in Project A (select the Create groups options when asked). This will add B.bundle at the root of your Project A outline. You can move it into the Frameworks directory near Blib.a if it you prefer.
Select B.bundle and check its Location in the Identity and Type right panel (Utilities area). By default, Xcode chooses Relative to Project. This is wrong, select Relative to Build Products instead.
The path to B.bundle will now look something like ../../../../../../../../Projects/MyApp/B.bundle. This is not what you want, but you can easily fix it. Open ProjectA.xcodeproj/project.pbxproj in a text editor, search for this path and delete everything in it except for B.bundle. Your project.pbxproj should look like this:
explicitFileType = wrapper.cfbundle; name = B.bundle; path = "B.bundle"; sourceTree = BUILT_PRODUCTS_DIR; };
Save your project.pbxproj file. Xcode will automatically reload your project and your app should build just fine.
After searching for a long time and failing many times, I found this resource that has been an absolutely great tutorial to create Static Libraries and include bundles in your main project or even for distribution to 3rd party developers that may consume your library.
Absolutely recommended:
https://github.com/jverkoey/iOS-Framework
In project A, is the product of project B a dependency in your scheme's Build action? I think you might have to set up this dependency (sometimes disabling the automatic dependency discovery option is best) for it to show up and be available for copying into another target. I believe this is because it doesn't really exist (like an image resource file) until it's built and Xcode needs to ensure it's built before working with it from another target.
As of Xcode 5.1.1 I was able to drag and drop B.bundle from the Project Navigator to the Copy Bundle Resources list of project A Build Phases. I assume creating B.bundle target is not an issue.
Switch build to Generic iOS Device. This step is needed to create a non-simulator reference.
Drag the .bundle to the other project's Copy Bundle Resources.
Select the .bundle in the Project navigator of the other project, and change its Location to Relative to Build Products
Make sure your .bundle in added to Target Dependencies of your static library
My team is creating some standard VS solution templates. We have a well-defined project structure, resources, etc. that we need to use every time we start a new project and this is the perfect solution. The basics work nicely.
However, as well as defining folder structure (etc.) it would be nice to be able to import a number of projects from VSS/TFS. We have a number of shared assemblies that will be used by all projects and it would be awesome to add a reference to these projects when creating a new project via our template. Can anyone tell me if this is possible and, if so, how it can be achieved?
I think there are 3 types of items you might want to templatize (is that a word?).
New Solution
New Project added to a solution
New item added to a project
I'm not sure whether its possible to add existing projects to the solution that is created when a project template is run. http://msdn.microsoft.com/en-us/library/ms185308.aspx shows how to create multiple project templates. You may have to either manually add them to the solution or create a script that modifies the .sln file to do that part.
Adding an assembly reference to either a project or item template is easily doable. The project template is pretty simple since you just need to modify your .vstemplate file for the project template(s). See http://msdn.microsoft.com/en-us/library/ms171405.aspx for reference.
Adding a new assembly reference when you add a new item from a template is a bit harder but can also be done. See http://msdn.microsoft.com/en-us/library/ms185290.aspx for more.
Have fun!