appsquickly / xcodeeditor Goto Github PK
View Code? Open in Web Editor NEWAn API for manipulating Xcode project files.
License: Apache License 2.0
An API for manipulating Xcode project files.
License: Apache License 2.0
The scheme 'Tests' has nothing configured to build for Running and has no executable specified to Run.
Good repo, I was trying to remove/add some plist files to existing targets, I tried removeResourceWithKey and removeMemberWithKey but didn't seem work, any idea how to achieve that?
XcodeEditor/XcodeEditorTests/Resources/ESA.Sales.Foobar.xib: iOS xibs do not support target device type "mac".
This error happens when you build the project in Xcode 7. As a workaround I moved all these Resources for test to the test target and make the framework able to be built. Yet tests are not able to run. Have to find out a way of putting xib files into a mac bundle.
Is this is possible to add source to group with specific path ?
When I'm adding to 3000th files, application has been crashed.
malloc: *** mach_vm_map(size=2097152) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Do you have any idea to prevent this memory issue?
i create fiolder and files ,but i can't add it to my project.can u give some demo ?
Please share build scheme in latest tag (1.6.4)
When trying to compile this, I'm getting a linker error because of the way the XCProjectNotFoundException global is defined in the header file.
I tried to fix this in my branch by moving that global to XCProject.m, but I might be overlooking something.
Or should I just create an PR?
It would make it a lot easier to understand transformations and verify they're making the intended changes.
I need to manipulate the code signing parameters of the xcodeproj file. In the one release configuration that I get the one "CODE_SIGN_IDENTITY[sdk=iphoneos*]" but I need to edit the following parameters:
I can't seem to find a way to get to these key/values in side the XCProjectBuildConfig class. Any ideas on how to accomplish this?
I updated xcode to xcode7, happened this
static const NSString* SDK_PATH = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk";
XCFrameworkDefinition* frameworkDefinition = [[XCFrameworkDefinition alloc] initWithFilePath:[XCFrameworkPath libzDylibPath] copyToDestination:NO];
[frameworksGroup addFramework:frameworkDefinition toTargets:[project targets]];
here is ok~ but when i build the project, failed for this
Hello,
I have a project which uses XcodeEditor for a code generation target that produces a static library. I am interested in migrating to using a more modern dynamic framework. I have it mostly working but the last hurdle is adding the headers to the target.
Is there currently a way to add a file (in my case a generated .h file, which is not under source control) to a dynamic framework target's Build Phases > Headers? I am able to add my .m files to Compile Sources using addMember:
, but there does not seem to be a way to actually add the Headers (and specify their scope, i.e. Public/Private/Project).
Thank you,
-keller
Because this class's naming conflicts with Xcode's internal XCBuildConfiguration
you get scary warnings when using plugins that rely on XcodeEditor. The warnings look like this:
objc[30712]: Class XCBuildConfiguration is implemented in both /Applications/Xcode6.1.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Versions/A/DevToolsCore and /Users/seandawson/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Auto-Importer.xcplugin/Contents/MacOS/Auto-Importer. One of the two will be used. Which one is undefined.
Some related issues:
markohlebar/Peckham#27
FormulaMonks/Auto-Importer-for-Xcode#10
Is there a way to change a project's Compile Sources under Build Phases? For example, adding and/or removing files?
Hi,
Thanks so much for developing this. It was exactly what I needed.
I noticed one issue, though.
CocoaPods now uses a emoji in various build phase names it adds automatically. These ordinarily are just strings with a UTF8-Code in them. You could just remove those Emoji (see https://gist.github.com/cihancimen/4146056 on how to detect them). Right now it just turns these Emoji in some gibberish.
Furthermore, I needed some functionality that is not present in the current CocoaPods release. Any idea when the next release will be?
For example:
Best regards,
Edward
I was trying to automate the removal of a bunch of source files from a specific target in my project.
I couldn't find this documented anywhere or any mention in issues, but it looks like removeMemberWithKey
and removeResourceWithKey
are basically the same thing, except the former expects the object key and the later expects the file ref key. In both cases, the method will remove the file from all build phases, which I find confusing based on the names. Based on the name, I thought removeResourceWithKey
would remove a member from the "Copy Bundle Resources" build phase, and removeMemberWithKey
remove a source file form the "Compile Sources" build phase.
let project = XCProject(filePath: "MyProject")
let target = project.targetWithName("MyTarget")
for m in target.members() where m.name.hasSuffix("-Foo.swift") {
target.removeMemberWithKey(m.key) // Does not work, the keys in the "files" object of the build phase are not the same keys you get from target.members(), which are file ref keys.
target.removeResourceWithKey(m.key) // Works, it looks like this method will find the "files" key corresponding to the file ref key
}
project.save()
Can anyone clarify the intended difference between these methods and document them in the readme?
Perhaps a better API would be to have a removeMember:
method that takes an XCSourceFile
instead of a key, since the key seems to be an implementation detail that shouldn't be leaked to this level.
Also, nullability annotations would be greatly appreciated, because right now everything is imported to Swift as implicitly unwrapped optionals.
It seems like xcdatamodel is not supported. fullPath is nil:
Project file: key=210833801A3AB97B002BF7B8, name=Yelp v2.xcdatamodel, fullPath=(null)
Is it, or can it be, possible to change target specific settings, like the Info.plist location of the target and let's say the Preprocessor Macros?
I need to automatically add targets (duplicate existent ones) and edit the location of the duplicated target's plist file and the corresponding preprocessor macros.
Thanks!
Can you use this to add a run script build phase? It doesn't seem like it.
Hi, I'm trying to change the paths on a source files in projects. I see that path is readonly. Is there a way to work around this already in the library? I tried looking at XCGroups and creating a new XCSourceFile with the new path, and then removing the old one, but I see that XCGroup has no method to remove members.
Is there a way to accomplish this task with this library?
I'm building a menu plugin and found this repo -
while it may be clear what the project name is in 99% of use cases - consider that there are times when we want to know / dig up these values.
Consider cherry picking a couple of classes from this code - CrasheyePluginXcode
https://github.com/GangWang/Crasheye/tree/d6c1b3abedafac040d62d85265e971bd5563cc40/CrasheyePluginXcode/class
Eg. for the first sample -
you should be able to call
MTProject *mainProject = [MTProject projectForKeyWindow];
NSLog(@"mainProject:%@",mainProject.directoryPath);
NSLog(@"projectName:%@",mainProject.projectName);
NSLog(@"infoDictionary:%@",mainProject.infoDictionary);
NSLog(@"workspacePath:%@",mainProject.workspacePath);
NSLog(@"projectFile:%@",mainProject.projectFile);
NSLog(@"projectFileDir:%@",mainProject.projectFileDir);
XCProject* project = [[XCProject alloc] initWithFilePath:mainProject.projectName];
@interface MTProject : NSObject
@property (nonatomic, copy, readonly) NSString* directoryPath;
@property (nonatomic, copy, readonly) NSString* projectName;
@property (nonatomic, copy, readonly) NSDictionary* infoDictionary;
@property (nonatomic, readonly) NSString* workspacePath;
@property (nonatomic, copy, readonly) NSString* projectFile;
@property (nonatomic, copy, readonly) NSString* projectFileDir;
+ (instancetype)projectForKeyWindow;
- (id)initWithName:(NSString*)name path:(NSString*)path;
- (BOOL)containsFileWithName:(NSString*)fileName;
@end
Say I add a group with path named @"Phone" to the root group. Then in that group, I add a group with path named @"@2x".
Then if I add a group to the root group called @"Pad", and in that group I add a group called @"@2x", it will have the same key as the first @"@2x" group, even though it is a different group.
In XCGroup's addGroupWithPath: method, you are generating the key just based on the passed in variable path, which is not the full path of the group, but the last path component, which could be the same as the last path component of other groups.
my project AAA.xcodeproj contains bbb.framework which is added to ccc.target.
and i want to remove bbb.framework
how can i make it
[group addFrameworkWithFilePath:xxx copyToGroupFolder:YES]
Steps to reproduce:
Expected result:
Folder and files inside the folder should be added to the project.
Actual result:
Only the folder gets added to the project. Files do not get added to the project.
I'm getting a "Bad access" exception from the following method:
+ (NSString*)xce_stringFromMemberType:(XcodeMemberType)nodeType {
NSDictionary* nodeTypesToString = DictionaryWithProjectNodeTypesAsStrings();
return [[nodeTypesToString allKeysForObject:@(nodeType)] firstObject]; // <-- Crashes here
}
It seems that the nodeTypesToString
dictionary is nil. I've tried altering the code in DictionaryWithProjectNodeTypesAsStrings()
to make sure it doesn't return nil (although it looks like it shouldn't anyway) but to no avail.
This is the result of calling addSubProject
after an Xcode project file has been saved (the project saving code already existed before I discovered this project). The saving is done on a separate thread; I wonder if that might have something to do with it? I've tried delaying the call to addSubProject
but that didn't seem to help either.
Any clues as to why this might be happening?
I'm using cocoapods in a MacOSX command line app with this Podfile:
# Uncomment this line to define a global platform for your project
platform :osx, '10.8'
use_frameworks!
target 'EventwoCreateApp' do
pod 'GBCli'
pod 'XcodeEditor'
end
When i try to build the project, it fails building because of including of non-modular header inside framework module
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/pedro/Library/Developer/Xcode/DerivedData/EventwoCreateApp-hbqavnbhqvzppravjjsvpcdoxdwl/Build/Products/Debug/Pods-EventwoCreateApp/XcodeEditor.framework/Headers/Pods-EventwoCreateApp-XcodeEditor-umbrella.h"
^
/Users/pedro/Library/Developer/Xcode/DerivedData/EventwoCreateApp-hbqavnbhqvzppravjjsvpcdoxdwl/Build/Products/Debug/Pods-EventwoCreateApp/XcodeEditor.framework/Headers/Pods-EventwoCreateApp-XcodeEditor-umbrella.h:20:9: note: in file included from /Users/pedro/Library/Developer/Xcode/DerivedData/EventwoCreateApp-hbqavnbhqvzppravjjsvpcdoxdwl/Build/Products/Debug/Pods-EventwoCreateApp/XcodeEditor.framework/Headers/Pods-EventwoCreateApp-XcodeEditor-umbrella.h:20:
#import "XCKeyBuilder.h"
^
/Users/pedro/Library/Developer/Xcode/DerivedData/EventwoCreateApp-hbqavnbhqvzppravjjsvpcdoxdwl/Build/Products/Debug/Pods-EventwoCreateApp/XcodeEditor.framework/Headers/XCKeyBuilder.h:14:9: error: include of non-modular header inside framework module 'XcodeEditor.XCKeyBuilder'
#import <CommonCrypto/CommonDigest.h>
^
/Users/pedro/Downloads/EventwoCreateApp/EventwoCreateApp/AppCreator.swift:10:8: error: could not build Objective-C module 'XcodeEditor'
import XcodeEditor
I've tried different solutions, like customizing the modulemap file or adding the framework to the target, but the error is always the same.
¿is there some solution or is it simply a swift limitation?, thanks
I added this frameowrk to a OS X cmd line tool project, but I get this when running my app. It seems as the framework is not included in my binary:
dyld: Library not loaded: @executable_path/../Frameworks/XcodeEditor.framework/Versions/A/XcodeEditor
Referenced from: /Users/jonny/Library/Developer/Xcode/DerivedData/fixunityoutput-gaczjmlpbieybbcwzokbxsrzfzwj/Build/Products/Debug/fixunityoutput
Reason: image not found
Get an already existing group with groupWithPathFromRoot:.
You can add groups to this via addGroupWithPath:.
But if you try to add a sub group to the group returned from addGroupWithPath:, it will not be added. This is because the instance variable _children is nil when trying to add children.
Change the code in XCGroup's initWithProject: key:alias:path:children method to have
_children = [children mutableCopy];
if(!_children)
{
_children = [[NSMutableArray alloc] init];
}
Surprisingly, this seems absent... sadly. This would fill a nice niche - as I am unaware of any tool - that can create Xcode projects "from thin air".
http://stackoverflow.com/questions/14118262/create-new-xcode-project-from-command-line
http://learnaholic.me/2012/11/28/xcode-4-dot-5-workspace-project-and-target-from-scratch/
Hi.
I happen to use XcodeEditor, but not directly. I am using Calabash for iOS for automation tests, and calabash is using XcodeEditor. They have calabash-ios setup
command, which does the following
When new target is created, a new scheme appears in the Xcode as well, in my case it's "MyTarget-cal" scheme.
So, the problem is that newly created scheme is not shared.
If I go to "Manage Schemes" Xcode menu, the "MyTarget-cal" scheme will not have checkmark in "Shared" column, even if the original "MyTarget" scheme had it.
Why that matters?
It is not a problem when building from Xcode and when using xcodebuild
from command line on dev machine.
But that becomes a real problem when trying to build from CI environment, such as Bamboo or Jenkins.
It's a known issue, Bamboo and Jenkins run their shell scripts in a specific environment, under some special user. So when Bamboo runs xcodebuild -project MyProject.xcodeproj -scheme MyTarget-cal
the xcodebuild
will complain that the project does not have "MyTarget-cal" scheme. To put it another way, Bamboo and Jenkins can't "see" scheme unless it's shared. That's why having a shared scheme is important for CI builds.
Most of Xcode projects can be build using only configuration, target and sdk options, but if it's an Xcode workspace with lot's of libraries, sub-projects and custom frameworks, building using -scheme
option is the only way to build it from command line properly.
I've done some research around the shared schemes.
If the scheme is shared in Xcode, then it will appear in MyProject.xcodeproj/xcsharedata/xcschemes
, for each scheme there will be a .xcscheme
file, like "MyTarget.xcscheme", "MyTarget-cal.xcscheme".
But that folder and its contents are created only when the project is opened in Xcode, looks like Xcode generates those folders and files.
When the whole thing is done on CI box, none of those folders and files will be created.
The only place I can find mention of "MyTarget-cal" target and scheme is in "MyProject.xcodeproj/project.pbxproj" file.
I assume there's a way to extract information about "MyTarget-cal" scheme from pbxproj file and create "MyTarget-cal.xcscheme" and put it under "xcshareddata/xcschemes", at least Xcode does that somehow.
I'm trying to add -ObjC to Other Linker Flags and $(SRCROOT) to Header Search Paths but it isn't saving to configuration. I can see that it is adding the parameter to the _buildSettings but it doesn't seem to be saving. Here is my code:
XCProject* project = [[XCProject alloc] initWithFilePath:[[[PersistantManager sharedInstance] projectPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.xcodeproj", [[PersistantManager sharedInstance] projectName]]]];
for (XCTarget* target in [project targets])
{
for (NSString* configName in [target configurations])
{
XCBuildConfiguration* configuration = [target configurationWithName:configName];
NSMutableArray* headerPaths = [[NSMutableArray alloc] init];
[headerPaths addObject:@"$(SRCROOT)"];
[configuration addOrReplaceBuildSetting:headerPaths forKey:@"HEADER_SEARCH_PATHS"];
NSMutableArray* linkerFlags = [[NSMutableArray alloc] init];
[linkerFlags addObject:@"-ObjC"];
[configuration addOrReplaceBuildSetting:linkerFlags forKey:@"OTHER_LDFLAGS"];
}
}
[project save];
Hi, I have been trying add Images.xcassets of my project. But I can not found solution. Which method I use it. Please help
Thanks...
Does XCodeEditor support sorting targets in alphabetical order? I could not figure out a way to do it.
I have an Xcode project, for which current library will return (null) for root group.
Xcode project successfully parsing
it has next structure:
Groups of project,
for (xcode_Group * group in [_xcodeProject groups]) { NSLog(@"Groupd : %@ : %@ : %@ : %@", [group pathRelativeToParent], [group alias], [group key], [[group parentGroup] key]); }
Group (null) : Products : 32005DD2DD4BE82AFAA88C83 : (null)
Group (null) : Products : 320CC833B8AF0ACFD35E6223 : (null)
Group (null) : Products : 3201088596B4756681693703 : (null)
Group (null) : Products : 44B36DE71303E461005FD12F : (null)
Group (null) : core : 44B36B581303DF6D005FD12F : 44B35F971303DE12005FD12F
Group (null) : Products : 320A737074758E53BA54BE93 : (null)
Group (null) : Bundles : 29B97317FDCFA39411CA2CEA : 29B97314FDCFA39411CA2CEA
Group (null) : Resources : 4459EE0F13040CD200AD8ACE : 29B97314FDCFA39411CA2CEA
Group (null) : Products : 320A2827FEC940B25BC42C63 : (null)
Group (null) : Products : 320D7DCCE32703ACAB9A45E3 : (null)
Group (null) : Products : 19C28FACFE9D520D11CA2CBB : 29B97314FDCFA39411CA2CEA
Group (null) : Products : 44B36DC31303E3DB005FD12F : (null)
Group Libs/core/Libs/iphone-news-library/Libs/GData : GData : 44B36F921303E56C005FD12F : 44B36C041303E126005FD12F
Group Libs : (null) : 44B35F971303DE12005FD12F : 29B97314FDCFA39411CA2CEA
Group Config : (null) : 442E0403130E93A100A65FDB : 29B97314FDCFA39411CA2CEA
Group Classes : (null) : 080E96DDFE201D6D7F000001 : 29B97314FDCFA39411CA2CEA
Group (null) : CustomTemplate : 29B97314FDCFA39411CA2CEA : (null)
Group (null) : Products : 320F2C48872C2E2C4DF86203 : (null)
Group Libs/core/Libs/Flurry : Flurry : 44B36DD51303E433005FD12F : 44B36C041303E126005FD12F
Group (null) : Core : E4493B5E155D358B007682BE : 29B97314FDCFA39411CA2CEA
Group (null) : Products : 44B36E091303E4A7005FD12F : (null)
Group (null) : Frameworks : 44B36C041303E126005FD12F : 29B97314FDCFA39411CA2CEA
Group (null) : Products : 320A5A189C235877202780D3 : (null)
Group (null) : Other Sources : 29B97315FDCFA39411CA2CEA : 29B97314FDCFA39411CA2CEA
It seems, that root group can have Alias (CustomTemplate in this example), and one or both items should be fixed:
- (BOOL) isRootGroup {
return [self pathRelativeToParent] == nil && [self displayName] == nil;
}
- (NSString*) displayName {
if (_pathRelativeToParent == nil) {
return _alias;
}
else {
return [_pathRelativeToParent lastPathComponent];
}
}
Sorry, cannot provide a .xcodeproj file
Hello guys, I'd like to ask how you can create a new target and a new build scheme - but not by duplicating it, but by creating the new target from nothing.
There is dedicated constructor for that, but it does not seem to be supported. I've added few methods to add it, but unfortunately simply adding it to _targets
and _configurations
does not work. Does anyone has a solution for this, or at least what steps need to be taken in order to support this?
Thank you
When building with Carthage I get following message:
*** Skipped building XcodeEditor due to the error:
Dependency "XcodeEditor" has no shared framework schemes
If you believe this to be an error, please file an issue with the maintainers at https://github.com/appsquickly/XcodeEditor/issues/new
I need add storyboard file to Target. Any suggestion?
If anyone ever attempting to use this framework in a swift project, NSException can not be directly catched. They have to wrap the try-catch-finally stuff in objective-c code and pass blocks in as parameters from swift, or their programs might be prone to crashing. Ever considered adopting the more usual NSError pattern, which is catchable in swift?
I check the code, I found it is seem lost to read the xcconfig file in project and target base configuration! Please check it.
I need an api to set the base configuration file, but I don't found it. Can you add the api to set the xcconfig?
Create a group with addGroupWithPath:.
Add a XCClassDefinition to that group, and when you save the project, it will crash saying:
'Error writing file at filePath: /path/to/file/MyNewClass.m, error: Error Domain=NSCocoaErrorDomain Code=4 "The folder “MyNewClass.m” doesn’t exist."
May be because in the commitFileOperations method, the file writes occur before the directories are created:
[self performFileWrites];
[self performCopyFrameworks];
[self performFileDeletions];
[self performCreateDirectories];
Maybe put performCreateDirectories first?
It would be awesome if there was an easy way to convert Xcode projects to make files.
There currently isn't a good way to get the compiler arguments and build commands for projects that primarily store build preferences in Xcode projects.
There was a tool for gnu step that provided similar functionality pbxbuild
but it is now deprecated. Is a feature like this in scope of this project?
Anyone figured out a way to add a framework to a target and add it to the embed binaries build phase ?
I've noticed that recent Kiwi library correctly shows test names
I've tried to correctly compile it as static library to add to the project, but failed :(
Could you, please, update and re-add the most recent Kiwi library, please?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.