Comments (12)
I think not currently, though it should be very simple to support.
from xcodeeditor.
I was edited in XCGroup
But fail in XCTarget addMember (invalid path)
Could you give me some help ?
- (void)addSourceFile:(XCSourceFileDefinition*)sourceFileDefinition withPath:(NSString*)targetPath
{
[self makeGroupMemberWithName:[sourceFileDefinition sourceFileName] contents:[sourceFileDefinition data]
type:[sourceFileDefinition type] fileOperationStyle:[sourceFileDefinition fileOperationStyle]
withPath:targetPath];
[[_project objects] setObject:[self asDictionary] forKey:_key];
}
- (void)makeGroupMemberWithName:(NSString*)name contents:(id)contents type:(XcodeSourceFileType)type
fileOperationStyle:(XcodeFileOperationStyle)fileOperationStyle
withPath:(NSString*)targetPath
{
NSString* filePath;
XCSourceFile* currentSourceFile = (XCSourceFile*) [self memberWithDisplayName:name];
if ((currentSourceFile) == nil)
{
NSDictionary* reference = [self makeFileReferenceWithPath:name
name:nil type:type];
NSString* fileKey = [[XCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@/%@", targetPath, name]] build];
[[_project objects] setObject:reference forKey:fileKey];
[self addMemberWithKey:fileKey];
}
filePath = targetPath;
BOOL writeFile = NO;
if (fileOperationStyle == FileOperationStyleOverwrite)
{
writeFile = YES;
[_fileOperationQueue fileWithName:name existsInProjectDirectory:filePath];
}
else if (fileOperationStyle == FileOperationStyleAcceptExisting &&
![_fileOperationQueue fileWithName:name existsInProjectDirectory:filePath])
{
writeFile = YES;
}
if (writeFile)
{
if ([contents isKindOfClass:[NSString class]])
{
[_fileOperationQueue queueTextFile:name inDirectory:filePath withContents:contents];
}
else
{
[_fileOperationQueue queueDataFile:name inDirectory:filePath withContents:contents];
}
}
}
from xcodeeditor.
There's a different flag for relative vs absolute file paths.
- Try creating an absolute file in Xcode. . open the project.pbxproj and take a look.
from xcodeeditor.
Ah, I did not want to add with absolute path. (sorry didn't mentioned that before)
I tried to add with relative path.
Anyways, Thank for your answer.
from xcodeeditor.
Did you try running all of the tests? There's a sample project that gets unpacked into /tmp
You can observe the updates there by opening that project in Xcode.
- Currently you can add a source- file by specifying the contents of the file.
- To use an existing file on the disk, and adding it into the project is not really supported, unless you put the file in the correct place.
- You could read the file from disk and set it as the argument to XcodeEditor.
from xcodeeditor.
Yes. I think it need support for
path = IZIZ/TIimaveView.m;
or
path = ../IZIZ/TIimaveView.m;
or
path = II/ZZ/TIimaveView.m;
instead of
path = TIimaveView.m;
in
FD88D16718ACA2EE00B74C6D /* TIimaveView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TIimaveView.m; path = IZIZ/TIimaveView.m; sourceTree = "<group>";
from xcodeeditor.
Its possible to add the source with a specific path, if you create groups as needed as you go. Will this work for you?
from xcodeeditor.
Sorry for late ACK
I'm using below with edited XCGroup file
NSString *projectName = @"RestInPeace";
NSString *workingRoot = @(getenv("WORKING_SRC_ROOT"));
unsigned long startPosition = workingRoot.length - projectName.length;
NSRange replacementRange = NSMakeRange(startPosition, projectName.length);
NSString *targetProjectFile = [workingRoot stringByReplacingCharactersInRange:replacementRange
withString:TARGET_PROJECT];
XCProject *project = [[XCProject alloc] initWithFilePath:targetProjectFile];
XCGroup *currentTargetGroup = [project groupWithPathFromRoot:targetGroup];
XCSourceFileDefinition *newSourceFile =
[[XCSourceFileDefinition alloc] initWithName:fileName text:content type:sourceType];
[newSourceFile setFileOperationType:XCFileOperationTypeOverwrite];
[currentTargetGroup addSourceFile:newSourceFile withPath:TARGET_NAME];
if (shouldAddToTarget) {
XCSourceFile *sourceFile = [project fileWithName:fileName];
XCTarget *targetObj = [project targetWithName:TARGET_NAME];
[targetObj addMember:sourceFile];
XCTarget *targetObjDev = [project targetWithName:TARGET_NAME_DEV];
[targetObjDev addMember:sourceFile];
}
XCGroup.h
- (void)addSourceFile:(XCSourceFileDefinition*)sourceFileDefinition withPath:(NSString*)pathPrefix;
XCGroup.m
- (void)makeGroupMemberWithName:(NSString*)name contents:(id)contents type:(XcodeSourceFileType)type
fileOperationStyle:(XCFileOperationType)fileOperationStyle withPath:(NSString*)targetPath
...
- (void)addSourceFile:(XCSourceFileDefinition*)sourceFileDefinition withPath:(NSString*)pathPrefix
{
[self makeGroupMemberWithName:[sourceFileDefinition sourceFileName] contents:[sourceFileDefinition data]
type:[sourceFileDefinition type] fileOperationStyle:[sourceFileDefinition fileOperationType]
withPath:targetPath];
....
}
from xcodeeditor.
You mean its working OK for you now?
What is the edit? Something you went merged into the main XcodeEditor branch?
from xcodeeditor.
Yep! OK
I will create merge request~
from xcodeeditor.
Ok, glad to hear it's working for you now.
from xcodeeditor.
Hi iziz/jasper,
I am not able to find this api with the parameter withPath,
is it available in some other branch?
[group addSourceFile:newSourceFile withPath:TARGET_NAME];
from xcodeeditor.
Related Issues (20)
- addframework failed in xcode7 HOT 11
- ESA.Sales.Foobar.xib: iOS xibs do not support target device type "mac" HOT 1
- Linker Error because of duplicate symbols HOT 3
- Update Compile Sources HOT 4
- Embed framework HOT 9
- xcconfig not work in project and target base configuration!
- how can i remove an existing xxx.framework(not imported from apple's libraries) from my project HOT 4
- Carthage: Dependency "XcodeEditor" has no shared framework schemes
- Add file to dynamic framework target Public/Private/Project Build Phases > Headers?
- Make scheme shared
- removeResourceWithKey and removeMemberWithKey need documentation
- XcodeEditor does not handle Emoji in build phase names well HOT 14
- [Question] Does XCodeEditor support sorting targets in alphabetical order?
- feature - determine project / name directory path / project file from key window HOT 4
- Doesn't get all the XCBuildConfiguration's in the file HOT 2
- "Project file of type file.storyboard can't become a build file." HOT 1
- Support for Copy Bundle Phases HOT 6
- Create new Target & Scheme HOT 1
- EXC_BAD_ACCESS from xce_stringFromMemberType HOT 1
- how to add some .strings files to project? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xcodeeditor.