I am using https://github.com/tuist/XcodeProj in an attempt to add a file to a specific target. Basically I'd like to do the following thing done via ruby mirror using Swift:
require 'xcodeproj'
source_root = '/path/to/xcodeproj'
project = Xcodeproj::Project.open(source_root)
group = project.main_group['TestProject']['TestGroup']
file = group.new_file('TestFile.swift')
target = project.targets.first
target.add_file_references([file])
project.save
So far, I've managed to add the actual file to project but couldn't manage to add it to a specific target:
let sourceRoot = Path("/path/to/xcodeproj")
let project = try XcodeProj(path: sourceRoot)
let target = project.pbxproj.targets(named: "some target name").first!
let group = project.pbxproj.groups.first!
let fileReference = try group.addFile(
at: Path("TestFile.swift"),
sourceTree: .group,
sourceRoot: sourceRoot
)
try project.write(path: Path(sourceRoot))
My question is, how can I add a file reference fileReference added to the project into a specific target programmatically using the library I mentioned above?
Try something like the following (also review Target Object API for details)
try target.sourcesBuildPhase().add(file: fileReference)
Related
We are using the Autodesk Forge Viewer DiffTool extension, but we need to change one of the texts:
Every tutorial shows how add localization to your own extension, but I couldn't find how to change a translation in an existing extension you are using.
Moreover, without knowing what the translation key is, I would have "guess" it, which isn't really great either.
So, how do I change the translation for this text?
There is no supported way to hook into the translation service of the Viewer to change the text. If the translation is wrong, please let us know, and we can fix that on our side.
If you want to change the text for some other reasons, then one thing you could do is wait for the initialization of the extension's UI and change the button's content using DOM APIs:
let extensionConfig = {}
extensionConfig['mimeType'] = 'application/vnd.autodesk.revit'
extensionConfig['primaryModels'] = [model1]
extensionConfig['diffModels'] = [model2]
extensionConfig['diffMode'] = 'overlay'
extensionConfig['versionA'] = '2'
extensionConfig['versionB'] = '1'
extensionConfig['onInitialized'] = () => {
let button = document.getElementById("diffFacetsRemovedButton");
let label = button.nextSibling;
label.innerHTML = label.innerHTML.replace("Odebrat", "Něco jiného");
}
viewer.loadExtension('Autodesk.DiffTool', extensionConfig);
I tried to use this simple script (its not from me) for simple reading a file and adding its content to a plugin called projectionist: https://github.com/tpope/vim-projectionist
(The original script: https://github.com/andyl/vim-projectionist-elixir/blob/master/ftdetect/elixir.vim)
I didn't find any api for reading a file in lua nvim. The error in the picture targets the line let l:json = readfile(s:proj_jsn) so I assume that this api is not available by lua?
if vim.g.loaded_vim_projectionist then
return
end
vim.g.loaded_vim_projectionist = 1
vim.api.nvim_exec([[
let s:base_dir = resolve(expand("<sfile>:p:h"))
let s:proj_jsn = s:base_dir . "/projections.json"
function! s:setProjections()
let l:json = readfile(s:proj_jsn)
let l:dict = projectionist#json_parse(l:json)
call projectionist#append(getcwd(), l:dict)
endfunction
call s:setProjections()
]], false)
The error message (picture)
I checked a several times if the file projections.json is in the right place, so this is not the mistake.
Thank you all in advance.
All,
I am trying to get the list of all the files that are in a particular repo in TFS GIT using REST API.
I found the below one but it only display the contents of the specific file name mentioned after "scopePath=/buld.xml", it only display the contents of file build.xml.
But I am trying, only to list all the files that are in a particular repository with out mentioning the particular file name.
Please help me.
https://{accountName}.visualstudio.com/{project}/_apis/git/repositories/{repositoryId}/items?items?scopePath=/&api-version=4.1
You can use the api below:
https://{accountName}.visualstudio.com/{project}/_apis/git/repositories/{repositoryId}/items?recursionLevel=Full&api-version=4.1
Also that could be achieved using VisualStudioOnline libs (at the date of writing comment it becomes AzureDevOps): Microsoft.TeamFoundationServer.Client, Microsoft.VisualStudio.Services.Client.
First, you need to create access token. Then just use code below:
VssBasicCredential credintials = new VssBasicCredential(String.Empty, "YOUR SECRET CODE HERE");
VssConnection connection = new VssConnection(new Uri("https://yourserverurl.visualstudio.com/"), credintials);
GitHttpClient client = connection.GetClient<GitHttpClient>();
List<GitRepository> repositories = await client.GetRepositoriesAsync(true); // or use GetRepositoryAsync()
var repo = repositories.FirstOrDefault(r => r.Name == "Some.Repo.Name");
GitVersionDescriptor descriptor = new GitVersionDescriptor()
{
VersionType = GitVersionType.Branch,
Version = "develop",
VersionOptions = GitVersionOptions.None
};
List<GitItem> items = await client.GetItemsAsync(repo.Id, scopePath: "/", recursionLevel: VersionControlRecursionType.Full, versionDescriptor: descriptor);
Under the hood it's using the REST API. So if you try the same effect using c# lang, better delegate it to lib.
You need to call the items endpoint first, which gives you an objectId (the gitObjectType should be "tree"):
http://{tfsURL}/tfs/{collectionId}/{teamProjectId}/_apis/git/repositories/{repositoryId}/items?recursionLevel=Full&api-version=4.1
Then call the trees end point to list the objects in the tree:
http://{tfsURL}/tfs/{collectionId}/{teamProjectId}/_apis/git/repositories/{repositoryId}/trees/{objectId}?api-version=4.1
test
I have added the plugin but cannot to setup config file(intelxdk.config.additions.xml).
If I add this code to config:
var customLocale = {}
customLocale.title = "Rate %#";
customLocale.message = "If you enjoy using %#, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!";
customLocale.cancelButtonLabel = "No, Thanks";
customLocale.laterButtonLabel = "Remind Me Later";
customLocale.rateButtonLabel = "Rate It Now";
AppRate.preferences.openStoreInApp = true;
AppRate.preferences.storeAppURL.android = 'market://details?id=com.site.test';
AppRate.preferences.customLocale = customLocale;
AppRate.preferences.displayAppName = 'My custom app title';
AppRate.preferences.usesUntilPrompt = 1;
AppRate.preferences.promptAgainForEachNewVersion = false;
AppRate.promptForRating(true);
nothing happing when I test my app on real device.
First off, go to the project tab.
Go in plugins->
Third party plugins.
Click on Get Plugin from the web.
For the name, write AppRate or anything you whant. For the plugin Id, write org.pushandplay.cordova.apprate and check "Plugin is located in the Apache Cordova plugins Registry".
BE WARNED that any third plugins can only be tested on the build tab.
After all that it should work.
P.S, there is nothing to add in the additions.xml file to make it work. Just put your code in a function that you call and it should work like a charm
I want to include some third party code (specifically https://github.com/ortuman/SwiftForms) in my XCode 6 + Swift project. How do I do that?
Very easy :
Download the archive.
Extract it.
Move required files to your project folder
Add the required files to your project.
Clean project
It's done
Simply add the source .swift files to your project, (drag and drop to the file tree on the left hand side of Xcode - you can see the file tree here).
The files you'll need are here.
As stated on the github page: Swift projects is currently not supported by Cocoapods. Until support is available you should just clone the repository and drag the source folder into your project to use SwiftForms.
Once you have the source .swift files presenet in your Xcode project you can create a form as described in the documentation:
"Creating a form using SwiftForms is pretty straightforward. All you need is to derive your controller from FormViewController and define a FormDescriptor instance along with its sections and rows. Here is an example of how to create a simple form to input an email and a user password."
// Create form instace
let form = FormDescriptor()
form.title = "Example form"
// Define first section
let section1 = FormSectionDescriptor()
var row: FormRowDescriptor! = FormRowDescriptor(tag: "name", rowType: .Email, title: "Email")
section1.addRow(row)
row = FormRowDescriptor(tag: "pass", rowType: .Password, title: "Password")
section1.addRow(row)
// Define second section
let section2 = FormSectionDescriptor()
row = FormRowDescriptor(tag: "button", rowType: .Button, title: "Submit")
section2.addRow(row)
form.sections = [section1, section2]
self.form = form