Make it easy to change the bundle ID

This commit is contained in:
Theodore Dubois 2019-05-11 15:59:19 -07:00
parent 632e4b80de
commit ca00c483b2
8 changed files with 22 additions and 29 deletions

View File

@ -27,31 +27,18 @@ You'll need these things to build the project:
- Clang and LLD (on mac, `brew install llvm`, on linux, `sudo apt install clang lld` or `sudo pacman -S clang lld` or whatever)
- sqlite3 (this is so common it may already be installed on linux and is definitely already installed on mac. if not, do something like `sudo apt install libsqlite3-dev`)
## Build for iOS
Open the project in Xcode and click Run. If you're not me, first open the project build settings and change the Product Bundle Identifier to something unique. There are scripts that should do everything else automatically. If you run into any problems, open an issue and I'll try to help.
## Build command line tool for testing
To set up your environment, cd to the project and run `meson build` to create a build directory in `build`. Then cd to the build directory and run `ninja`.
To set up a self-contained Alpine linux filesystem, download the Alpine minirootfs tarball for i386 from the [Alpine website](https://alpinelinux.org/downloads/) and run the `tools/fakefsify.py` script. Specify the minirootfs tarball as the first argument and the name of the output directory as the second argument. Then you can run things inside the Alpine filesystem with `./ish -f alpine /bin/login -f root`, assuming the output directory is called `alpine`.
You can replace `ish` with `tools/ptraceomatic` to run the program in a real process and single step and compare the registers at each step. I use it for debugging. Requires 64-bit Linux 4.11 or later.
To compile the iOS app, just open the Xcode project and click run. There are scripts that should download and set up the alpine filesystem and create build directories for cross compilation and so on automatically.
## Further setup guide
To enable local development there are a few more steps that needs to be done.
- Go to the project settings in Xcode find the "iSH" target
- Under "General" change the bundle identifier to a specific identifier for you
- Under "Capabilities" change the name of the "App Group" and remove the old app group
- Go to the "iSHFileProvider" target
- Under "General" use the same bundle identifier you created before and add `.FileProvider` to it
- Under "Capabilities" use the same name of the "App Group" as for the "iSH" target
- Go to the file `app/AppDelegate.m`
- Change the string in the function `manager containerURLForSecurityApplicationGroupIdentifier:` to your App Group name that you entered in the step before.
Congratulations! You should now have the app running!
# A note on the JIT
Possibly the most interesting thing I wrote as part of iSH is the JIT. It's not actually a JIT since it doesn't target machine code. Instead it generates an array of pointers to functions called gadgets, and each gadget ends with a tailcall to the next function; like the threaded code technique used by some Forth interpreters. The result is a speedup of roughly 3-5x compared to pure emulation.

View File

@ -99,7 +99,7 @@
[UIApplication openURL:@"https://discord.gg/SndDh5y"];
} else if (cell == self.exportContainerCell) {
// copy the files to the app container so they can be extracted from iTunes file sharing
NSURL *container = [NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:@"group.app.ish.iSH"];
NSURL *container = [NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:PRODUCT_APP_GROUP_IDENTIFIER];
NSURL *documents = [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0];
[NSFileManager.defaultManager removeItemAtURL:[documents URLByAppendingPathComponent:@"roots copy"] error:nil];
[NSFileManager.defaultManager copyItemAtURL:[container URLByAppendingPathComponent:@"roots"]

View File

@ -47,7 +47,7 @@ static void ios_handle_die(const char *msg) {
- (int)startThings {
NSFileManager *manager = [NSFileManager defaultManager];
NSURL *container = [manager containerURLForSecurityApplicationGroupIdentifier:@"group.app.ish.iSH"];
NSURL *container = [manager containerURLForSecurityApplicationGroupIdentifier:PRODUCT_APP_GROUP_IDENTIFIER];
NSURL *alpineRoot = [container URLByAppendingPathComponent:@"roots/alpine"];
[manager createDirectoryAtURL:[container URLByAppendingPathComponent:@"roots"]
withIntermediateDirectories:YES

View File

@ -29,7 +29,7 @@ struct task *fake_task;
return nil;
self.mount->fs = &fakefs;
NSFileManager *manager = NSFileManager.defaultManager;
NSURL *container = [manager containerURLForSecurityApplicationGroupIdentifier:@"group.app.ish.iSH"];
NSURL *container = [manager containerURLForSecurityApplicationGroupIdentifier:PRODUCT_APP_GROUP_IDENTIFIER];
_root = [container URLByAppendingPathComponent:@"roots/alpine/data"];
self.mount->source = strdup(self.root.fileSystemRepresentation);
int err = self.mount->fs->mount(self.mount);

View File

@ -23,7 +23,7 @@
<key>NSExtension</key>
<dict>
<key>NSExtensionFileProviderDocumentGroup</key>
<string>group.app.ish.iSH</string>
<string>$(PRODUCT_APP_GROUP_IDENTIFIER)</string>
<key>NSExtensionFileProviderSupportsEnumeration</key>
<true/>
<key>NSExtensionPointIdentifier</key>

View File

@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.app.ish.iSH</string>
<string>$(PRODUCT_APP_GROUP_IDENTIFIER)</string>
</array>
</dict>
</plist>

View File

@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.app.ish.iSH</string>
<string>$(PRODUCT_APP_GROUP_IDENTIFIER)</string>
</array>
</dict>
</plist>

View File

@ -1192,6 +1192,7 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = "PRODUCT_APP_GROUP_IDENTIFIER=@\\\"$(PRODUCT_APP_GROUP_IDENTIFIER)\\\"";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
@ -1202,6 +1203,8 @@
ISH_LOG = "";
MESON_BUILD_DIR = "$(CONFIGURATION_BUILD_DIR)/meson";
ONLY_ACTIVE_ARCH = YES;
PRODUCT_APP_GROUP_IDENTIFIER = "group.$(PRODUCT_BUNDLE_IDENTIFIER)";
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH.staging;
SDKROOT = iphoneos;
VALID_ARCHS = arm64;
VERSIONING_SYSTEM = "apple-generic";
@ -1233,6 +1236,7 @@
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = "PRODUCT_APP_GROUP_IDENTIFIER=@\\\"$(PRODUCT_APP_GROUP_IDENTIFIER)\\\"";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
@ -1242,6 +1246,8 @@
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
ISH_LOG = "";
MESON_BUILD_DIR = "$(CONFIGURATION_BUILD_DIR)/meson";
PRODUCT_APP_GROUP_IDENTIFIER = "group.$(PRODUCT_BUNDLE_IDENTIFIER)";
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH.staging;
SDKROOT = iphoneos;
VALID_ARCHS = arm64;
VERSIONING_SYSTEM = "apple-generic";
@ -1305,7 +1311,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH;
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
@ -1363,7 +1369,7 @@
INFOPLIST_FILE = app/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH;
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
@ -1407,7 +1413,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH.FileProvider;
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).FileProvider";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
@ -1444,7 +1450,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH.FileProvider;
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).FileProvider";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";