Can you create per-user project settings in Xcode? - iphone

I'm collaborating on an iPhone application, with the project files (.xcodeproj directory) checked into source control. One important setting is the "Code Signing Identity", which specifies the certificates to use to sign the application in order that it can run on the iPhone.
Each developer on the project has his own Code Signing Identity, so whenever anyone makes a change to the project, his Code Signing Identity gets saved into the project settings, and then everyone else inherits that change. They then have to change that to their CSI before they can continue.
Is there a way to have the Code Signing Identity saved in some local per-user project file that doesn't get checked into source control?

You could base the Xcode project on an .xcconfig file, then make each developer use their own .xcconfig file and keep the identity setting in there.

Either that or have your source control system ignore the file that contains the signature, in git you can create a file called .gitignore, theres probably a similar thing for what you are using. It means even though you've changed it the change won't get mirrored.

I worked around this by making different builds. The one named "Dev - Rob" had my settings in it, and the one named "Dev - [Other Guy's Name]" had Other Guy's settings.
We also used this to make builds like "Release - Beta" and "Release - AppStore" etc., for all situations where we'd have different signing configurations.

Related

Is the a way to share a preconfigured vscode.dev?

The situation is, I want to share my settings of vscode.dev to others. That could include
extensions installed
tabs opened (not files, but some extension related tabs such as panels or previews)
So the person who clicked on the shared link can go to vscode.dev, but with my configurations.
Try to use Settings Sync, its the easiest way: Settings Sync
You could try to create a settings.json too, and share that file with others.
I think the only solutions you have here is to use either GitHub Codespaces (Dev Containers) or store config in repository.
Basically you will not have a link for preconfigured vscode.dev. The idea is to have all required configuration in devcontainer.json file committed it to repository. So whenever the repository is opened VSCode uses the file to configure environment.
Also you can change you settings in Workspace and right click on extensions and click "add to workspace recommendations". That will create .vscode/extensions.json, .vscode/settings.json and commit .vscode folder into repository.
TLDR: commit VSCode configuration files into repository and open repository in vscode.dev
Look into Profiles, which can be enabled in your Settings (currently experimental but will be made generally available in vscode v1.75 due out very soon.
Current setting in Stable: Workbench > Experimental > Settings Profiles: Enabled
There is no setting for Profiles in the Insiders Build, it is just enabled by default. I assume when v1.75 Stable comes out that will also be the case.
See v1.75 Release Notes: Profiles:
We are happy to announce that the Profiles feature is now generally
available in VS Code. A Profile can include extensions, settings,
keyboard shortcuts, UI state, tasks, and user snippets. You can
customize VS Code for different development scenarios like data
science, documentation writing or for multiple programming languages
like Python or Java. If you have different VS Code setups based on
workflow like Work or Demo, you could also save those as different
profiles. You can open multiple workspaces (folders) with different
profiles applied simultaneously.
{image omitted]
You can also export and import profiles to share them with your
colleagues, friends or students to help them get started with VS Code.
The following video demonstrates how to export a profile using a
GitHub gist in order to share it with someone. Users that receive the
profile link can preview the shared profile in VS Code for the Web and
import it to their local VS Code instance.
There is a nice mp4 demonstration in the link, but it appears SO would take that format.
You can export a Profile to a Github Gist so that it can be imported by someone else or to a local file you can share (or yourself to a new maching, etc.) - my demo shows all the settings, UI State and extensions it can include.
More info on Profiles at v1.69 Release Notes: Settings Profiles

Xcode GIT problems iPhone App

So I made a repository for an app and everything in Xcode is setup. Now another person tries to pull it and that works fine until this message appears: The File "UserInterfaceState.xcuserstate" could not be unlocked, unlocking failed for an unknown reason.
The project uses the Google Maps API and gives the error: "GoogleMaps/GoogleMaps.h" file not found. Even though the project is a direct clone, it works for me but not for him.
For the error of "GoogleMaps/GoogleMaps.h" file not found.
You may have not set the path properly. For setting right path do following steps:
Go to Targets -> Build Phases -> Link Binary With Libraries
Click on + option
Select the GoogleMaps Framework. If you have added it from outside than go there & select it.
Go to Targets -> Build Settings -> Header Search Paths
Remove the older path of Google Maps API from it (keep new path don't remove it)
For "The File "UserInterfaceState.xcuserstate" could not be unlocked" issue
refer this : http://www.meetup.com/818-iOS-Developers/messages/boards/thread/20469352
You probably corrupted the file by using Git, that, or you overwrote a locally saved file with something from the cloud. Try recreating the project without using Git, and see if it works.

Code signing in project settings, target settings and re-signing after creating the archive

I have seen a few questions similar to this. So the target settings override the project settings. I got that, but if I don't want to override the project settings, is that what the "Don't Sign" option is for?
What am I supposed to do after archiving my app, when it asks if I want to re-sign it? If I have set the signing at the project or target level, should this be set to "Don't Sign"? What happens if I elect to re-sign it? Does the signing done during the previous archiving step get overridden and replaced with the new choice?
Can I look into an archive (.ipa) file and see what provisioning profile was used? I don't see the option in Finder to open it like I can open other bundles. How can I do this?
Just unzip the ipa (unzip appname.ipa) and do the following on the results:
codesign -dvv Payload/appname.app
It should show you the cert used.

How can I quickly set the iPhone deployment target in Xcode?

I was reading this great article about Base SDK and Deployment targets and decided to try it out myself. The Deployment target seems to be buried in the Build settings, and not that easy to access compared to the Base SDK target (which is right there in the General tab of the project settings). To get to the Deployment settings now I have to Get Info, go to the Build tab, then search for "Deployment".
Is there a quick way to check and access the Deployment target in Xcode that I'm missing?
Sure. Never use the build pane. Just put the setting in your xcconfig files, and then it's easy to maintain, easy to find, and easy to comment. I have a detailed talk on how to convert from the Build Pane to xcconfig files and why you'd want to.

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have a manifest file listing what goes in, which limits the copy. We have our own Python script which does the copy, refreshing only the files which have changed.
I have made a Run Script Phase in Xcode to call that script, but I am having a few issues related to the Code Signing phase.
Since we use a separate manifest file, my Run Script Phase cannot specify any input/output file in the Xcode GUI: it varies depending on what is contained in directories at the time. The side effect of this is that Xcode doesn't strictly know what files will get copied (things happen "under the cover", so to speak).
The problem I have is that if I only modify resource files between builds, rebuilding my app will properly call my script, which copies the appropriate files, only Xcode won't rerun the Code Signing step, and won't re-copy my app to my device.
I found that odd, considering that my resource files are indeed listed in the <app_bundle>/_CodeSignature/CodeResources file, but it looks like Xcode determines rebuilds requirements independent of that (likely only files listed in the project file), which is understandable.
I tried playing tricks by touching my app bundle's directory, or the app's binary itself, but it doesn't quite work. Touching the app's bundle directory doesn't seem to do anything, while touching the binary will work, but NOT FOR THE CURRENT BUILD, only the subsequent one (since no input file requires recompilation, Xcode infers no new binary gets generated, but the next time, it will indeed detect that the binary has been touched, and redo both Code Signing and on).
Still, this is quite an imperfect workaround, because:
Having to build twice is error prone
My dSYM file will needlessly get regenerated
Does anyone know of any way to force the Code Signing step in Xcode (from a Run Script, or elsewhere)?
You can call codesign directly from the command line or a shell script, e.g.
codesign -f -s "iPhone Distribution" --entitlements Entitlements.xcent -vv location/MyApp.app/MyApp
Run man codesign to find out the usage.
You can discover all the internal commands run by viewing the detailed build output in Xcode. Select the Build tab, then click the little icon at the bottom left of that window pane - the one that looks like text (it is next to the warning icon). This will show the full build output in a new pane in Xcode.
I created a shell script calling codesign directly so I could re-sign an existing binary using a new certificate and provisioning profile (e.g. after updating some graphics in the binary).
This turned out to be really complicated as Xcode does some subtle stuff as part of its internal build processes (one example: Xcode embeds the provisioning profile in the resulting app binary, but in the process changes some of its values, e.g. the get-task-allow setting). That meant I had to write a tool to generate an appropriate .xcent file from the provisioning profile, depending on whether a Development/Distribution/App Store build is being done. Hopefully none of that will affect you...