xcodebuild not building library for simulator - iphone

I'm running a script to build a static library for the device and the simulator to later be merged using lipo.
To build both versions I'm using the following commands:
xcodebuild -target ${L_NAME} -configuration ${CONFIGURATION} -sdk iphonesimulator -arch i386 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
xcodebuild -target ${L_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
The problem is that no iphonesimulator version is created. Inside the Products folder only a Debug-iphoneos version exists.

I eventually found out the problem, I didn't have i386 as a valid architecture

Related

How to compile framework for Mac Catalyst on Xcode 12?

I have been trying to compile the aws-sdk-ios for Mac Catalyst but I wasn't successful yet. Below there is the script that I use to compile for armv7 and x86_64 (simulator).
# Build .a files
xcodebuild ARCHS="i386 x86_64" \
ONLY_ACTIVE_ARCH=NO \
-configuration Debug \
-project "${project_path}" \
-target "${project_name}" \
-sdk iphonesimulator \
SYMROOT=$(PWD)/builtFramework
xcodebuild ARCHS="armv7 arm64" \
ONLY_ACTIVE_ARCH=NO \
-configuration Release \
-project "${project_path}" \
-target "${project_name}" \
-sdk iphoneos \
SYMROOT=$(PWD)/builtFramework
This correctly compiles the project and results into these folders:
I tried to compile the project for Mac Catalyst with multiple variations of the code below (based in multiple examples on the internet):
xcodebuild ONLY_ACTIVE_ARCH=NO \
-project "${project_path}" \
-target "${project_name}" \
-destination "generic/platform=macOS,variant=Mac Catalyst,name=Any Mac"
SYMROOT=$(PWD)/builtFramework
This seems to not create any Release-maccatalyst folder or anything else, even adding these flags:
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES SUPPORTS_MACCATALYST=YES
Or these:
ARCHS="x86_64" VALID_ARCHS="x86_64"
(Also tried with x86_64h, no luck)
With the ARCHS flags above, the compilation fails with these errors:
I am not sure what I need to do to compile the project, anyone could please help me to find the correct script to create the .framework for Catalyst?
Regards,
Pedro

Swift project on GitHub travis-ci check always fail?

I don't know how to edit my .travis.yml. Every time travis-ci check fail, I am almost crazy!
This is my travis-ci link: https://travis-ci.org/liman123/DebugMan
This is my .travis.yml, is there anything wrong? Thanks!
osx_image: xcode8.3
language: objective-c
script:
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace
DebugMan.xcworkspace -scheme DebugMan -sdk iphonesimulator -destination
'platform=iOS Simulator,name=iPhone 6,OS=latest' ONLY_ACTIVE_ARCH=NO |
xcpretty
- pod lib lint
language: objective-c
script:
- xctool -project example.xcodeproj -scheme exampleTests build test -sdk
iphonesimulator GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES
GCC_GENERATE_TEST_COVERAGE_FILES=YES
after_success:
- bash <(curl -s https://codecov.io/bash)
Wrap your first script command in double quotes:
"set pipefail ... | xcpretty"

swift: how to generate arm7 or arm64 from the command line

Using the Xcode 8.3 beta incarnation of swiftc, how do you generate an Arm7 or Arm64 binary?
I've tried the obvious argument -target-cpu arm64 which gives me a linker message <unknown>:0: warning: argument unused during compilation: '-mcpu=arm64'
ld: library not found for -lobjc and it plows ahead trying to build an x64 target.
Actual command:
swiftc -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ -L /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/ -swift-version 3 -target-cpu arm64 somefile.swift
you can use the sdk and target option to do this. Here is an example:
/Projects/Test $ cat main.swift
print("Hello world!");
Compiling for x86_64
/Projects/Test $ swiftc main.swift
/Projects/Test $ lipo -info main
Non-fat file: main is architecture: x86_64
/Projects/Test $ ./main
Hello world!
Compiling for armv7
/Projects/Test $ swiftc main.swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk -target armv7-apple-ios8.1
/Projects/Test $ lipo -info main
Non-fat file: main is architecture: armv7
Compiling for arm64
/Projects/Test $ swiftc main.swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk -target arm64-apple-ios8.1
/Projects/Test $ lipo -info main
Non-fat file: main is architecture: arm64
I wrote a script build.sh so that its easier to use:
#!/bin/sh
TARGET_MAC_VERSION=10.11
TARGET_IOS_VERSION=8.1
if [ "$#" -ne 2 ]; then
echo "Usage $0: <armv7/arm64/x86_64> <file>"
exit
fi
if [ "$1" != 'armv7' ] && [ "$1" != 'arm64' ] && [ "$1" != 'x86_64' ]; then
echo "Usage $0: <armv7/arm64/x86_64>"
exit
fi
if [ "$1" == 'x86_64' ]; then
SDK=macosx
TARGET="x86_64-macosx$TARGET_MAC_VERSION"
else
SDK=iphoneos
TARGET="$1-apple-ios$TARGET_IOS_VERSION"
fi
echo "xcrun -sdk $SDK swiftc $2 -target $TARGET"
xcrun -sdk $SDK swiftc $2 -target $TARGET
Output
$ ./build.sh armv7 main.swift
xcrun -sdk iphoneos swiftc main.swift -target armv7-apple-ios8.1
$ lipo -info main
Non-fat file: main is architecture: armv7
$ ./build.sh arm64 main.swift
xcrun -sdk iphoneos swiftc main.swift -target arm64-apple-ios8.1
$ lipo -info main
Non-fat file: main is architecture: arm64
$ ./build.sh x86_64 main.swift
xcrun -sdk macosx swiftc main.swift -target x86_64-macosx10.11
$ lipo -info main
Non-fat file: main is architecture: x86_64
Edit Note: Optimized the script based on the input from #jens. See the comments for more information.

Compiling Freetype for iPhone SDK (XCode)

I was wondering if anyone knew how to configure FreeType in XCode for the iPhone SDK. I have been trying with no success.
Ideally you'll want to build using the latest tools, and as of the release of iOS 6.0 SDK, with a minimum SDK version of 4.3 and with builds for armv7 and armv7s.
Here is the methid I used to build freetype 2.4.10 for iOS. From the root of the freetype 2.4.10 source, do:
mkdir build-armv7
./configure --prefix=./build-armv7 --host=arm-apple-darwin --enable-static=yes --enable-shared=no \
CPPFLAGS="-arch armv7 -fpascal-strings -Os -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.3 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include/libxml2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \
CC=`xcrun -sdk iphoneos -find clang` \
CFLAGS="-arch armv7 -fpascal-strings -Os -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \
LD=`xcrun -sdk iphoneos -find ld` \
LDFLAGS="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -miphoneos-version-min=4.3" \
AR=`xcrun -sdk iphoneos -find ar`
make
make install
Next, clean the build directory, and build again for armv7s:
make clean
mkdir build-armv7s
./configure --prefix=./build-armv7s --host=arm-apple-darwin --enable-static=yes --enable-shared=no \
CPPFLAGS="-arch armv7s -fpascal-strings -Os -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.3 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include/libxml2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \
CC=`xcrun -sdk iphoneos -find clang` \
CFLAGS="-arch armv7s -fpascal-strings -Os -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \
LD=`xcrun -sdk iphoneos -find ld` \
LDFLAGS="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -miphoneos-version-min=4.3" \
AR=`xcrun -sdk iphoneos -find ar`
make
make install
Finally, combine the architectures into a single binary, and remove the unnecessary extra headers etc. for the second architecture (which are identical to the first architecture).
xcrun -sdk iphoneos lipo -create -arch armv7 build-armv7/lib/libfreetype.a -arch armv7s build-armv7s/lib/libfreetype.a -output libfreetype_universal.a
rm -rf build-armv7s
mv -f libfreetype_universal.a build-armv7/lib/libfreetype.a
mv build-armv7 build
I have; this blog post helped immensely:
http://robertcarlsen.net/2009/03/25/openframeworks-iphone-libs-593
(Plus, there are lots of examples lying around google that do similar things.
Use the configure script supplied with Freetype.
mkdir install_dir
If you are compiling for the simulator:
export CFLAGS = "-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk"
./configure --prefix=install_dir
if you are compiling for a device:
export CFLAGS = "-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk"
./configure --prefix=install_dir --host=arm-apple-darwin
and then
make
make install
You will now find the headers and lib in 'install_dir'.
the 'make install' step is important, as configure will setup the headers correctly. You can't just copy or use them directly from the source tree.
You can build for each platform (simulator and device) and then combine the libs into one multi-architechture lib using the 'lipo' tool.

iPhone SDK location on hard drive

I attempted to reinstall the iphone sdk on my mac. I figured the reinstallation would just override my previous installation but it seems that more hard drive space was eaten up after the second install. Does anyone know how I can refresh my installation and start from scratch to free up all the lost space?
Certainly at least as of Xcode 4.4, this has changed. It's now:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
and
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/
It is also possible to get the path with the xcrun tool. In Terminal.app type the following:
xcrun --sdk iphoneos --show-sdk-path
and
xcrun --sdk iphonesimulator --show-sdk-path
This will have the following results:
$ xcrun --sdk iphoneos --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk
$ xcrun --sdk iphonesimulator --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk
There are SDK folders for each SDK version at:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
and
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs