I know that this is not a new question, but I have tried many solution like edit Xcode project file manually or recreating new scheme for target after renaming it.
Can somebody help me with this question how copy target in right way and then rename it.
Right now I just rename scheme and it is displayed as is. But when Xcode is running app, under progress indicator it says: Running ProjectName-copy. But I have renamed target but seems product names or some build settings still has "...-copy" in the name.
Duplicate a target.
Double click the copy of target and change its name to whatever you want.
'New target -> Build Settings -> Packaging -> Product Name', change it to the name you want.
Product (Menu item) > Schemes > Manage Schemes, then click the '+' button, select the new target and click 'OK' button.
All done.
PS:
After Duplicating the target, Xcode make a new Info.plist file named 'xxx copy-Info.plist' in the root path of project. If you want to change its name and path, after doing this, you should go to 'New target -> Build Settings -> Packaging -> Info.plist file' and change the value to the path of new file.
Press on the target name in xcode ( in the same place where you want to select the sim/device type) and select "Manage Schemes...". Highlight the scheme with the copy inside name and press enter on keyboard. You can rename it there.
To copy a target, click on your project, and go to the project inspector tab that looks like this:
Project:
SomeName
Targets:
SomeName
right click on a target, and select duplicate, then double-click slowly on the new target, or select the new target and hit enter, and just put the new name in!
To change running targets, to the top left of your xcode you will see this:
(start button) (stop Button) (target name and device)
[|>] [[]] [/\ TargetName > TargetDevice]
click the target name, next to the little compass (mathematical compass, not navigational) and select your desired target from the dropdown.
Hope I helped, Matroskin.
Related
In an Xcode project, files in the left Project Navigator can be organized into virtual (and actual) folders (Groups).
In Playground, while a new folder can be added, it does not seems to be possible to do the same.
Can it be done in Playground?
And if you can't, what would be similar?
You can create an Xcode Project with a built in Playground, information found here
In Xcode, File -> New -> Project… and then iOS -> Application -> Single View Application
File -> Save as Workspace… Save it as SuperProject.xcworkspace in the same directory as SuperProject.xcproject file.
File -> New -> File… and then iOS -> Source -> Playground. Call it SuperProject.playground, use the same directory as SuperProject.xcproject, and select the top-level “SuperPlayground” under Group (this is not the default option).
File -> New -> Target… and then iOS -> Framework & Library -> Cocoa Touch Framework. Name it SuperPlaygroundiOS and uncheck Unit Tests.
Optional: Control-click on ViewController.swift in the Project Navigator1 and click New File… and then iOS -> Source -> Swift File. Call it SuperClass.swift and make sure SuperProject and SuperProjectiOS are checked under Targets. Replace the contents of this file with this:
import Foundation
class SuperClass{
func greetMe() -> String{
return "Hello"
}
}
Select the framework target (SuperPlaygroundiOS) in the File Inspector for any other files you want to access from your new playground.
Select SuperPlaygroundiOS > iPhone 6S Plus beside the Play/Stop buttons, then Product -> Build.
In SuperProject.playground, type the following at the top of the file:
#testable import SuperPlaygroundiOS
If you did step #5, you can now type this at the bottom of the file too.
SuperClass.greetMe()
Is there any way to display the CFBundleShortVersionString as a UILabel text in my LaunchStoryboard without entering it by hand every time it increments? I know how to do it in code, but it is not possible to run code while the LaunchStoryboard is shown.
Is it possible through Xcode variables?
As we all know, you can't put code in a launch screen. And unfortunately there isn't a built-in way to use a variable for a label's text in the launch screen (similar to how you can preprocess Info.plist with values in a header file).
The only option available to achieve your goal would be to write your own script that updates the LaunchScreen.storyboard file and add that script as a custom Build Phase for your target.
To make this easier, I would setup your target to use a preprocessor file for Info.plist. Once that is done and working, you now have a separate and simple header file you can interrogate in your script to process the LaunchScreen.storyboard file.
Here's a complete solution:
Create a file named Info.h and add it to the root of your project.
Add the following line:
#define APP_VERSION 2.6 // Update this version as needed
Now select your project's target in Xcode and go to the General tab. Change the Version value from whatever number you have there to APP_VERSION.
Now select the Build Settings tab. Search on Info. Under the Packaging section, set the Preprocess Info.plist File to Yes. Also set the Info.plist preprocessing Prefix File to Info.h.
Now when you do a build, the CFBundleShortVersionString value in Info.plist will be set to the value in the Info.h file.
To get the label in the launch screen file updated to match, do the following:
Select your launch screen storyboard and then select the label that will contain the version number. Show the Identity Inspector pane. Enter APP_VERSION into the Label attribute. If you look at the storyboard file now, the XML for the label will now show a userLabel attribute with the value of APP_VERSION.
Go back to the project target and select the Build Phases tab. Click the + icon and choose to add a New Run Script Phase. Rename the new phase to something useful like "Update Launch Version". Then drag the new phase to before the existing "Copy Bundle Resources" phase.
Now open the new "Update Launch Version" phase. Enter /bin/bash in the Shell field. Copy and paste the following code into the phase:
VERSION=`cat Info.h | grep APP_VERSION | cut -f3 -d' '`
sed -e "/userLabel=\"APP_VERSION\"/s/text=\"[^\"]*\"/text=\"$VERSION\"/" Storyboard.storyboard > tmp.storyboard
Now do a clean build. This is a test at this point. Have a look at tmp.storyboard and make sure it looks correct and the label for the app version is showing the proper version.
Once that is working, update the above code to:
VERSION=`cat Info.h | grep APP_VERSION | cut -f3 -d' '`
sed -i bak -e "/userLabel=\"APP_VERSION\"/s/text=\"[^\"]*\"/text=\"$VERSION\"/" Storyboard.storyboard
This final version actually updates the launch screen storyboard file. The previous version was a test to make sure everything else was working without risk to trashing your storyboard.
I figured out the script to update the Version & Build label on LaunchScreen.storyboard based on the first answer without using any extra files. Unfortunately, Clemens Brockschmidt's solution doesn't work due to some Syntax errors and incorrect paths.
Make sure to name your label to "APP_VERSION" in Identity Inspector pane -> Document -> Label.
Also create your script before "Copy Bundle Resources" phase.
UPDATE: My older answer didn't work in the newest Xcode environment. I've fixed the current issues and refactored the script.
And here's the final working script with shell: /bin/sh in XCode 11 (Swift 5):
# ON/OFF Script Toggle (script ON with #, script OFF without #)
#exit 0
# Increment Build Number Bool (Increment ON with true, increment OFF with false)
shouldIncrement=false
# App vesion / Build version constants
sourceFilePath="$PROJECT_DIR/$PROJECT_NAME/Base.lproj/LaunchScreen.storyboard"
versionNumber="$MARKETING_VERSION"
buildNumber="$CURRENT_PROJECT_VERSION"
# Increment build number
if [ "$shouldIncrement" = true ]; then
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
fi
# Output version & build numbers into a label on LaunchScreen.storyboard
sed -i .bak -e "/userLabel=\"APP_VERSION\"/s/text=\"[^\"]*\"/text=\"$versionNumber($buildNumber)\"/" "$sourceFilePath"
As a BONUS I've included a build number incrementer and ON/OFF script toggle to disable your incrementer when you build your project a lot. Let me know if you have any issues or if this works for you.
Edit
There is no way to make the launch screen dynamic. Doesn't work good
with localizations too etc
A alternative is given below
Previous Answer
You should make your inital VC similar to the LaunchScreen.xib and in that make a label.
Now in the ViewController you can access the info plist through NSBundle method and set its value. This would make the transition from Launch screen to first VC smooth and look natural with version code animating in or something if you want
let appVersion = NSBundle.mainBundle().infoDictionary["CFBundleVersion"];
myLabel.text = "\(appVersion)"
I have beed using Advance new file package in Sublime Text 2 and when I press shortcut for creating new file is in my main directory C\users\%name\.
Is it possible (or with another package) to set path to be in folder that I'm currently at.
Example, if I'm at
C:\Users\%user\Desktop\Notebook\Ruby programs\Ruby\test.rb
to set the path to
C:\Users\Bane\Desktop\Notebook\Ruby programs\Ruby\
Open Preferences -> Package Settings -> AdvancedNewFile -> Settings - User and add the following to the file.
{"default_root": "current"}
You can see more about settings on the GitHub page.
After adding a CoreData Model to my existing project using
File > New > File... > Core Data > Data Model
I am unable to edit the model. The project now includes a .xcdatamodeld package reference, but clicking on it in Project Navigator has the same effect as clicking on a folder or group, the current editor does not change. Also right clicking the reference and selecting "Open As >" lists no potential editors. Furthermore, opening the file inspector panel only lists settings for "Identity" "Target Membership" and "Text Settings", it does not list settings for "Core Data Model" or "Versioned Core Data Model"
Not that this should have any effect on XCodes ability to recognize a file type, but I have also referenced CoreData.framework in build phases, and included the necessary Core Data properties in the AppDelegate.
What's strange is I have opened the .xcdatamodeld package in Finder to expose the internal .xcdatamodel (note no trailing 'd'). Double clicking that file will open XCode with the Core Data Model Editor as expected.
Even stranger still is, I created a new projected and clicked the "Use Core Data" check box. Doing so allowed me edit the data model by selecting the .xcdatamodeld reference in the Project Navigator. Hence my machine and XCode are capable and configured to edit CoreData files.
It's as if XCode is unable to use Core Data unless the original project was created with the "Use Core Data" check box.
Has anyone experienced this issue, were you able to fix it, and how?
Thanks!
Turns out I was attempting to add the Data Model to a group which referenced a specific folder in which to store it's children. That folder however did not exist. This cause XCode to place the data model in the project root, but at the same time reference it as residing 2 directories above the project root. What's even odder is that XCode didn't list the file as missing by displaying it in red. Either way XCode ignored the file when clicked in Project Navigator, because it didn't really exist where it thought it did. Moral of the story is: check your file paths and configured group paths.
I ran into this issue today, and the problem was that my .xcdatamodel file was packaged inside itself (strange, I know). Here's how I fixed it:
I found my File.xcdatamodel file in Finder.
Right-clicked and selected Show Package Contents.
Inside was another copy of File.xcdatamodel. I copied that to my Desktop.
I then dragged that file into Xcode and it opened.
What a relief. :) I hope this helps someone else.
Our real problem was that Xcode couldn't open/validate the data model when creating a new version.
Meaning: having first one .xcdatamodel and then Editor > Add Model Version... > MyProject 2 (as .xcdatamodel).
After what, the MyPoject.xcdatamodeld was created but couldn't be opened.
After hours investigating we figured out that the .xcurrentversion file and the XCVersionGroup in the project file were missing or invalid.
One of the reason was that the xcdatamodeld version should be in the root folder.
Easy Fast Solution 1:
Create a new Model Version and:
Set the path to the root folder
Specify the Group to be the subdirectory where the previous version is.
The new .xcdatamodeld will now work on Xcode but can't be moved anywhere else than the root folder.
Complicated Solution 2:
To have a wroking .xcdatamodeld in a subfolder, hou have to modify manually the project file follwoing those steps:
PS: This is the most complicated and hacky answer I evcer wrote. I'm sorry :(
Create a new Model Version (even though it invalidates the data model) in the same directory of the previous version.
Make sure the new .xcdatamodeld file is specified in your target(s).
Open the Package Content in Finder and drag-and-drop all xcdatamodel versions to the project.
Open the project.pbxproj file in a text editor.
Search for the new files for all data models and copy their fileId.
Example:
75F3199D1B9D80D50030FF46 /* MyProject 2.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 75F319981B9D80D50030FF46 /* MyProject 2.xcdatamodel */; };
// fileId = 75F3199D1B9D80D50030FF46 /* The first id at the beginning of the line */
Move those lines from the PBXBuildFile section to the beginning of the PBXFileReference one and update them like this (reuse the fileId).
Example:
75F3199D1B9D80D50030FF46 /* MyProject 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MyProject 2.xcdatamodel"; sourceTree = "<group>"; };
Now search the file MyPoject.xcdatamodeld in the PBXBuildFile section and copy its fileRef.
Example:
75F319961B9D7FA50030FF46 /* MyProject.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 75F319931B9D7FA50030FF46 /* MyProject.xcdatamodeld */; };
// fileRef = 75F319931B9D7FA50030FF46
Finally, at the very end of the project.pbxproj file create the XCVersionGroup section and reuse the fileRef from the xcdatamodeld and all fileId.
Example (without the // comments):
/* Begin XCVersionGroup section */
75F319931B9D7FA50030FF46 /* MyProject.xcdatamodeld */ = { // fileRed
isa = XCVersionGroup;
children = (
75F3199D1B9D80D50030FF46 /* MyProject 2.xcdatamodel */, // fileId
75F319A11B9D80D50030FF46 /* MyProject.xcdatamodel */, // fileId
);
currentVersion = 75F3199D1B9D80D50030FF46 /* MyProject 2.xcdatamodel */; // fileId of the current version
name = MyProject.xcdatamodeld;
path = Path/To/MyProject.xcdatamodeld; // set the correct path
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = 7564EB681B4AB1560065394B /* Project object */;
} /* EOF */
You should now be able to open the xcdatamodeld file in Xcode now from the desired subfolder.
Now remove the extra references of the single xcdatamodel files from xcode (the ones created in the beginning).
Sorry for the long answer... but problem solved :D
This is still a problem in Xcode 8.
For me, the simple solution was to drag (inside the project file navigator pane - left hand side of Xcode) my .xcdatamodeld file from its (yellow) sub group folder up to the very top level under the App (the one with the blue icon).
After that, it opened up with the editor immediately.
I retested by dragging it back to the sub-group, and again it would not open in the editor, then back to top level and it opened correctly...
I have no idea why this is happening, but at least I can edit it again.
Hope this helps somebody.
Restarting Xcode usually takes care of this problem.
Here's how I solved the issue:
In Xcode file tree, deleted the .xcdatamodeld file.
When I opened the project folder, the file was there. (Xcode only removed the reference.)
I've dragged it back to Xcode file tree, checked "Copy items if needed". It didn't make a copy because understood that the file is already under the project folder.
Problem solved.
On first selection this behavior happens but selecting another class then back to the dataModel allows editing for me on a fresh project without CoreData then adding the coreData model to the project.
Just a thought, did you add an entity or are you not even able to access the datamodel view?
I solved it like this in Xcode:
Right click on your project (not your project folder, I mean that one with the blue Xcode Icon!), than select "New File" and choose the right folder to save the data model.
Note: Clicking "New File" on the project folder itself or on one of its subfolders did not work somehow..
i have two projects in a project group:
ProjectA
ProjectB
Whenever i open the ProjectGroup.bpg in Delphi, it always starts with the 2nd project as the active one:
ProjectA
ProjectB
And every time i have to flip it to the the "real" project:
ProjectA
ProjectB
How can i make ProjectA the default project that opens with the project group?
ProjectGroup.bpg
#------------------------------------------------------------------------------
VERSION = BWS.01
#------------------------------------------------------------------------------
!ifndef ROOT
ROOT = $(MAKEDIR)\..
!endif
#------------------------------------------------------------------------------
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
DCC = $(ROOT)\bin\dcc32.exe $**
BRCC = $(ROOT)\bin\brcc32.exe $**
#------------------------------------------------------------------------------
PROJECTS = ProjectA.exe ProjectB.exe
#------------------------------------------------------------------------------
default: $(PROJECTS)
#------------------------------------------------------------------------------
ProjectA.exe: ProjectA.dpr
$(DCC)
ProjectB.exe: childfolder\ProjectB.dpr
$(DCC)
See DUnit: How to run unit tests for the practical reason.
Far from ideal but the only way I know is like
in the Delphi IDE, right click your default project in the Project Manager and select Build Later.
or Switch the lines for Project A and Project B in the .bpg file.
You might have a stuck desktop settings file. Look for a .DSK file associated with your project group, and delete it.
In Delphi 7 (and I presume later also) you can select the 'active' project in the project group tree by double-clicking it. If you then do 'Save Project Group As' by right clicking the top of the project tree, the active project is saved with the group and will open at that when you next open the project group.
Place file ProjectGroup.dsk in project folder with text:
[ActiveProject]
ActiveProject=1
or set check to TRUE in Environment Options -> Preferences -> Autosave Options -> Project Desktop, this will create DSK files for projects and groups automatic!