I am trying to create a framework in XCode 4.2 for iOS applications.
I was developing my own Game framework. I was usually distributing only in source codes and resources but, due to using ARC in my framework, I had to distribute in static library and framework.
I haven't decided which shall I use yet.
Although developing framework for iOS is not a supported way, It's better that distributing resources and headers and Mach-O file in one directory(same as framework).
So I want to use framework to distribute my Game framework.
I used this script to create a Framework.
It seems that I have success creating a framework and copy mach-O and headers and resources.
But this framework's resources couldn't be added to the application which I added this framework.
#!/bin/bash
set -o errexit
set -o nounset
# Environment Variables
PANKIA_DIR="${SRCROOT}/Pankia"
PANKIA_CORE_DIR="${PANKIA_DIR}/Core"
PANKIA_PLATFORM_DIR="${PANKIA_DIR}/Platform"
FRAMEWORK_NAME="Pankia"
FRAMEWORK_VERSION=A
FRAMEWORK_VERSION_NUMBER=1.0
FRAMEWORK_BUILD_PATH="${SRCROOT}/build/${CONFIGURATION}-framework"
FRAMEWORK_DIR="${FRAMEWORK_BUILD_PATH}/${FRAMEWORK_NAME}.framework"
FRAMEWORK_PACKAGE_NAME="${FRAMEWORK_NAME}.${FRAMEWORK_VERSION_NUMBER}.zip"
FRAMEWORK_TARGET_NAME="libPankia"
# Clean directories
rm -rf "${FRAMEWORK_BUILD_PATH}"
# Build simulator and device binaries.
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator${IPHONEOS_DEPLOYMENT_TARGET} -target ${FRAMEWORK_TARGET_NAME} -configuration ${CONFIGURATION} clean build
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphoneos${IPHONEOS_DEPLOYMENT_TARGET} -target ${FRAMEWORK_TARGET_NAME} -configuration ${CONFIGURATION} clean build
# create framework directories.
mkdir -p ${FRAMEWORK_DIR}
mkdir -p ${FRAMEWORK_DIR}/Versions
mkdir -p ${FRAMEWORK_DIR}/Versions/${FRAMEWORK_VERSION}
mkdir -p ${FRAMEWORK_DIR}/Versions/${FRAMEWORK_VERSION}/Resources
mkdir -p ${FRAMEWORK_DIR}/Versions/${FRAMEWORK_VERSION}/Headers
# create symlinks
ln -s ${FRAMEWORK_DIR}/Versions/${FRAMEWORK_VERSION} ${FRAMEWORK_DIR}/Versions/Current
ln -s ${FRAMEWORK_DIR}/Versions/Current/Headers ${FRAMEWORK_DIR}/Headers
ln -s ${FRAMEWORK_DIR}/Versions/Current/Resources ${FRAMEWORK_DIR}/Resources
ln -s ${FRAMEWORK_DIR}/Versions/Current/${FRAMEWORK_NAME} ${FRAMEWORK_DIR}/${FRAMEWORK_NAME}
# create the universal library
lipo ${SRCROOT}/build/${CONFIGURATION}-iphoneos/lib${FRAMEWORK_TARGET_NAME}.a ${SRCROOT}/build/${CONFIGURATION}-iphonesimulator/lib${FRAMEWORK_TARGET_NAME}.a -create -output "${FRAMEWORK_DIR}/Versions/Current/${FRAMEWORK_NAME}"
# copy files
cp ${PANKIA_PLATFORM_DIR}/GameInterface/Pankia.h ${FRAMEWORK_DIR}/Headers/
cp ${PANKIA_PLATFORM_DIR}/Models/Native/*.h ${FRAMEWORK_DIR}/Headers/
cp ${PANKIA_CORE_DIR}/Models/Native/*.h ${FRAMEWORK_DIR}/Headers/
cp -r ${PANKIA_PLATFORM_DIR}/Resources ${FRAMEWORK_DIR}/Resources/
cp -r ${PANKIA_PLATFORM_DIR}/RetinaResources ${FRAMEWORK_DIR}/Resources/
cp ${SRCROOT}/libPankia/Info.plist ${FRAMEWORK_DIR}/Resources/
# cp ${SRCROOT}/build/${CONFIGURATION}-iphoneos/usr/local/include/*.h ${FRAMEWORK_DIR}/Headers/
# cp Info.plist ${FRAMEWORK_DIR}/Resources
# zip (配布用に TestFramework.framework ディレクトリをZIP圧縮するだけなので、配布しないなら以下はコメントアウトしてもよい)
# cd ${FRAMEWORK_BUILD_PATH}
# zip -ry ${FRAMEWORK_PACKAGE_NAME} $(basename $FRAMEWORK_DIR)
Do you know why?
And is there any better way to distribute my framework?
Here is a helpful tutorial on creating frameworks. I have used it and have been able to package resources with the framework.
http://codefriend.blogspot.com/2011/09/creating-ios-framework-with-xcode4.html
Related
In my game, there is already a Admob plugin setup, and I want to set up Chartboost plugin too. When I setup the Chartboost plugin, I can't make the apk package.
CommandInvokationFailure: Failed to re-package resources.
D:\Android\sdk\build-tools\25.0.1\aapt.exe package --auto-add-overlay
-v -f -m -J "gen" -M "AndroidManifest.xml" -S "res" -I "D:/Android/sdk\platforms\android-25\android.jar" -F bin/resources.ap_
--extra-packages android.support.v7.appcompat:com.unity3d.player:com.unity.purchasing:com.android.vending.billing:com.google.unity.ads:com.unity.purchasing.googleplay:com.google.example.games.mainlibproj:com.google.android.gms.ads.impl:com.google.android.gms.ads:com.google.android.gms.auth.api:com.google.android.gms.auth:com.google.android.gms.base:com.google.android.gms:com.google.android.gms:com.google.android.gms.clearcut:com.google.android.gms.drive:com.google.android.gms.games:com.google.android.gms.gass:com.google.android.gms.nearby:com.google.android.gms.tasks:android.support.v4:com.unity3d.ads:com.pushok.test
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\common\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\GoogleAIDL\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\GooglePlay\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-ads-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-ads-lite-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-auth-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-auth-base-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-base-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-basement-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-basement-9.0.0\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-clearcut-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-drive-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-games-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-gass-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-nearby-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\play-services-tasks-10.0.1\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\support-v4-24.0.0\res"
-S "E:\unityWork\MySlots\SlotsGame\Temp\StagingArea\android-libraries\UnityAds\res"
And seems to be the file AndroidManifest.xml made this error.
I have made a backup, so I use git to find what changed in my project.
I find when I set up the Chartboost (click 'Setup Android SDK' button), there is added a file play-services-basement-9.0.0.aar, And I already have play-services-basement-10.0.0.aar.So I delete the 9.0.0 file.
Now I can make the apk package!
Your error CommandInvokationFailure: Failed to re-package resources. might occurs when you have an AndroidManifest.xml file (Probably under Plugins/Android or a plugin in a subfolder of this folder) that tries to access a resource by name (google_play_services_version), but this value is never defined anywhere. Usually, this value is added via some method such as adding it to the AndroidManifest.xml or to an xml under res/values.
Another workaround is:
To fix this error, you have to copy the version.xml file from
android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/res/values/
into Assets/Plugins/Android/res/values/ of your Unity project's folder.
Additional resource:
Unity 5 Android Build - Failed to re-package resources
Failed to re-package resources : aapt.exe package
Alright guys, I posted a similar question and took it down because it wasn't specific enough so here I go. From the zip file of Freetype 2.6.5 I have not been able to create an Xcode project that will compile the library for iOS use, only for i386_64.
I tried the commands here but I don't get past the first commands the and I am getting this
FreeType build system -- automatic system detection
The following settings are used:
platform unix compiler cc
configuration directory ./builds/unix configuration rules
./builds/unix/unix.mk
If this does not correspond to your system or settings please remove
the file `config.mk' from this directory then read the INSTALL file
for help.
Otherwise, simply type
/Applications/Xcode.app/Contents/Developer/usr/bin/make' again to
build the library, or
/Applications/Xcode.app/Contents/Developer/usr/bin/make refdoc' to
build the API reference (this needs python >= 2.6).
cd builds/unix; \
./configure 'CFLAGS=-arch i386' /bin/sh: ./configure: No such file or directory make: *** [setup] Error 127
I also followed the instructions inside the cmakelists.txt that it comes inside the project but still nothing, I still get an xcode project for osx and not for IOS which is giving me a plethora of linking errors. Here is the instructions for your reference.
For an iOS static library, use
#
cmake -D IOS_PLATFORM=OS -G Xcode
#
or
#
cmake -D IOS_PLATFORM=SIMULATOR -G Xcode
I am not sure what else to do. Any help?
Here's an outline of the basic build process to compile the FreeType libaries for iOS:
Download the latest FreeType source code
Extract the archive and cd into the unarchived directory
Setup toolchain and export variables for the architectures desired (arm64, arm7, i386, x86_64)
Compile the source code and build the libraries
For example, the build commands for arm64 might look something like this:
$ export CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
$ iphoneos="7.0" # target version of iOS
$ ARCH="arm64" # architecture (arm64, arm7, i386, x86_64)
$ export CFLAGS="-arch ${ARCH} -pipe -mdynamic-no-pic -Wno-trigraphs -fpascal-strings \
-O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden \
-miphoneos-version-min=$iphoneos -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2 \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
$ export AR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
$ export LDFLAGS="-arch ${ARCH} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
-miphoneos-version-min=7.0"
$ ./configure --host="aarch64-apple-darwin" --enable-static=yes --enable-shared=no
$ make
$ clean
It's a bit of work to construct the commands for each arch, but
fortunately there's a build
script
— which automatically downloads, extracts, and builds the latest FreeType (2.6.5 currently).
To run the script just use the following command in Terminal:
./build_freetype.sh
The resulting iOS libraries can be found in ~/Desktop/FreeType_iOS_Release when it completes.
I got a simple application I want to run on my iphone. However I get a annoying error the provisioning profile can not be found. It happens after I go to my project folder and run:
sudo rake device:iphone:production
=== BUILD NATIVE TARGET RhoLib OF PROJECT RhoLib WITH CONFIGURATION Release ===
Check dependencies
=== BUILD NATIVE TARGET rhoextlib OF PROJECT rhoextlib WITH CONFIGURATION Release ===
Check dependencies
=== BUILD NATIVE TARGET curl OF PROJECT curl WITH CONFIGURATION Release ===
Check dependencies
=== BUILD NATIVE TARGET rhorunner OF PROJECT rhorunner WITH CONFIGURATION Release ===
Check dependencies
Code Sign error: Provisioning profile '0558F1B2-FE5A-4236-B9EE-A200EFAD68E9' can't be found
cd ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rhodes-3.3.3
set bundle identifier
set URL name
restore_default_images
rm -f platform/iphone/Default.png
rm -f platform/iphone/Default.png
cp platform/iphone/Default.bak platform/iphone/Default.png
rm -f platform/iphone/Default.bak
rm -f platform/iphone/Default#2x.png
rm -f platform/iphone/Default-Portrait.png
rm -f platform/iphone/Default-PortraitUpsideDown.png
rm -f platform/iphone/Default-Landscape.png
rm -f platform/iphone/Default-LadscapeLeft.png
rm -f platform/iphone/Default-LandscapeRight.png
restore icon
rm -f platform/iphone/icon.png
cp platform/iphone/icon.bak platform/iphone/icon.png
rm -f platform/iphone/icon.bak
rm -f platform/iphone/icon57.png
cp platform/iphone/icon57.bak platform/iphone/icon57.png
rm -f platform/iphone/icon57.bak
rm -f platform/iphone/icon72.png
cp platform/iphone/icon72.bak platform/iphone/icon72.png
rm -f platform/iphone/icon72.bak
rm -f platform/iphone/icon114.png
cp platform/iphone/icon114.bak platform/iphone/icon114.png
rm -f platform/iphone/icon114.bak
************************************
ERROR during building by XCode !
XCode return next error code = pid 9102 exit 65
I checked the xcode organizer and the profile is both on the phone and the library.
I checked developer.apple.com and the profile is Distribution Ad Hoc for the device plugged in.
My build.yml:
sdkversion: 3.3.2
name: My Application
version: 0.1
vendor: rhomobile
build: release
bbver: 4.6
applog: rholog.txt
iphone:
provisionprofile: 0558F1B2-FE5A-4236-B9EE-A200EFAD68E9
sdk: iphoneos5.1
codesignidentity: "iPhone Distribution"
entitlements:
configuration: Release
emulator: 5.1
emulatortarget: iphone
BundleIdentifier: com.randomname.myapplication
BundleURLScheme: myapplication
wp:
productid:
uid: 3928127822
android:
version: 2.1
extensions:
- accelerometer
Anyone got a clue what I missed here? Already been trying different things for a few days without result :(
After a while I found that the script checks for the provisioning profile in /Library/MobileDevice/Provisioning Profiles instead of ~/Library/MobileDevice/Provisioning Profiles. This is caused by using the sudo command, however without sudo I dont have permission. Workaround is to create a /Library/MobileDevice/Provisioning Profiles folder and copy the installed profile to that location. Code signing works fine now.
edit: even a better solution is to reinstall the rhodes gem without sudo. By installing the suite I had to sudo it to make system changes, however this made the compilation require sudo as well and therefor look in the wrong place for provisioning profiles.
This did the trick:
sudo gem uninstall rhodes
gem install rhodes
I want to clean, build and create .ipa file using an ant script. Also I need to set the application icon. I searched the web but couldn't find a solution. And i prefer to run the ant through the terminal.
Try searching for Ant + XCodeBuild. There should be plenty examples out there that give you a general idea how you can script an XCode build from ANT.
Key is the terminal xcodebuild command and you can only do this with Ant if you run your build on a Mac.
You can create a script.sh instead a Ant with this:
#!/bin/sh
cd {PROJECT_BUILDDIR}
xcodebuild -sdk iphoneos5.1 -configuration Release "ARCHS=armv6 armv7" clean build
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${PROJECT_BUILDDIR}/${PROJECT_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${DEVELOPER_NAME}" --embed "${PROVISONING_PROFILE}"
And for start this, open Terminal and write:
sudo bash script.sh
This is is not tested, maybe exist a some small errors
For some tips
I am getting a library not found error building GraphViz current release (June 7 2012) with Xcode 4.3 using a script. I may have made mistakes updating build scripts from other people's successful recipes for the new location of Xcode4.3 and the developer tools in the Applications folder.
ld: library not found for -lcrt1.10.6.o
(doing this from memory so exact number on the CRT lib may be wrong)
Am also a little lost also how I would incorporate this into an Xcode build in the IDE. I am a very experienced programmer but having trouble finding my way around Xcode 4 at times. (Decades of Visual Studio et al).
I have copied the instructions from this earlier question and adapted
#!/bin/sh
# For iPhoneOS, see http://clang.llvm.org/ for options
export DEV_iOS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
# was /Developer/Platforms/iPhoneOS.platform/Developer
export SDK_iOS=${DEV_iOS}/SDKs/iPhoneOS5.1.sdk
export COMPILER_iOS=${DEV_iOS}/usr/bin
export CC=${COMPILER_iOS}/clang
export CXX=${COMPILER_iOS}/clang++
export LDFLAGS="-arch armv7 -pipe -Os -gdwarf-2 -mthumb -isysroot ${SDK_iOS}"
export CFLAGS="${LDFLAGS}"
export OBJCFLAGS="${LDFLAGS}"
export CXXFLAGS="${LDFLAGS} -fvisibility-inlines-hidden"
export LD=${COMPILER_iOS}/ld
export CPP=${COMPILER_iOS}/clang
export AR=${COMPILER_iOS}/ar
export AS=${COMPILER_iOS}/as
export NM=${COMPILER_iOS}/nm
export CXXCPP="${COMPILER_iOS}/clang++"
export OBJC=${COMPILER_iOS}/clang
export RANLIB=${COMPILER_iOS}/ranlib
./configure \
--build=arm-apple-darwin11 \
--host=arm-apple-darwin11 \
--disable-dependency-tracking \
--enable-shared=no \
--enable-static=yes \
--enable-ltdl=no \
--enable-swig=no \
--enable-tcl=no \
--srcdir=${GVROOT} \
--with-codegens=no \
--with-cgraph=no \
--with-graph=yes \
--with-expat=no \
--with-fontconfig=no \
--with-freetype2=no \
--with-ipsepcola=yes \
--with-libgd=no \
--with-quartz=yes \
--with-visio=yes \
--with-x=no
The compiler normally uses crt1.o combined with crt[i/n].o and crt[begin/end].o to support the constructors and destructors (functions called before and after main and exit).
This error could be caused by this missing library file for the specific deployment target.
First, do some investigation, like:
list all your deployment targets:
ls -la /Developer/SDKs
and find which crt1 libraries do you have for which environment
find /Developer/SDKs -name crt1\*
You could see something like:
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.10.5.o
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.5.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.o
So as you can see, crt1.10.6.o is missing for MacOSX10.5.
Solution 1:
You can solve that by creating the link to the missing file pointed to the other environment, or you could change your deployment target.
E.g.
ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o /Developer/SDKs/MacOSX10.5.sdk/usr/lib/
Also this could be caused, that you have different gcc installed in your system. See:
which gcc;
xcrun -find gcc;
brew list | grep gcc; brew list gcc47
Solution 2
So when you're compiling using make, you can actually specify the right compiler by CC variable. E.g.
CC=/path/to/gcc-3.4 make
Solution 3
What you can also try is specifying the right target deployment environment variable for gcc, by executing the following lines:
export MACOSX_DEPLOYMENT_TARGET=10.5
export C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/include
export LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/lib
If this works, then you can add above lines to your shell profile (~/.profile) to make the change permanent.
How to test
Create the example conftest.c file with the following code:
#ifdef __GNUC__
yes;
#endif
And try to compile it via:
gcc conftest.c
cc conftest.c
cc conftest.cc conftest.c
Troubleshooting
To see which exactly what file is missing, try to debug it using dtruss, e.g.:
sudo dtruss -f gcc conftest.c 2>/dev/stdout | grep crt
You should see something like:
12426/0xb4e3b: stat64("/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/crt1.10.6.o\0", 0x7FFF5FBFE780, 0xB) = -1 Err#2
So once you found the missing file, then you can follow by the first solution by linking the missing file from existing location (e.g. locate crt1.10.6.o). If you will have other missing symbols, then try another file (check the architecture before by: file `locate crt1.10.6.o`).
E.g.
sudo ln -s /Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/crt1.10.6.o /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/crt1.10.6.o
sudo ln -s /Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/crt1.10.6.o /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64/crt1.10.6.o
Related
Error in xcode project: ld: library not found for -lcrt1.10.6.o
If I remember correctly this is what fixed the library not found problem.
CFLAGS="$(OTHER_CFLAGS) -miphoneos-version-min=5.0"
LDFLAGS="$(OTHER_LDFLAGS) --miphoneos-version-min=5.0"
To link this to Xcode, under Build Settings then Header and Library search paths you need to add the paths to the built versions of the library and the header.
You can add the build script as part of your Xcode project, but I haven't had success with this, plus you should only need to build it once per version, so putting the time into anything other than a build script doesn't have much return.
If you decide to put the script in your project anyway (good luck!), then go to the build phases tab, add a build phase of type "Run Script" and paste your script there.