Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix some classes not autocompleting in Swift, updated template with Swift Appdelegates #1351

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2fd0734
fix some classes not autocompleting in Swift, updated template
LearnCocos2D Feb 12, 2015
489baab
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
c55ac0d
fixed a typo: XCode -> Xcode
LearnCocos2D Feb 12, 2015
71eaf39
updated project creator to support new Swift AppDelegates and Mac tar…
LearnCocos2D Feb 12, 2015
1f19210
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
f552250
fix #1393 - Mac: size of window does not take into account title bar …
LearnCocos2D Mar 3, 2015
64eec30
Merge branch 'KoboldKit-develop-steffen' into develop
LearnCocos2D Mar 3, 2015
c4705e1
fix some classes not autocompleting in Swift, updated template
LearnCocos2D Feb 12, 2015
3d74f9b
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
8b82718
fixed a typo: XCode -> Xcode
LearnCocos2D Feb 12, 2015
e6e9a2d
updated project creator to support new Swift AppDelegates and Mac tar…
LearnCocos2D Feb 12, 2015
0b0663e
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
8e25f9a
fix #1393 - Mac: size of window does not take into account title bar …
LearnCocos2D Mar 3, 2015
448428b
Merge branch 'refs/heads/develop' into develop-steffen
LearnCocos2D Mar 3, 2015
76d7cbb
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
ca0a6f1
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
91025e5
fix main trying to launch "AppController" instead of "AppDelegate"
LearnCocos2D Mar 4, 2015
257137d
update copyrights of appdelegate files
LearnCocos2D Mar 4, 2015
88900d5
fix some classes not autocompleting in Swift, updated template
LearnCocos2D Feb 12, 2015
831cbae
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
4c22ec8
fixed a typo: XCode -> Xcode
LearnCocos2D Feb 12, 2015
c8e637e
updated project creator to support new Swift AppDelegates and Mac tar…
LearnCocos2D Feb 12, 2015
a630c71
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
b46a414
fix #1393 - Mac: size of window does not take into account title bar …
LearnCocos2D Mar 3, 2015
54e67b4
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
4b02356
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
e09f951
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
c98cf31
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
2990051
fix main trying to launch "AppController" instead of "AppDelegate"
LearnCocos2D Mar 4, 2015
0606adc
update copyrights of appdelegate files
LearnCocos2D Mar 4, 2015
9cfbed5
Merge remote-tracking branch 'fork-koboldkit/develop-steffen' into de…
LearnCocos2D Mar 4, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated project creator to support new Swift AppDelegates and Mac tar…
…get fixes
  • Loading branch information
LearnCocos2D committed Mar 4, 2015
commit c8e637ed323e99e7063c91921740652e85bffed7
31 changes: 29 additions & 2 deletions SpriteBuilder/ccBuilder/CCBProjectCreator.m
Original file line number Diff line number Diff line change
@@ -97,12 +97,17 @@ -(BOOL) createDefaultProjectAtPath:(NSString*)fileName engine:(CCBTargetEngine)e
inFile:pbxprojFile
search:@"MACOSX_DEPLOYMENT_TARGET = 10.10"];
[self removeLinesMatching:@".*MainScene[.]swift.*" inFile:pbxprojFile];
filesToRemove = @[@"Source/MainScene.swift"];
[self removeLinesMatching:@".*AppDelegate[.]swift.*" inFile:pbxprojFile];
filesToRemove = @[@"Source/MainScene.swift", @"Source/Platforms/iOS/AppDelegate.swift", @"Source/Platforms/Mac/AppDelegate.swift"];
}
else if (programmingLanguage == CCBProgrammingLanguageSwift)
{
[self removeLinesMatching:@".*MainScene[.][hm].*" inFile:pbxprojFile];
filesToRemove = @[@"Source/MainScene.h", @"Source/MainScene.m"];
[self removeLinesMatching:@".*AppDelegate[.][hm].*" inFile:pbxprojFile];
[self removeLinesMatching:@".*main[.][m].*" inFile:pbxprojFile];
filesToRemove = @[@"Source/MainScene.h", @"Source/MainScene.m",
@"Source/Platforms/iOS/AppDelegate.h", @"Source/Platforms/iOS/AppDelegate.m", @"Source/Platforms/iOS/main.m",
@"Source/Platforms/Mac/AppDelegate.h", @"Source/Platforms/Mac/AppDelegate.m", @"Source/Platforms/Mac/main.m"];
}

for (NSString *file in filesToRemove)
@@ -157,6 +162,12 @@ -(BOOL) createDefaultProjectAtPath:(NSString*)fileName engine:(CCBTargetEngine)e

// Update Mac Xib file
NSString* xibFileName = [parentPath stringByAppendingPathComponent:@"Source/Resources/Platforms/Mac/MainMenu.xib"];
if (programmingLanguage == CCBProgrammingLanguageObjectiveC)
{
// this fixes the ObjC Mac target not being able to "find" the AppDelegate class
// CAUTION: This has to be performed *before* the substitutions below as it includes PROJECTNAME in the search string
[self removeAppDelegateModuleAndTargetFromXib:xibFileName];
}
[self setName:identifier inFile:xibFileName search:substitutableProjectIdentifier];
[self setName:projName inFile:xibFileName search:substitutableProjectName];

@@ -235,4 +246,20 @@ - (void) removeLinesMatching:(NSString*)pattern inFile:(NSString*)fileName
[updatedFileData writeToFile:fileName atomically:YES];
}

-(void) removeAppDelegateModuleAndTargetFromXib:(NSString*)xibFileName
{
// this fixes the ObjC Mac target not being able to "find" the AppDelegate class because the Xib specified a custom module and target,
// which coincidentally is necessary for the Mac target in Swift to find the AppDelegate - so best solution was to setup Main.xib so
// that it works with Swift and removing the module & target for ObjC projects
NSData *fileData = [NSData dataWithContentsOfFile:xibFileName];
NSString *fileString = [[NSString alloc] initWithData:fileData encoding:NSUTF8StringEncoding];

NSString* searchFor = @"customClass=\"AppDelegate\" customModule=\"PROJECTNAME\" customModuleProvider=\"target\"";
NSString* replaceWith = @"customClass=\"AppDelegate\"";
fileString = [fileString stringByReplacingOccurrencesOfString:searchFor withString:replaceWith];

NSData *updatedFileData = [fileString dataUsingEncoding:NSUTF8StringEncoding];
[updatedFileData writeToFile:xibFileName atomically:YES];
}

@end