I've been trying to add a Copy Files build phase to a project template for Xcode 4 but I cannot figure out how to add files to copy.
Here's what I've added to my target. Changes to DstPath, DstSubfolderSpec and RunOnlyForDeploymentPostprocessing are all reflected in projects created from the template. But no files. I have tried adding an array using keys named Files, Definitions, Nodes, nothing has any affect.
Any thoughts or ideas would be greatly appreciated!
<key>BuildPhases</key>
<array>
<dict>
<key>Class</key>
<string>CopyFiles</string>
<key>DstPath</key>
<string></string>
<key>DstSubfolderSpec</key>
<string>10</string>
<key>RunOnlyForDeploymentPostprocessing</key>
<string>NO</string>
</dict>
</array>
I found a little gem hidden in some weird python script that gave a "better" (as opposed to nothing) explanation of the mysterious DstSubfolderSpec…
# dstSubfolderSpec property value used in a PBXCopyFilesBuildPhase object.
'BUILT_PRODUCTS_DIR': 16, # Products Directory
: 1, # Wrapper
: 6, # Executables: 6
: 7, # Resources
: 15, # Java Resources
: 10, # Frameworks
: 11, # Shared Frameworks
: 12, # Shared Support
: 13, # PlugIns
There's actually quite a bit of interesting info in the script, (apparently it's part of pythonwebkit, or something).. but regardless, I posted a gist of it here if you want to try and glean any other useful tidbits.
So far I have this working:
<dict>
<key>Class</key>
<string>CopyFiles</string>
<key>DstPath</key>
<string>www</string>
<key>DstSubfolderSpec</key>
<string>7</string>
This creates a CopyFiles build phase that copies files to the folder "www" inside of Resources. (This would result in those files living under /www in the app bundle.) However, I haven't yet been able to specify which files get copied. This is similar to this question
I don't know the answer but this may be a workaround. It runs a script with each build.
<key>Targets</key>
<array>
<dict>
<key>BuildPhases</key>
<array>
<dict>
<key>Class</key>
<string>ShellScript</string>
<key>ShellPath</key>
<string>/bin/sh</string>
<key>ShellScript</key>
<string>~/hello.sh</string>
</dict>
Note that the path to the script is absolute. Maybe you can define a path with PathType Group to set it relative to a group inside the project (I didn't try).
DstPath is the destination path of the files to copy (I guess). I don't know what DstSubfolderSpec is, it only appears in the Command Line Tool with a value of 0. I guess you don't know it either.
Related
i create a cocoa application project, and add target "Finder sync extension". Then the "finderSync.appex" will be put to ".../Contens/Plugins/" folder. But when i launch the application, the extension is not loaded automatically, should i load it manually ? How can i load it ?
From the Apple developement guide, it says:
For OS X to recognize and automatically load the Finder Sync extension, the extension target’s info.plist file must contain the following entries:
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict/>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.FinderSync</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).FinderSync</string>
</dict>
I already set as the above, but it doens't work.
You need to register your extension with Finder:
pluginkit -a <path you your appex>
You might also need to tell Finder to enable your extension:
pluginkit -e use -i <ID of you appex>
I am trying to update the Perm Gen Memory in Jenkins, from what I have read adding this to the org.jenkins.plist file would do the trick but it is not changing it for me:
<key>-XX:PermSize</key>
<string>512m</string>
<key>-XX:MaxPermSize</key>
<string>1024m</string>
When I use the Jenkins monitoring tool is still tells me that:
Perm Gen Memory: 81mb
Am I doing something wrong?
Thanks
According to http://mgrebenets.github.io/mobile%20ci/2015/02/01/jenkins-ci-server-on-osx, you should be using <string> but not <key>, eg:
<string>-XX:MaxPermSize=1024m</string>
<key> denotes a section. In this case, you are setting program arguments that fall under the <key>ProgramArguments</key> section. What you specified as key sections is probably confusing the launcher. Look at that link for a complete example and compare to yours.
Abridged example:
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.jenkins</string>
<key>ProgramArguments</key>
<array>
..... more props here...
<string>-XX:MaxPermSize=256m</string>
.... more props here
</array>
... more stuff here...
</dict>
Also note the instructions for properly restarting (unloading/loading) the instance so that the changes are applied. Once you restart it, confirm that the options you set translated properly to the command line:
ps aux | grep java
The properties should be properly formatted as follows:
-XX:PermSize=512m -XX:MaxPermSize=1024m
I don't know whats wrong, I installed FacebookSDK using Cocoapods (as always), and I am getting an error in this method:
_dispatch_once(dispatch_once_t *predicate, dispatch_block_t block)
{
if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
dispatch_once(predicate, block);
}
}
The red line of the error is on the line dispatch_once (predicate, block); . I am not doing anything different than other times using FacebookSDK.
Can anyone help?
Configure your info.plist (find it in the Supporting Files folder in your Xcode Project).
Right-click your .plist file and choose "Open As Source Code".
Copy & Paste the XML snippet into the body of your file (inside of the <dict>...</dict>):
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>FB + AP-ID</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string> AP-ID </string>
<key>FacebookDisplayName</key>
<string>App-Name</string>
If you use any of the Facebook dialogs (e.g., Login, Share, App Invites, etc.) that can perform an app switch to Facebook apps, your application's .plist also need to handle this.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
Source: Facebook SDK Documentation
My app kept crashing and producing the error message:
'The service configuration is `nil`
on the same line:
dispatch_once(predicate, block);
while trying to implement AWS Auth via the Mobile Hub into my iOS app.
I spent a lot of hours editing my info.plist, googling solutions, and re-downloading the awsconfiguration.json file only to discover that my "Target Membership" box in the right side bar of Xcode was unchecked. Once I checked it my app successfully built with AWS Auth working fine.
Hope this helps someone.
So I had the same issue, and fixed it by reinstalling all of my pod files by removing from Podfile, running "pod update" and then readding them and running "pod update" again. Worked like a charm.
It's rather annoying and I can't seem to figure out why.
If you still have a problem with those solutions suggested above (with anaconda lint):
Disable linting altogether within the user-defined Anaconda settings file, Anaconda.sublime-settings, via the file menu:
Sublime > Preferences > Package Settings > Anaconda > Settings – User:
When it opens file, just type the following and save it away ;-)
{"anaconda_linting": false}
At least, it fixed my problem.
Blessings
(a debtor)<><
Looks like you have SublimeLinter installed. It highlights errors and warnings.
Disabling Annaconda linting in sublimetext 3 for current file:
Enter command palette by Cntrl + Shift + P or Command + shift + P for Mac OS X
Type Anaconda: Disable linting on this file and hit enter
To re-enable linting Anaconda: Enable linting on this file
Disabling linting persists between sessions.
Source
You probably can change "anaconda_linter_mark_style" to "none" and keep "anaconda_linter_underlines" as true. This way it'll only put a underscore under errors but not highlight the whole line.
If you don't want to disable SublimeLinter completely, you can set Syntax Specific Preferences.
Preferences -> Package Settings -> Sublime Linter -> Settings Syntax Specific User
The preferences is evaluated similar to CSS, it cascades. Think about the most user-specific, syntax-specific rules evaluated last.
E.g: I also do not like the white rectangle, so I opted for fills.
{
/*
Selects the way the lines with errors or warnings are marked; "outline"
(default) draws outline boxes around the lines, "fill" fills the lines
with the outline color, and "none" disables all outline styles
(useful if "sublimelinter_gutter_marks" is set).
*/
"sublimelinter_mark_style" : "fill",
/*
If true, lines with errors or warnings will be filled in with the
outline color.
This setting is DEPRECATED and will be ignored in future
versions. Use "sublimelinter_mark_style" instead. For backwards
compatibility reasons, this setting overrides "sublimelinter_mark_style"
if that one is set to "outline", but has no effect if it's set to "none".
*/
"sublimelinter_fill_outlines": false,
// If true, lines with errors or warnings will have a gutter mark.
"sublimelinter_gutter_marks": false,
// If true, the find next/previous error commands will wrap.
"sublimelinter_wrap_find": false,
}
For Anaconda/Sublime Users
I have Anaconda and the lint function is useful, but out of the box, it is draconian about style. When you hover over the rectangle, it will tell you the number of the rule it is enforcing. You can disable the ones that you feel are unneeded or get in the way as you code.
On Macs:
Go to Preferences | Browse Packages | Anaconda | Anaconda.sublime-settings
Search for "pep8_ignore"
Add the rules you want to remove.
I've put in my list the following rules that remove some of the white space rules that slow me down but keeps the "no tabs" rule.
"E201",
"E202",
"E203",
"E302",
"E309",
"W291",
"W293",
"W391"
You'll want to set "translate_tabs_to_spaces": true in your user settings if you go with this list.
Alternatively you can set "pep8" to false to stop it entirely.
If you are using Anaconda plugin (for Python development) this is it's linting functionality - it highlights Python syntax errors and PEP8 violations.
You can disable this feature completely or change the color of this outline by adding some custom rules to your current SublimeText theme:
In Sublime Text menu: Preferences > Browser Packages...
Locate source file of your current theme in opened directory (*.twTheme file with the name corresponding to the one, selected in Preferences > Color Scheme > ...)
Duplicate this file, add another name (for example Tomorrow-my.tmTheme from Tomorrow.tmTheme)
Paste the following code to this newly created theme file, right before </array> tag:
<dict>
<key>name</key>
<string>anaconda Error Outline</string>
<key>scope</key>
<string>anaconda.outline.illegal</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FF4A52</string>
<key>foreground</key>
<string>#FFFFFF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>anaconda Error Underline</string>
<key>scope</key>
<string>anaconda.underline.illegal</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FF0000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>anaconda Warning Outline</string>
<key>scope</key>
<string>anaconda.outline.warning</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#DF9400</string>
<key>foreground</key>
<string>#FFFFFF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>anaconda Warning Underline</string>
<key>scope</key>
<string>anaconda.underline.warning</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FF0000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>anaconda Violation Outline</string>
<key>scope</key>
<string>anaconda.outline.violation</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#ffffff33</string>
<key>foreground</key>
<string>#FFFFFF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>anaconda Violation Underline</string>
<key>scope</key>
<string>anaconda.underline.violation</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FF0000</string>
</dict>
</dict>
Adjust the colors to your needs. Save file.
Select your "new" theme in Preferences > Color Scheme > and observe the changes.
Point 3. was needed in my case because color wasn't updated immediately, after just saving theme and restarting Sublime/switching themes (sublime uses some kind of buffer?..). So, maybe you will have to repeat steps 3-6, when you want to play a little with the colors.
Source: Anaconda's Docs
On line 300 "anaconda_linter_mark_style": "none", in Preferences -> Package Settings -> Anaconda -> Settings - Default. This removes the "annoying" highlighting but still checks for pep8 errors
If none of the previous solutions worked for you, try this:
Go to Preferences | Package Settings | Pylinter | User settings
In the file, just add/modify the following lines:
"run_on_save": false,
"disable_outline": true
It worked for me, and in my case I had anaconda only as a folder, associating the python compiler of Sublime to the python compiler (python.exe) present in the anaconda folder.
I just found that this can also randomly happen on the last word that you searched. So if you searched for "integer" for instance. Then all instances of "integer" will have that white square around them.
In Anaconda with Sublime Text, if you don't want to make any changes to the settings:
In the case highlighting occurs, you can use a keyboard shortcut (in my case it's CTRL-ALT-R) to autoformat the code! The highlighting will be gone immediately.
You just have to repeat that every once in a while, after having added new code (which is not formatted according to the PEP8 rules).
The command is "anaconda_auto_format".
if you got the anaconda linting
go in the dir like this C:\Users\giova\AppData\Roaming\Sublime Text 3\Packages\Anaconda
and change the anaconda.sublime-settings (find the anaconda linter keys and set them to false). See if you installed other linter stuff and change their settings to false where it seems to rely on linting until everythings is right for you. I had installed different linters, so I had to change all of them.
you can disable warnings in anaconda.sublime-settings
via the file menu:
Sublime > Preferences > Package Settings > Anaconda > Settings – User:
In opened file type following code and press Ctrl + S to save file
{"pep8": false}
you can also type this:
{"anaconda_linting": false}
but it disables both warnings and errors, which is not good
For me, on sublime 3 this was the PyLinter Package. While the linting feature's useful i also wanted to get rid of the annoying highlight. Found this on their docs if it's helpful! :)
https://packagecontrol.io/packages/Pylinter
I was able to remove the highlight with Command + option + x
The plugin can be invoked by a keyboard shortcut:
OS X: Command+option+z
Linux, Windows: Control+Alt+z
**Toggle Marking**
The marking of the errors in the file can be toggled off and on:
OS X: Command+option+x
Linux, Windows: Control+Alt+x
Whenever I create a new .cpp/.h file in Xcode a comment is added to the top of the file. For example:
/*
* <file>.cpp
* <Name of project>
*
* Created by <My name> on <Date>.
* Copyright <Year and company>. All rights reserved.
*
*/
I want to change the default comment to be another license, like GPL/LGPL/ or something else. Is there somewhere I can change this behavior in Xcode?
With Xcode 9 there is a built-in option which you can find in the details below.
Create a property list file named IDETemplateMacros.plist
Add a FILEHEADER value to the Root and set its string value with your copyright text like Copyright © 2017 ...
Copy the file to one of the following locations
For a single project and user
<ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
For all team members in a single project
<ProjectName>.xcodeproj/xcshareddata/IDETemplateMacros.plist
For all projects in a workspace for a single user
<WorkspaceName>.xcworkspace/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
For all projects in a workspace for all team members
<WorkspaceName>.xcworkspace/xcshareddata/IDETemplateMacros.plist
For everything you work on, regardless of project
~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist
Create a new file - you should see the new copyright header
Sample IDETemplateMacros.plist for copy and paste:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string>
// Created by Your Name on 29.12.17.
// Copyright © 2017 Your Company. All rights reserved.
// </string>
</dict>
</plist>
First try changing your Name and Organization your contact card in Address Book.
If that doesn't work, open System Preferences > Users & Groups > Right click on your user (System Preferences must already be unlocked) > Advanced Options... > Change the name in the Full Name text box.
To change the organization name in Xcode click on the project file so it is selected (left sidebar of Xcode in the Project navigator) > In the File Inspector (right sidebar of Xcode) change the Organization text box.
This blog post has some good steps for modifying file templates in Xcode 4.3:
http://error-success.piku.org.uk/2012/04/27/how-to-make-xcode-4-3-2-templates/
The /Developer folder no longer exists, so you copy the templates from within the Xcode.app bundle located in /Applications:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/
And place your modified copy here, as before:
~/Library/Developer/Xcode/Templates/File\ Templates/
UPDATE: I decided to write a script that would extract the built in Xcode templates and replace the headers. Source and instructions can be found at the following url:
https://github.com/royclarkson/xcode-templates
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates
any update of your SDK will wipe changes here so keep your template backed up somewhere else
Don't edit anything in /Developer as Apple can overwrite this at any time.
The following works for Xcode 4, 5 and 6 except later source differs and is under /Applications
Instead copy the templates that you want to change from /Applications/Xcode<version>.app/Contents/Developer/Library/Xcode/Templates to ~/Library/Developer/Xcode/Templates/File Templates and then edit the files keeping the same directory structure but edit the directory name that is the template to not show up a a duplicate in Xcode.
e.g for a new category of C/C+ files in Xcode 5 copy /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/C and C++ to ~/Library/Developer/Xcode/Templates/File Templates/GPL C and C++
this process is copied from Red Glasses's blog
For Xcode 4 the source path is or for Xcode 4 /Developer/Library/Xcode/Templates/File Templates
– Press ⌘ 1 to display the File Navigator.
– Click on the name of your project at the top of the File Navigator.
– Press ⌘⌥⇧ ⏎ (that's Command Option Shift Return) to view the Version Editor.
– Make sure that the Comparison View is shown(View > Version Editor > Show Comparison View).
This lets you see the raw text of your project's project.pbxproj file.
– Press ⌘ f to search the project.pbxproj file, paste in ORGANIZATIONNAME and press Return.
This is where the name of the organization that follows the copyright text is defined.
Or open Xcode's plist at
~/Library/Preferences/com.apple.dt.Xcode.plist
And change the organizationName key's value.
Or select the project from the Navigator pane and display the File Inspector with ⌘⌥ 1.
Look at the Organization value under Project Document. Change the value there.
In Xcode 12.4
Using Xcode, create a plist file named IDETemplateMacros.
Save it to the Desktop initially while you configure it.
If you cannot see the file in the Project Navigator then from the Xcode menu, select View > Navigators > Project
Right click on the filename and select Open as > Source Code
The following is a template that works nicely for me so chances are it will for you too.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string>
//
// ___FILENAME___
// ___PACKAGENAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___
// Copyright © ___YEAR___ ___FULLUSERNAME___. All rights reserved.
//
</string>
</dict>
</plist>
Copy and paste the above overwriting the existing contents.
Save the file and close it.
In Finder navigate to the following folder:
~/Library/Developer/Xcode/UserdData/
Drag the file from your Desktop to this Folder and then test using Xcode to create a new project.
It's very simple:
Open up terminal
In one line, write the following:
defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions -dict ORGANIZATIONNAME "Blah, Inc"
You don't have to worry about changing directories beforehand or anything else. It works instantly.
Change the details in your Address Book - add a company name. It will pick it up from there.
Try modifying this file:
/Developer/Library/Xcode/File\ Templates/C\ and\ C++/Header\ File.pbfiletemplate/header.h
Works with Xcode 14
Say you want to modify (or get rid of) the XCode Header comment.
First open XCode, Use File > New File... (⌘N) and choose Property List from the file templates.
Name it file IDETemplateMacros.plist
On the navigator, select the file as right-click Open as source code. Xcode will show us the property file as text. Property files are really just XML files.
Copy paste the following content:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string>Created for ___PROJECTNAME___ in ___YEAR___
// Using Swift ___DEFAULTTOOLCHAINSWIFTVERSION___</string>
</dict>
</plist>
On the root dict we have added an entry with key FILEHEADER and a two-lines string as a value:
Created for ___PROJECTNAME___ in ___YEAR___
// Using Swift ___DEFAULTTOOLCHAINSWIFTVERSION___
Save the file IDETemplateMacros.plist on the folder:
~/Library/Developer/Xcode/UserData/
That's it, now when creating a new project called MyProject, the header will be:
//Created for MyProject in 2022
// Using Swift 5.0
Note1. There is a list of macros on https://help.apple.com/xcode/mac/9.0/index.html?localePath=en.lproj#/dev7fe737ce0
Note 2. As an example you can write:
Created ___DATE___
// ___COPYRIGHT___
Note that there is a leading space but you do not include the // for the comment on the first line.
Note 3. For a more list of options see:
https://useyourloaf.com/blog/changing-xcode-header-comment/
In Xcode 4.2, they're here:
/Developer/Library/Xcode/Templates/File Templates
I just changed the template of a SwiftUI file, you have to open Xcode's Contents and look for the template files you want to change.
To change the SwiftUI template the path is this:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/MultiPlatform/User\ Interface/SwiftUI\ View.xctemplate
You nedd open with sudo
For AppCode users:
Go to preferences (CMD + ,)
Editor-File and Code Templates
Change Scheme to Project
Modify Files and/or Includes as you need.
add to git .idea/fileTemplates if needed
You can override the text macros globally, or for an individual workspace or project. You can also decide to keep the macros for a single user or share it with all users.
The full list of locations that Xcode searches, in order of priority:
Project - single user
<ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/
Project - shared by all users
<ProjectName>.xcodeproj/xcshareddata/
Workspace - single user
<WorkspaceName>.xcworkspace/xcuserdata/[username].xcuserdatad/
Workspace - shared by all users
<WorkspaceName>.xcworkspace/xcshareddata/
Globally for Xcode
~/Library/Developer/Xcode/UserData/
I don't remember what was the default template but you can make a template in any way you like using textMacros:
// ___FILENAME___
// ___PACKAGENAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// ___COPYRIGHT___
//
There are some other textMacros if you like more customization, but these are enough for making something like the default one.
You can create the file yourself if no files found at the path