Rename XCode project AND iOS app, but retain old app - ios

I'm trying to further develop a sample application while keeping the original on my phone at the same time.
All answers here how-to-change-the-name-of-an-ios-app do not work completely because the new app will overwrite the original one, therefore anytime I want the original one back on my phone I have to run ('install') that one again. There must be some additional step that has to be taken.
I apologize for creating a new question, but I cannot comment on the old one due to a lack of reputation and I see no point in answering a bunch of random questions that other people are more qualified to do just to gain some.

I recommend you to create a new target in existing project. You can do this by duplicating exiting target.
In this target change bundle identifier. (New target's general tab) So it will not overwrite existing application.
change Bundle display name to identify your new application from exiting one. (New target's info tab)
This way you can have files only related to you sample application. When you want to build original target you just have to change the target from XCode and build.

You can double click on your project's name here so that it is selectable and editable.
I doubt it will overwrite your old app because it has a different name. I haven't tested this on any iOS device but in the simulator it doesn't delete the old version.

Related

Is there any better way to rename an XCode project than the given one?

The given version is described here: How do I rename a project in Xcode 5?
But, as you can see from the following screenshot^, not everything gets renamed, and if one opens package contents, directory names etc. to try to manually change all the references, the project is broken afterwards, so you have to keep the old project name for sub directories etc., which granted is not a massive problem, but is intensely irritating, and I'm not enjoying being intensely irritated at work.
^ apologies for a screenshot, but there's too much information in it to transcribe to written text. Top two-thirds of screenshot is XCode project, bottom third a Finder window.
Renaming projects in xcode in one of the most annoying things in iOS development. I assume you want to rename your app. I faced this problem once and figured out a simple, clean way to do it.
Go back to the point where everything worked.
Open project in xcode and click on the project icon in the project structure( first file)
Go to the info tab
Search for Bundle Name. Most probably it will automatically be set to $(PRODUCT_NAME) which is a shell variable that will set your app name the same as the project name.
Set it to whatever you want your app name to be
Done
Notes :
If you use custom URL Schemes this might produce an error when redirecting.
ALWAYS git or some other SVN in your projects. This will come in handy in this kind of situations

Re-add the xcdatamodel to the Build Settings

While I was busy trying out stuff for this question, I accidently removed the xcdatamodel-package.
I found out that recently there was this question which mentioned the following:
For some reason, the xdatamodel was removed from the build settings. I added it back in and it worked.
I tried doing what he did, but I don't know where to start.
I recreated the package, but when I try to set an attribute value, I get +entityForName: could not locate an entity named 'EN'...
All I know is; it did work until I started fooling around with not-tutorial-attributes and stuff.
What they're getting at in that other question is that when you add a file to a project, it's not necessarily added to the current target. You can have multiple targets in a project, and you can add files that don't get compiled (e.g. developer documentation), so it's possible to add a file but then have it just sit there and not get built.
If you select the file in Xcode and open up the Utilities pane on the right, there's a section that shows target membership. It looks like this:
This one shows that the file belongs to the project momdecTests but not to the project momdec. Make sure your app target is checked here.

What is the best way to have multiple variations of a product in Xcode?

I have a project that I maintain for a client; let's call it MyDataAssistant. When the project goes into beta, the client likes to have a "separate app" built for them, which I create using a different provisioning profile and a modified bundle identifier (MyDataAssistant-BETA). It's a pain to always be going back and forth and changing the bundle identifier, code signature settings, and especially the icon. I understand that you can have multiple targets and multiple build settings (within each target?) in a project, but I'm not clear on what the difference is, or how to use them appropriately.
Additionally, the client would like a third version with read-only capabilities. I can accomplish this by just making a flag return from a certain part of my code, but I would like it if that flag could be toggled in the build (target?) settings.
Please advise on how to manage this kind of project with multiple "variations" of the build.
Add a new configuration to your project by duplicating the release one for example.
Give it a name "Beta"
Add a User-defined build setting
Call it MY_DATA_ASSISTANT_BUNDLE_ID_SUFFIX for example and set the value to be -BETA only for the Beta configuration.
Edit the MyDataAssistant-info.plist file by setting the bundle identifier to com.YOURCOMPANYNAME.MyDataAssistant$(MY_DATA_ASSISTANT_BUNDLE_ID_SUFFIX)
This will make it have different values for the different configurations.
You can also set the display name to have a different value by setting it to $(PRODUCT_NAME)$(MY_DATA_ASSISTANT_BUNDLE_ID_SUFFIX)
Set the right provisioning profile for each configuration. (Of course after creating the beta one in the provisioning portal as if it was for a new app with the bundle identifier having the suffix "-BETA")
Create a new scheme!
Give it a name: MyDataAssistant-BETA
Change its build configuration to "Beta" for all the actions and you should be ready to go.
If you want to have different icons for the beta version you can use the $(MY_DATA_ASSISTANT_BUNDLE_ID_SUFFIX) in the MyDataAssistant-info.plist file for the icons names and of course add them to the target.
I would recommend creating two targets. This will allow you to share what files you want between variations, as well as have custom source, or config files in each. The simplest implementation of this would be to have an identical target except for the info.plist file.
Simply right click on your current app target in project settings, and hit duplicate.

How can I avoid having to clean the project after replacing files?

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

xcode 4 editing multiple targets duplicates changes

I have a project setup with two separate projects in two separate schemes, the only difference between the two targets is that they have different bundle ids and different icons. However whenever I change the second target and build it the changes are copied to the first target. I'm not sure what's going on, the only thing I could think of is they have the same product name so the app executable name is the same. Does someone know if this is causing it and if so how could i fix, or is something else going on?
Thanks
Presuming that in your new target have you specified a new plist file
and that the target points to this plist file and as you pointed out you also changed the product name in the build settings, the only thing I can think of at this point is that your schemes are both pointing to the same executable. Open both schemes in the scheme editor and look at what the executable field is pointing to. They may both be pointing to the same thing.

Resources