set -e
sudo chflags nouchg client_ios_httpfiles.sh
sudo chflags nouchg exe/*
sudo chmod +x client_ios_httpfiles.sh
sudo chmod +x exe/*
sudo chflags -R nouchg .
sudo xcode-select -switch $1
security -v unlock-keychain -p "sourcecode" "$HOME/Library/Keychains/login.keychain"
xcodebuild -list
xcodebuild -scheme client_ios $2 $3 $4 $5 $6 $7 $8 $9 -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=17.0.1' -archivePath bin/client_ios.xcarchive archive
mkdir bin/client_ios_stripped.xcarchive
cp -r bin/client_ios.xcarchive/. bin/client_ios_stripped.xcarchive
xcrun bitcode_strip -r bin/client_ios.xcarchive/Products/Applications/client_ios.app/client_ios -o bin/client_ios_stripped.xcarchive/Products/Applications/client_ios.app/client_ios
xcodebuild -exportArchive -archivePath bin/client_ios_stripped.xcarchive -exportPath bin -exportOptionsPlist client_ios/exportOptions.plist
rm -r bin/client_ios_stripped.xcarchive
mkdir bin/Release-iphoneos
mkdir bin/Release-iphoneos/client_ios.app.dSYM
cp -r obj/ArchiveIntermediates/client_ios/BuildProductsPath/Release-iphoneos/client_ios.app.dSYM/. bin/Release-iphoneos/client_ios.app.dSYM
mkdir bin/tmp
mv bin/client_ios.ipa bin/tmp
cd bin/tmp
unzip client_ios.ipa
rm client_ios.ipa
codesign -s "iPhone Developer: Dirk Meyer (YSC6QVD64P)" -f --preserve-metadata --generate-entitlement-der Payload/client_ios.app
codesign -d --entitlements - Payload/client_ios.app >../client_ios_entitlements.txt
zip -r ../client_ios.ipa .
cd ../..
rm -r bin/tmp
xcodebuild -scheme client_ios $2 $3 $4 $5 $6 $7 $8 $9 -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=17.0.1'
cd bin/Debug-iphonesimulator
cd client_ios.app
zip -r ../../client_ios.app.zip .
cd ..
cd client_ios_notification_extension.appex
zip -r ../../client_ios_notification_extension.appex.zip .
cd ..
cd client_ios_intents_extension.appex
zip -r ../../client_ios_intents_extension.appex.zip .
cd ..
cd client_ios_broadcast_extension.appex
zip -r ../../client_ios_broadcast_extension.appex.zip .
cd ..
cd client_ios.app.dSYM
zip -r ../../client_ios.app.dSYM.zip .
cd ..
cd ../..
# cd client_ios/phone_ios_restarter
# xcodebuild -list
# xcodebuild -scheme phone_ios_restarter $2 $3 $4 $5 $6 $7 $8 $9 -archivePath bin/phone_ios_restarter.xcarchive archive
# mkdir bin/phone_ios_restarter_stripped.xcarchive
# cp -r bin/phone_ios_restarter.xcarchive/. bin/phone_ios_restarter_stripped.xcarchive
# xcrun bitcode_strip -r bin/phone_ios_restarter.xcarchive/Products/Applications/phone_ios_restarter.app/phone_ios_restarter -o bin/phone_ios_restarter_stripped.xcarchive/Products/Applications/phone_ios_restarter.app/phone_ios_restarter
# xcodebuild -exportArchive -archivePath bin/phone_ios_restarter_stripped.xcarchive -exportPath bin -exportOptionsPlist exportOptions.plist
# rm -r bin/phone_ios_restarter_stripped.xcarchive
# mkdir bin/tmp
# mv bin/phone_ios_restarter.ipa bin/tmp
# cd bin/tmp
# unzip phone_ios_restarter.ipa
# rm phone_ios_restarter.ipa
# codesign -s "iPhone Developer: Dirk Meyer (YSC6QVD64P)" -f --preserve-metadata --generate-entitlement-der Payload/phone_ios_restarter.app
# zip -r ../phone_ios_restarter.ipa .
# cd ../..
# rm -r bin/tmp
# cd ../..
# mkdir bin/phone_ios_restarter
# cp -r client_ios/phone_ios_restarter/bin/. bin/phone_ios_restarter
# xcodebuild test -project client_ios.xcodeproj -scheme client_ios -destination 'platform=iOS,name=Test iPhone' $2 $3 $4 $5 $6 $7 $8 $9 || true
