IPhone/iPod development: changes

Revision 57504
Skalogryz,
/* External Links */
Older edit
Revision 57518 (current)
Trev,
/* iOS 8.0 and later */ Update
@@ -1,9 +1,3 @@
1---
2categories:
3 - "Mac OS X"
4 - "IOS"
5---
6
7::tpl[Platform only]{1="iOS" 2="iOS" 3="iOS"}1::tpl[Platform only]{1="iOS" 2="iOS" 3="iOS"}
82
9::tpl[iPhone iPod development]3::tpl[iPhone iPod development]
@@ -13,7 +7,7 @@
13Requirements:7Requirements:
148
15- Intel Mac (iPhone SDK requirement)9- Intel Mac (iPhone SDK requirement)
16- Mac OS X 10.5.5 or later (iPhone SDK requirement)10- Leopard 10.5.5 or later (iPhone SDK requirement)
17- iPhone SDK 3.x or later installed (tested with 2.2 - 5.1). **Warning:** there is a bug in the iPhone SDK 3.0 linker. See below for more information.11- iPhone SDK 3.x or later installed (tested with 2.2 - 5.1). **Warning:** there is a bug in the iPhone SDK 3.0 linker. See below for more information.
1812
19Some features:13Some features:
@@ -42,12 +36,14 @@
4236
43## Apple's Licence limitations37## Apple's Licence limitations
4438
45### Developing applications for iPhone/iPod39### Signing up to the Apple Developer Program
4640
47FPC cannot work around the requirement of needing an Apple-issued certificate to run self-written programs on an iPhone/iPod Touch. So you have to sign up to Apple's iPhone Developer program ($99/year) to run FPC-compiled programs on the real hardware (just like for regular Xcode-compiled programs).41You will eventually need to sign up to Apple's iPhone Developer program ($99/year) to distribute your programs through the Apple store. This applies to any iPhone application, compiled with FPC or not.
4842
49Without such a certificate, you can only run programs on the simulator (possibly unless you have a jailbroken iPhone/iPod Touch, but in that case you are on your own).43You *do not need to pay the fee* to run applications on your own physical iPhone device. A free developer account will be enough for this, if you use the new XCode versions.
5044
45Without a developer certificate, you can only run programs on the simulator. (Possibly you can also workaround this if you have a jailbroken iPhone/iPod Touch, but in that case you are on your own.)
46
51Read more about Apple's iPhone development program here: <http://developer.apple.com/iphone/program/>47Read more about Apple's iPhone development program here: <http://developer.apple.com/iphone/program/>
5248
53### Pascal headers required for developing49### Pascal headers required for developing
@@ -60,9 +56,9 @@
6056
61### iPhone Simulator is not iPhone57### iPhone Simulator is not iPhone
6258
63The iPhone Simulator makes the iPhone OS API in available to regular Mac applications, thereby mimicking the environment that the devices provide. By allowing you to run your applications in Mac OS X, the simulator provides a way to quickly test your application’s functionality without the need for an actual device. However, running applications on the simulator is not the same as running them on devices.59The iPhone Simulator makes the iPhone OS API in available to regular Mac applications, thereby mimicking the environment that the devices provide. By allowing you to run your applications in macOS, the simulator provides a way to quickly test your application’s functionality without the need for an actual device. However, running applications on the simulator is not the same as running them on devices.
6460
65The simulator uses Mac OS X versions of the low-level iPhone OS frameworks instead of the versions that run on devices. In general, the simulator is a good tool for performing initial testing of your application. Keep however in mind that, because the simulator does not emulate device functionality, you must always perform final testing and performance analysis of your application on actual devices. The main reason is that programs running under the simulator can also transparently use any other frameworks/functionality used by the host Mac OS X operating system, which may not be available on the device.61The simulator uses macOS versions of the low-level iPhone OS frameworks instead of the versions that run on devices. In general, the simulator is a good tool for performing initial testing of your application. Keep however in mind that, because the simulator does not emulate device functionality, you must always perform final testing and performance analysis of your application on actual devices. The main reason is that programs running under the simulator can also transparently use any other frameworks/functionality used by the host macOS operating system, which may not be available on the device.
6662
67## Compiling and running pure Pascal applications on an iPhone/iPod Touch63## Compiling and running pure Pascal applications on an iPhone/iPod Touch
6864
@@ -86,35 +82,35 @@
8682
87**for FPC 2.6.0:**83**for FPC 2.6.0:**
8884
85```text
86 ppcarm -Cparmv6 -Cfvfpv2 -FD/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin -XR/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk program.pas
89```87```
90ppcarm -Cparmv6 -Cfvfpv2 -FD/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin -XR/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk program.pas
91```
9288
93for iPhoneSimulator ( OS_TARGET has been introduced)89for iPhoneSimulator ( OS_TARGET has been introduced)
9490
91```text
92 ppc386 -Tiphonesim -XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk program.pas
95```93```
96ppc388 -Tiphonesim -XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk program.pas
97```
9894
99**prior to FPC 2.6.0:**95**prior to FPC 2.6.0:**
10096
97```text
98 ppcarm -FD/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin -XR/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk program.pas
101```99```
102ppcarm -FD/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin -XR/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk program.pas
103```
104100
105for iPhoneSimulator101for iPhoneSimulator
106102
103```text
104 ppc386 -XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk program.pas
107```105```
108ppc388 -XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk program.pas
109```
110106
111## Compiling and running pure Pascal applications on iPhone simulator107## Compiling and running pure Pascal applications on iPhone simulator
112108
113Compiling and linking requires a regular ppc386 compiler. There is little difference between an iPhone Simulator and a regular Mac OS X application, except that iPhoneSim applications are linked to different frameworks compared to regular Mac OS X applications.109Compiling and linking requires a regular ppc386 compiler. There is little difference between an iPhone Simulator and a regular macOS application, except that iPhoneSim applications are linked to different frameworks compared to regular macOS applications.
114110
115Starting with FPC 2.6.0 **iphonesim** target has been introduced. For SDKs 3.2 and higher fpc packages needs to be compiled for iphonesim target ([see #17470](http://bugs.freepascal.org/view.php?id=17470)). Reasoning: while FPC compile is still pretty much the same (i386 target), different Objective-C ABI is used. For darwin-i386 FPC is using ObjC1 (to be compatible with OSX 10.4 and earlier), while iphonesim-i386 required ObjC2 only. (It seems like previous versions of iPhoneSim SDK 2.x and 3.0 allows ObjC1)111Starting with FPC 2.6.0 **iphonesim** target has been introduced. For SDKs 3.2 and higher fpc packages needs to be compiled for iphonesim target ([see #17470](http://bugs.freepascal.org/view.php?id=17470)). Reasoning: while FPC compile is still pretty much the same (i386 target), different Objective-C ABI is used. For darwin-i386 FPC is using ObjC1 (to be compatible with OSX 10.4 and earlier), while iphonesim-i386 required ObjC2 only. (It seems like previous versions of iPhoneSim SDK 2.x and 3.0 allows ObjC1)
116112
117Some frameworks are iPhone-specific (UIKit), other frameworks exist for both Mac OS X and the iPhoneOS (CoreFoundation, CoreGraphics, etc). The iPhoneSim SDK provides its own versions of these frameworks. In order to ensure that the SDK's versions of these frameworks are used, you have to to tell the compiler to use appropriate SDK (just like when compiling applications for a real device):113Some frameworks are iPhone-specific (UIKit), other frameworks exist for both macOS and the iOS (CoreFoundation, CoreGraphics, etc). The iPhoneSim SDK provides its own versions of these frameworks. In order to ensure that the SDK's versions of these frameworks are used, you have to to tell the compiler to use appropriate SDK (just like when compiling applications for a real device):
118114
119```115```
120 fpc simtest.pas -XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk116 fpc simtest.pas -XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk
@@ -154,6 +150,33 @@
154150
155(possibly with an INSTALL_PREFIX=xyz at the end of the "sudo make" line to install it under "xyz" rather than under /usr/local -- in that case, also adjust the "ln" command afterwards)151(possibly with an INSTALL_PREFIX=xyz at the end of the "sudo make" line to install it under "xyz" rather than under /usr/local -- in that case, also adjust the "ln" command afterwards)
156152
153## iOS 8.0 and later
154
155Apple requires everyone to use 64-bit applications for iOS 8.0 (and later). Also iPhone Simulator for iOS 8.0 is 64-bit only.
156
157Whenever you compile a project you'll need to use the proper SDK and proper bin utilities. Note that for iPhone Simulator, there's also its own set of bin utilities, not compatible with default macOS bin utilities.
158
159Example
160
161```
162export SDK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
163export BIN_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/
164```
165
166```
167ppcx64 -Tiphonesim -Px86_64 -Scghi -O1 -va -XR$SDK_PATH -FD$BIN_PATH iphoneproj.pas
168```
169
170Note that using "-va" parameter (show all messages) which helps to know whether you're using the right path for bin utilities and SDK. The desired result is that ctrl.o library and ld tool are found in a proper target platform, similar to shown below.
171
172```
173[0.437] Linking iphoneproj
174[0.481] Searching file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/crt1.o... found
175[0.481] Searching file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ld... found
176```
177
178If the path is not found then FPC will fallback to system-wide defaults (macOS target) and the linking is likely to fail.
179
157## More information180## More information
158181
159- [Simple iPhone example using FreePascal and SDL](http://freeze-dev.de/blog/?p=492)182- [Simple iPhone example using FreePascal and SDL](http://freeze-dev.de/blog/?p=492)
@@ -164,5 +187,7 @@
164187
165## External Links188## External Links
166189
167- ["Developing with Objective Pascal" articles](http://dl.dropboxusercontent.com/u/28343282/ObjP/index.html)190- [Simon Choi's Basic Tutorial for Clean Installation for iOS 8.2](https://blog.naver.com/simonsayz/220305479793)
168- <https://github.com/genericptr/Framework-Parser> - the primary Apple frameworks headers parser (used for FPC package)191- [Simon Choi's Basic Tutorial for Clean Installation for iOS 11.2.5](https://blog.naver.com/simonsayz/221209784815)
192- [The primary Apple frameworks headers parser (used for FPC package)](https://github.com/genericptr/Framework-Parser)
193- [Tips for Castle game engine project compilation for iOS](https://github.com/castle-engine/castle-engine/wiki/iOS)