iphonelazext: updating the example hello world project to be compatbile with the later iOS versions

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5044 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2016-07-29 03:31:34 +00:00
parent 48dab069a8
commit 43a1354fe2
2 changed files with 43 additions and 50 deletions

View File

@ -1,86 +1,63 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="7"/> <Version Value="9"/>
<General> <General>
<Flags> <Flags>
<MainUnitHasCreateFormStatements Value="False"/> <MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/> <MainUnitHasTitleStatement Value="False"/>
<UseDefaultCompilerOptions Value="True"/> <UseDefaultCompilerOptions Value="True"/>
</Flags> </Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<TargetFileExt Value=""/>
<Title Value="ihelloworld"/> <Title Value="ihelloworld"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>
<Icon Value="0"/>
<ActiveEditorIndexAtStart Value="0"/>
</General> </General>
<VersionInfo> <VersionInfo>
<ProjectVersion Value=""/> <StringTable ProductVersion=""/>
<Language Value=""/>
<CharSet Value=""/>
</VersionInfo> </VersionInfo>
<CustomData Count="4"> <BuildModes Count="1">
<Item0 Name="iPhone/AppID" Value="com.mycompany.myapplication"/> <Item1 Name="Default" Default="True"/>
<Item1 Name="iPhone/SDK" Value="iPhone 2.0"/> </BuildModes>
<Item2 Name="iPhone/SimSpaceName" Value="AE7A4C5E-559A-1694-53EF-3683CFE2F32D"/>
<Item3 Name="iPhone/isiPhoneApp" Value="true"/>
</CustomData>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<Units Count="1"> <Units Count="1">
<Unit0> <Unit0>
<Filename Value="ihelloworld.pas"/> <Filename Value="ihelloworld.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ihelloworld"/>
<CursorPos X="34" Y="12"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<SyntaxHighlighter Value="Delphi"/>
</Unit0> </Unit0>
</Units> </Units>
<JumpHistory Count="0" HistoryIndex="-1"/>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
<Version Value="8"/> <Version Value="11"/>
<Target>
<Filename Value="ihelloworld"/>
</Target>
<SearchPaths> <SearchPaths>
<IncludeFiles Value="$(ProjOutDir)/"/> <IncludeFiles Value="$(ProjOutDir)"/>
<Libraries Value="$Env(WNLIB)/../Music/oggvorbis/macosx/"/> <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
<OtherUnitFiles Value="MacLauncher/;$Env(WNLIB)/;$Env(WNLIB)/MacOS/;$Env(WNLIB)/Application2/;$Env(WNLIB)/Composite/;$Env(WNLIB)/Graphics/;$Env(WNLIB)/VectorGraphics/;$Env(WNLIB)/TextOut/;$Env(PTELIB)/;$Env(PTELIB)/3DBasics/;$Env(PTELIB)/3DEngine/;$Env(PTELIB)/DeviceMenu/;$Env(PTELIB)/DrawController/;$Env(PTELIB)/GdiEngine/;$Env(PTELIB)/NavPanel/;$Env(PTELIB)/PteClasses/;$Env(PTELIB)/PteViewer/;$Env(PTELIB)/Shaders/;$Env(PTELIB)/ShadowSpreads/;$Env(PTELIB)/VirtualList/;$Env(PTELIB)/OpenGL/;$Env(PTELIB)/MacOS/;$Env(WNLIB)/../Music/;$Env(WNLIB)/../Music/oggvorbis/"/>
</SearchPaths> </SearchPaths>
<Parsing> <Parsing>
<SyntaxOptions> <SyntaxOptions>
<SyntaxMode Value="Delphi"/> <SyntaxMode Value="Delphi"/>
<CStyleOperator Value="False"/>
<IncludeAssertionCode Value="True"/>
<CPPInline Value="False"/>
<UseAnsiStrings Value="True"/>
</SyntaxOptions> </SyntaxOptions>
</Parsing> </Parsing>
<Linking> <Linking>
<Debugging> <Options>
<UseLineInfoUnit Value="False"/> <Win32>
</Debugging> <GraphicApplication Value="True"/>
<LinkSmart Value="True"/> </Win32>
</Options>
</Linking> </Linking>
<Other> <Other>
<CompilerMessages> <CustomOptions Value="-dIPHONEALL"/>
<IgnoredMessages idx3018="True" idx3031="True" idx3189="True" idx4035="True" idx4036="True" idx4055="True" idx4079="True" idx4080="True" idx4081="True" idx5024="True" idx5057="True" idx5058="True" idx5060="True"/>
</CompilerMessages>
<CustomOptions Value="-XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk"/>
<CompilerPath Value="$(CompPath)"/>
</Other> </Other>
</CompilerOptions> </CompilerOptions>
<Debugging> <Debugging>

View File

@ -5,14 +5,17 @@ program ihelloworld;
{$linkframework UIKit} {$linkframework UIKit}
uses uses
iPhoneAll, CGContext, CGGeometry, CFString; // you can probably find a number of different iPhoneAll units available online.
// The example is written, using iPhoneAll from https://github.com/genericptr/iOS_8_0
// Once you get the headers don't forget to add to search path for the project
iPhoneAll;
type type
TAppDelegate = objcclass(NSObject) TAppDelegate = objcclass(NSObject)
procedure applicationDidFinishLaunching(application: UIApplication); message 'applicationDidFinishLaunching:'; procedure applicationDidFinishLaunching(application: UIApplication); message 'applicationDidFinishLaunching:';
end; end;
TMyWindow = objcclass(UIWindow) TMyView = objcclass(UIView)
public public
procedure drawRect(c: CGRect); override; procedure drawRect(c: CGRect); override;
end; end;
@ -21,7 +24,7 @@ const
helloworld = 'Hello world'; helloworld = 'Hello world';
// window paint method // window paint method
procedure TMyWindow.drawRect(c: CGRect); procedure TMyView.drawRect(c: CGRect);
var var
cg : CGContextRef; cg : CGContextRef;
begin begin
@ -45,18 +48,29 @@ begin
end; end;
var var
mainwindow : TMyWindow; mainwindow : UIWindow;
ctrl : UIViewController;
myview : TMyView;
{ TAppDelegate } { TAppDelegate }
procedure TAppDelegate.applicationDidFinishLaunching(application: UIApplication); procedure TAppDelegate.applicationDidFinishLaunching(application: UIApplication);
begin begin
// application has initialized, now we can create the main window // application has initialized, now we can create the main window
mainwindow:=TMyWindow(TMyWindow.alloc);
// initialize window in Objective-C style // initialize window in Objective-C style
mainwindow := TMyWindow(mainwindow.initWithFrame (UIScreen.mainScreen.bounds)); mainwindow:=UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds);
// creating the root controller
ctrl:=UIViewController.alloc.init;
mainwindow.setRootViewController(ctrl);
myview := TMyView.alloc.init;
myview.setBounds( mainwindow.bounds );
ctrl.setView(myview);
// activate and show the window // activate and show the window
mainwindow.makeKeyAndVisible; mainwindow.makeKeyAndVisible;
end; end;
function NSStr(const s: string): NSString; function NSStr(const s: string): NSString;
@ -68,11 +82,13 @@ end;
var var
pool : NSAutoreleasePool; pool : NSAutoreleasePool;
{$R *.res}
begin begin
// initialize foundation memory manger (aka autorelease pool) // initialize foundation memory manger (aka autorelease pool)
pool := NSAutoreleasePool.alloc.init; pool := NSAutoreleasePool.alloc.init;
// launching main application loop // launching main application loop
ExitCode:=UIApplicationMain(argc, argv, nil, NSSTR('TAppDelegate')); ExitCode:=UIApplicationMain(argc, PChar(argv), nil, NSSTR('TAppDelegate'));
// according to docs the UIApplicationMain never returns, // according to docs the UIApplicationMain never returns,
// but still the code present in the Obj-C main.m files // but still the code present in the Obj-C main.m files
pool.release; pool.release;