Forum > iPhone/iPad

Questions about making iOS library.....

(1/3) > >>

chenyuchih:
Hello,

I would like to write some libraries for iOS and I saw there's precompiled cross-compiler package in sourceforge. So I installed the following things sequentially:

Xcode (and the command line tool)
fpc-3.0.0.intel-macosx.dmg
fpc-3.0.1.intel-macosx.cross.ios.dmg
fpcsrc-3.0.0-20151207-macosx.dmg
lazarus-1.6-i686-macosx.dmg

My questions are
1. Does it mean that I can start to write the most basic program/library(no GUI, no framework) for iOS? If not, what should I need more?
2. How should I config the project options? (CPU-target as "arm-darwin" and "a64-darwin"?)
3. I tried to compile one library for iphone simulator(i386-iphonesim), but the compiler shows that unit system cannot be found. Where can I found the needed units?

Thanks for your help!

Best Regards,
ChenYuChih

Phil:

--- Quote from: chenyuchih on May 30, 2016, 10:33:50 am ---1. Does it mean that I can start to write the most basic program/library(no GUI, no framework) for iOS? If not, what should I need more?

--- End quote ---

Do you actually mean "library" or do you mean "unit" or something else? Creating a program (app bundle) for iOS is different from creating a library (framework included in an app bundle) for iOS.

This is what "library" means:

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/PascalDynLibs.html

These articles don't deal specifically with iOS, but the principles are the same.

-Phil

chenyuchih:
Well, the library what I mentioned is "dynamically loaded library"(*.dll, *.so, *.dynlib). What I want is to create a dynlib with some numerical and string processing for other iOS programs. Do I need any other packages or patches for this purpose?

Thanks.

ChenYuChih

Phil:
Very good. Yes, you can create a dynamic library for iOS with FPC. For example, with the ndfd example library in the article series above, you can compile it into a multi-architecture library for iOS like this (in a bash script):


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---#!/bin/shset -e fpc_options="-S2ha -CiroR -O2 -XX -Fu~/Tools/WST" sdkroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ppcarm -Cparmv7 -Cfvfpv3 $fpc_options -XR$sdkroot -olibndfd-arm ndfd.pasppca64 $fpc_options -XR$sdkroot -olibndfd64-arm ndfd.pas sdkroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ppc386-3.0.1 -Tiphonesim $fpc_options -XR$sdkroot -olibndfd-sim ndfd.pasppcx64-3.0.1 -Tiphonesim $fpc_options -XR$sdkroot -olibndfd64-sim ndfd.pas lipo -create libndfd-arm libndfd64-arm libndfd-sim libndfd64-sim -output ndfdinstall_name_tool -id ndfd ndfdrm libndfd-armrm libndfd64-armrm libndfd-simrm libndfd64-sim 
Note that libraries included with an iOS app bundle must be in a framework, hence why the library file created is named "ndfd" instead of the "libndfd.dylib". This ndfd library file is copied into a framework folder (eg, ndfd.framework) along with the framework's Info.plist file. Finally, ndfd.framework is copied into the app bundle's Framework subfolder.

Note that for distribution with an actual arm app (not Simulator) you can use lipo to strip out the i386 and x86_64 architectures' code. For testing with the Simulator, it doesn't hurt to leave the armv7 and arm64 architectures' code in the library, even though the arm code will not be used under the Simulator.

-Phil

chenyuchih:
Thanks Phil,

Sounds that the released version (3.0.0 & 3.0.1 cross-compiler) is enough for my usage.

But I'm still curious about how to work with Lazarus 1.6, because I do like the Lazarus IDE...

Is there any response to my 2nd and 3rd question?

BTW, I saw you specify the SDK path in the script, where should I set it in Lazarus? (It seems not the same as Android library path...)

Thank you very much!

ChenYuChih

Navigation

[0] Message Index

[#] Next page

Go to full version